在Jenkinsfile
中使用权威性管道语法,并使用cobertura如下发布覆盖率报告
cobertura(
coberturaReportFile: 'coverage/cobertura-coverage.xml',
enableNewApi: true,
autoUpdateHealth: true,
autoUpdateStability: true,
failUnstable: true,
failUnhealthy: true,
failNoReports: true,
onlyStable: false
)
还尝试如下使用code coverage api:
publishCoverage(
failUnhealthy: true,
calculateDiffForChangeRequests: true,
failBuildIfCoverageDecreasedInChangeRequest: true,
failNoReports: true,
adapters: [
coberturaAdapter(path: 'coverage/cobertura-coverage.xml')
]
)
查看我能找到的所有文档,如果不使用硬编码阈值,我将无法找出what are the instructions to fail the build if coverage drops。
将感谢您提供参考或代码段。
答案 0 :(得分:1)
启用autoUpdateHealth
并结合硬编码阈值可以解决问题
cobertura(
coberturaReportFile: 'coverage/cobertura-coverage.xml',
enableNewApi: true,
autoUpdateHealth: true,
autoUpdateStability: true,
failUnstable: true,
failUnhealthy: true,
failNoReports: true,
onlyStable: false
conditionalCoverageTargets: '80, 0, 0',
fileCoverageTargets: '80, 0, 0',
lineCoverageTargets: '80, 0, 0',
methodCoverageTargets: '80, 0, 0',
packageCoverageTargets: '80, 0, 0',
)