【问题标题】:jenkins declerative pipeline - fail build when coverage dropsjenkins 声明性管道 - 覆盖率下降时构建失败
【发布时间】:2020-07-21 23:37:03
【问题描述】:

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

希望能提供参考或代码 sn-p。

【问题讨论】:

    标签: jenkins jenkins-pipeline jenkins-groovy cobertura


    【解决方案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',
    )
    
    

    【讨论】:

      猜你喜欢
      • 2011-09-23
      • 1970-01-01
      • 1970-01-01
      • 2017-12-03
      • 2017-05-22
      • 1970-01-01
      • 1970-01-01
      • 2020-05-30
      • 1970-01-01
      相关资源
      最近更新 更多