JK
This commit is contained in:
parent
0674e0b782
commit
af0ac14aca
23
Jenkinsfile
vendored
23
Jenkinsfile
vendored
@ -23,6 +23,7 @@ pipeline {
|
|||||||
TEST_RESULTS_DIR = 'TestResults'
|
TEST_RESULTS_DIR = 'TestResults'
|
||||||
COVERAGE_DIR = 'TestResults/Coverage'
|
COVERAGE_DIR = 'TestResults/Coverage'
|
||||||
COVERAGE_FILE = 'TestResults/Coverage/coverage.opencover.xml'
|
COVERAGE_FILE = 'TestResults/Coverage/coverage.opencover.xml'
|
||||||
|
COVERAGE_HTML_DIR = 'TestResults/Coverage/html'
|
||||||
|
|
||||||
// Path ติดตั้ง dotnet ชั่วคราวใน pipeline
|
// Path ติดตั้ง dotnet ชั่วคราวใน pipeline
|
||||||
DOTNET_ROOT = "${WORKSPACE}/.dotnet"
|
DOTNET_ROOT = "${WORKSPACE}/.dotnet"
|
||||||
@ -85,13 +86,18 @@ pipeline {
|
|||||||
echo '### dotnet --info'
|
echo '### dotnet --info'
|
||||||
dotnet --info
|
dotnet --info
|
||||||
|
|
||||||
echo '### Install/Update dotnet-sonarscanner'
|
echo '### Install/Update dotnet tooling'
|
||||||
dotnet tool install --global dotnet-sonarscanner || dotnet tool update --global dotnet-sonarscanner
|
dotnet tool install --global dotnet-sonarscanner || dotnet tool update --global dotnet-sonarscanner
|
||||||
|
dotnet tool install --global dotnet-reportgenerator-globaltool || dotnet tool update --global dotnet-reportgenerator-globaltool
|
||||||
'''
|
'''
|
||||||
script {
|
script {
|
||||||
if (!env.PATH.contains('/root/.dotnet/tools')) {
|
if (!env.PATH.contains('/root/.dotnet/tools')) {
|
||||||
env.PATH = "${env.PATH}:/root/.dotnet/tools"
|
env.PATH = "${env.PATH}:/root/.dotnet/tools"
|
||||||
}
|
}
|
||||||
|
if (env.WORKSPACE && !env.PATH.contains("${env.WORKSPACE}/.dotnet")) {
|
||||||
|
env.PATH = "${env.WORKSPACE}/.dotnet:${env.PATH}"
|
||||||
|
env.DOTNET_ROOT = "${env.WORKSPACE}/.dotnet"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,6 +126,7 @@ pipeline {
|
|||||||
sh '''#!/bin/bash -e
|
sh '''#!/bin/bash -e
|
||||||
rm -rf "${TEST_RESULTS_DIR}"
|
rm -rf "${TEST_RESULTS_DIR}"
|
||||||
mkdir -p "${COVERAGE_DIR}"
|
mkdir -p "${COVERAGE_DIR}"
|
||||||
|
mkdir -p "${COVERAGE_HTML_DIR}"
|
||||||
dotnet test AS400API.sln --configuration "${BUILD_CONFIGURATION}" --no-build \
|
dotnet test AS400API.sln --configuration "${BUILD_CONFIGURATION}" --no-build \
|
||||||
/p:CollectCoverage=true \
|
/p:CollectCoverage=true \
|
||||||
/p:CoverletOutputFormat=opencover \
|
/p:CoverletOutputFormat=opencover \
|
||||||
@ -127,9 +134,20 @@ pipeline {
|
|||||||
--results-directory "${TEST_RESULTS_DIR}" \
|
--results-directory "${TEST_RESULTS_DIR}" \
|
||||||
--logger "trx;LogFileName=test-results.trx" \
|
--logger "trx;LogFileName=test-results.trx" \
|
||||||
--logger "junit;LogFileName=test-results.xml"
|
--logger "junit;LogFileName=test-results.xml"
|
||||||
|
|
||||||
|
reportgenerator \
|
||||||
|
-reports:"${COVERAGE_FILE}" \
|
||||||
|
-targetdir:"${COVERAGE_HTML_DIR}" \
|
||||||
|
-reporttypes:"HtmlInline_AzurePipelines;Cobertura"
|
||||||
'''
|
'''
|
||||||
junit testResults: "${TEST_RESULTS_DIR}/**/*.xml", allowEmptyResults: false
|
junit testResults: "${TEST_RESULTS_DIR}/**/*.xml", allowEmptyResults: false
|
||||||
publishCoverage adapters: [opencoverAdapter("${COVERAGE_FILE}")], sourceFileResolver: sourceFiles('STORE_LAST_BUILD'), failNoReports: true
|
publishHTML(target: [
|
||||||
|
allowMissing : false,
|
||||||
|
keepAll : true,
|
||||||
|
reportDir : "${COVERAGE_HTML_DIR}",
|
||||||
|
reportFiles : 'index.html',
|
||||||
|
reportName : 'Code Coverage'
|
||||||
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,6 +215,7 @@ pipeline {
|
|||||||
archiveArtifacts artifacts: "${PUBLISH_DIR}/**", fingerprint: true
|
archiveArtifacts artifacts: "${PUBLISH_DIR}/**", fingerprint: true
|
||||||
archiveArtifacts artifacts: "${TEST_RESULTS_DIR}/**/*.trx", allowEmptyArchive: true
|
archiveArtifacts artifacts: "${TEST_RESULTS_DIR}/**/*.trx", allowEmptyArchive: true
|
||||||
archiveArtifacts artifacts: "${COVERAGE_FILE}", allowEmptyArchive: true
|
archiveArtifacts artifacts: "${COVERAGE_FILE}", allowEmptyArchive: true
|
||||||
|
archiveArtifacts artifacts: "${COVERAGE_HTML_DIR}/**", allowEmptyArchive: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user