【问题标题】:How to fix unstable builds when thresholds are met?达到阈值时如何修复不稳定的构建?
【发布时间】:2019-11-25 08:46:57
【问题描述】:

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

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

【问题讨论】:

  • 复杂性缺失。编辑:啊,它在报告中。很有趣。
  • 是的,它在报告中,这就是原因,我觉得它很奇怪。

标签: jenkins jenkins-pipeline jenkins-plugins jacoco jacoco-maven-plugin


【解决方案1】:

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

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

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

配置的最大阈值高于实际覆盖范围。如果覆盖率低于最小值,则构建失败,如果覆盖率低于最大值,则构建不稳定,如果高于则构建成功。

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

【讨论】:

    【解决方案2】:

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

    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
    

    附: 我的实际 Coverage 复杂度为 50。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-29
      • 2021-03-26
      • 2021-07-30
      • 2011-05-30
      • 2023-02-23
      • 1970-01-01
      相关资源
      最近更新 更多