Sure @poddingue
This is the stage in our pipeline
stage('Analyze code coverage') {
when { expression { env.codeCoverage == "true" }}
steps { container(c) { script {
usageLog(env.sourceCommit,"coverage","ciaas_bazel_coverage","ciaas","jenkins","ciaas","jenkins",true)
analyzeCodeCoverage()
}}}
post { always { container(c) { script {
usageLog(env.sourceCommit,"coverage","ciaas_bazel_coverage","ciaas","jenkins","ciaas","jenkins",false,currentBuild.currentResult=="FAILURE"?usageLogLabels:getCompiledFileInfo())
}}}}
}
and the analyzecoverage method is:
def analyzeCodeCoverage() {
env.CURRENT_STAGE = env.STAGE_NAME
boolean coverageFileFount = false;
sh """
./infrastructure/ci/code_coverage '${env.SERVICE_NAME}'
"""
if (findFiles(glob: "ci-testlogs/**/jacoco.xml").length > 0) {
println("jacoco file found")
publishCoverage adapters: [jacocoAdapter('ci-testlogs/**/jacoco.xml')]
coverageFileFount = true;
}
if(fileExists(env.CODE_COVERAGE_FILE)) {
println("coverage file found")
def coverage_file = readFile(env.CODE_COVERAGE_FILE)
if (coverage_file.size()) {
cobertura(autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: env.CODE_COVERAGE_FILE,
conditionalCoverageTargets: '70, 0, 0', failNoReports: false, failUnhealthy: false, failUnstable: false,
lineCoverageTargets: '80, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '80, 0, 0', onlyStable: false,
sourceEncoding: 'ASCII', zoomCoverageChart: false)
}
coverageFileFount = true;
}
if (!coverageFileFount) {
unstable("Code coverage file not found.")
}
}
And as i mentioned jenkins log i can see both the reports are generated successfully but not displaying the 1st one.