Last active
September 1, 2019 19:11
-
-
Save chaturanga50/14694959d610871762f0b6f4f80ee419 to your computer and use it in GitHub Desktop.
publish multiple coverage reports to one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node('master') { | |
stage('Publish coverage reports') { | |
def pathPattern = ['/target/jacoco/index.html'] | |
pathPattern.each { pattern -> | |
def modules = ['module1', | |
'module2', | |
'module3'] | |
allPaths = [] | |
allModules = [] | |
modules.each { module -> | |
singleModulePath = module + pattern | |
allPaths.push(singleModulePath) | |
allModules.push(module) | |
} | |
reportPath = allPaths.join(',') | |
moduleTitles = allModules.join(',') | |
} | |
try { | |
publishHTML (target: [ | |
allowMissing: false, | |
alwaysLinkToLastBuild: true, | |
keepAll: true, | |
reportDir: '.', | |
reportFiles: "${reportPath}", | |
reportTitles: "${moduleTitles}", | |
reportName: "Coverage Report" | |
]) | |
currentBuild.result = 'SUCCESS' | |
} | |
catch (exc) { | |
echo "Failed to publish coverage report! ${exc}" | |
currentBuild.result = 'FAILURE' | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stage('publish reports') { | |
steps { | |
unstash 'source' | |
script { | |
sh 'rm -f listFiles.txt' | |
sh 'ls target/jmeter/reports > listFiles.txt' | |
def baseDir = ['target/jmeter/reports/'] | |
baseDir.each { base -> | |
allPaths = [] | |
allFiles = [] | |
def files = readFile("listFiles.txt").split("\\r?\\n"); | |
files.each { file -> | |
singleDirPath = base + file | |
allPaths.push(singleModulePath) | |
allFiles.push(file) | |
} | |
reportPath = allPaths.join(',') | |
reportTitles = allFiles.join(',') | |
} | |
publishHTML target: [ | |
allowMissing: false, | |
alwaysLinkToLastBuild: false, | |
keepAll: true, | |
reportDir: '.', | |
reportFiles: "${reportPath}", | |
reportFiles: "${reportTitles}", | |
reportName: "Coverage Report" | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment