在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。
会很感激一个参考或代码片段。
2条答案
按热度按时间kx7yvsdv1#
结合硬编码阈值启用
autoUpdateHealth
可以达到这个目的of1yzvn42#
下面是我们用来在覆盖率下降时使构建失败的代码,关键是将 failBuildIfCoverageDecreasedInChangeRequest 和 applyThresholdRecursively 设置为true: