Hi,
My Jenkins version is Jenkins 2.346.3 and my Cobertura version is 1.16. I have unit tests for all codes.
My thresholds are as shown below;
" stage(‘UnitTest-Coverage’) {
steps {
sh “”"
echo “Running Unit Tests”
“”"
junit ‘test.xml’
sh “”"
echo “Running Cobertura Code Coverage”
“”"
cobertura autoUpdateHealth: false, autoUpdateStability: false, classCoverageTargets: ‘100, 0, 100’, coberturaReportFile: ‘coverage*.xml’, conditionalCoverageTargets: ‘10, 0, 10’, failUnhealthy: false, fileCoverageTargets: ‘100, 0, 100’, lineCoverageTargets: ‘70, 0, 70’, maxNumberOfBuilds: 0, methodCoverageTargets: ‘100, 0, 100’, onlyStable: false, packageCoverageTargets: ‘100, 0, 100’, sourceEncoding: ‘ASCII’, zoomCoverageChart: false
sh “”"
echo “Running Code Coverage”
“”"
publishCoverage adapters: [coberturaAdapter(‘coverage*.xml’)], failUnstable: true, globalThresholds: [[thresholdTarget: ‘Method’, unstableThreshold: 100.0], [thresholdTarget: ‘Package’, unstableThreshold: 100.0], [thresholdTarget: ‘Line’, unstableThreshold: 70.0], [thresholdTarget: ‘Conditional’, unstableThreshold: 10.0], [thresholdTarget: ‘Class’, unstableThreshold: 100.0], [thresholdTarget: ‘File’, unstableThreshold: 100.0]], sourceFileResolver: sourceFiles(‘STORE_LAST_BUILD’) "
I get this error when I build ;
Build failed because following metrics did not meet stability target: [Method {unstableThreshold=100.0, unhealthyThreshold=0.0}].
But the code coverage report is good for my threshold.
Why did fail the build?