使用具有以下配置的 Jenkins Jacoco 插件版本 3.0.1 会生成有效的覆盖率报告,但实际上无法更改构建状态。
jacoco(
execPattern: '**/target/code-coverage/**.exec',
classPattern: '**/target/classes',
sourcePattern: '**/src',
inclusionPattern: 'com/company/**',
changeBuildStatus: true,
minimumInstructionCoverage: '70'
)
记录的输出是
[JaCoCo plugin] Overall coverage: class: 19, method: 9, line: 4, branch: 2, instruction: 3
[JaCoCo plugin] Health thresholds: JacocoHealthReportThresholds [minClass=0, maxClass=0, minMethod=0, maxMethod=0, minLine=0, maxLine=0, minBranch=0, maxBranch=0, minInstruction=0, maxInstruction=0, minComplexity=0, maxComplexity=0]
[JaCoCo plugin] Apply Min/Max thresholds result: SUCCESS
“Apply Min/Max thresholds”行表示已注册 changeBuildStatus 标志,但阈值均显示为 0。
changeBuildStatus 是否真的适用于管道,如果适用,设置阈值的正确格式是什么?
最佳答案
对我来说,我需要添加相应的 maximumCoverage 值。例如,
jacoco(
execPattern: '**/target/code-coverage/**.exec',
classPattern: '**/target/classes',
sourcePattern: '**/src',
inclusionPattern: 'com/company/**',
changeBuildStatus: true,
minimumInstructionCoverage: '70',
maximumInstructionCoverage: '80'
)
希望这能解决您的问题。
关于jenkins - 如何使用 Jacoco 和 Jenkins Pipeline 更改构建状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51117101/