Skip to content

Instantly share code, notes, and snippets.

@chaturanga50
Last active September 1, 2019 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chaturanga50/14694959d610871762f0b6f4f80ee419 to your computer and use it in GitHub Desktop.
Save chaturanga50/14694959d610871762f0b6f4f80ee419 to your computer and use it in GitHub Desktop.
publish multiple coverage reports to one
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'
}
}
}
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