Search code examples
jenkinsjenkins-pipelinejenkins-pluginsjacocojacoco-maven-plugin

How to fix unstable builds when thresholds are met?


My overall coverage is meeting the threshold, but still build is marked as Unstable. Does anyone know the reason for this?

16:53:04 [JaCoCo plugin] Thresholds: JacocoHealthReportThresholds [minClass=75, maxClass=99, minMethod=75, maxMethod=99, minLine=75, maxLine=99, minBranch=40, maxBranch=99, minInstruction=65, maxInstruction=99, minComplexity=0, maxComplexity=99]
16:53:04 [JaCoCo plugin] Publishing the results..
16:53:04 [JaCoCo plugin] Loading packages..
16:53:04 [JaCoCo plugin] Done.
16:53:04 [JaCoCo plugin] Overall coverage: class: 89, method: 89, line: 77, branch: 41, instruction: 67
16:53:04 [JaCoCo plugin] Health thresholds: JacocoHealthReportThresholds [minClass=75, maxClass=99, minMethod=75, maxMethod=99, minLine=75, maxLine=99, minBranch=40, maxBranch=99, minInstruction=65, maxInstruction=99, minComplexity=0, maxComplexity=99]
16:53:04 [JaCoCo plugin] Apply Min/Max thresholds result: UNSTABLE

Jacoco report


Solution

  • Ok, according to links I found, the coverage should be ABOVE both minimum and maximum coverage.

    See the links https://issues.jenkins-ci.org/browse/JENKINS-16903 — reporting the same unexpected behaviour.

    https://groups.google.com/forum/#!topic/jenkins-jacoco-plugin-mailing-list/pzHm98RJjB8/discussion — here the rule it is finally declared:

    The configured maximum thresholds are above the actual coverage. If a coverage is below minimum the build fails, if the coverage is below maximum the build is unstable, if it is above then it is a success.

    It also seems from the second topic that specifying only one threshold (or only minimum) does not work. Therefore I'd recommend you to try setting both min and max to your expected minimum.