Hi, I am using jacoco plugin to make sure if the coverage is less than 70 % then build should failed. for that i am using below script, but in logs of jacoco step getting failure but pipeline shows Green color, and it continues.
stage('Jacoco') {
steps {
script {
jacoco classPattern: '**/build/classes/java', changeBuildStatus: true, minimumInstructionCoverage: '70', maximumInstructionCoverage: '80'
if(env.BRANCH_NAME.equals('develop')) {
def publishResult = publishCoverage failUnhealthy: true,
globalThresholds: [[thresholdTarget: 'Instruction', unhealthyThreshold: 80.0]],
adapters: [jacocoAdapter(path: 'build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml')],
sourceFileResolver: sourceFiles('STORE_ALL_BUILD')
script {
if (currentBuild.result == 'FAILURE') {
error("Test coverage is too low.")
}
}
}
}
}
}
In the log of jacoco step getting below message at the end :
[JaCoCo plugin] Apply Min/Max thresholds result: FAILURE
Please suggest the solution