达到阈值时如何修复不稳定的构建?

How to fix unstable builds when thresholds are met?

我的总体覆盖率达到了阈值,但构建仍然被标记为不稳定。有谁知道这是什么原因?

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

好的,根据我找到的链接,覆盖率应该高于最小和最大覆盖率。

查看链接 https://issues.jenkins-ci.org/browse/JENKINS-16903 — 报告了同样的意外行为。

https://groups.google.com/forum/#!topic/jenkins-jacoco-plugin-mailing-list/pzHm98RJjB8/discussion — 这里最终声明的规则是:

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.

从第二个主题看来,仅指定一个阈值(或仅指定最小值)似乎也不起作用。因此,我建议您尝试将最小值和最大值都设置为您预期的最小值。

通过添加以下配置修复不稳定的构建。

10:43:30 [JaCoCo plugin] Overall coverage: class: 89, method: 89, line: 77, branch: 41, instruction: 67
10:43:30 [JaCoCo plugin] Health thresholds: JacocoHealthReportThresholds [minClass=30, maxClass=75, minMethod=30, maxMethod=75, minLine=30, maxLine=75, minBranch=30, maxBranch=40, minInstruction=30, maxInstruction=65, minComplexity=30, maxComplexity=49]
10:43:30 [JaCoCo plugin] Apply Min/Max thresholds result: SUCCESS

P.S。 我的实际Coverage复杂度是50。