如果编译器警告的数量增加,我如何在Jenkins中失败?

时间:2016-07-11 13:41:11

标签: java jenkins

在TeamCity中,如果编译器/检查警告的数量与之前的成功构建相比增加,我可以添加构建失败条件,使构建失败

https://confluence.jetbrains.com/display/TCD9/Build+Failure+Conditions#BuildFailureConditions-Failbuildonmetricchange

我如何在詹金斯做同样的事情?

2 个答案:

答案 0 :(得分:3)

Warnings Plug-in应该完全符合您的要求。它会根据警告的数量或可选的特定优先级的新警告将构建标记为不稳定或失败。

Fail build on any new compiler warnings

如果您设置"所有优先级"到" 0"如图所示,它应该做你想要的。 如果这还不够,该插件还包括选项"使用delta作为新警告","使用以前版本作为参考"和"仅使用稳定版本作为参考" 34;详细描述了每个选项如何改变行为。

答案 1 :(得分:0)

警告插件已被弃用,并由Warnings Next Generation Plugin取代。等效的功能称为“质量门”。

如果自上次成功构建以来出现新问题,请使用Quality Gate type of "NEW", with a threshold of 1来使构建失败。

如果使用管道,则此阶段将解析结果,如果出现新的皮棉故障,则失败。

stage('lint') {
  steps {
    // ..generate eslint report, other types are supported by the plugin...
  }
  post {
    always {
      // record lint issues found, also, fail the build if there are ANY NEW issues found
      recordIssues enabledForFailure: true,
        blameDisabled: true,
        tools: [esLint(pattern: 'checkstyle-results.xml')],
        qualityGates: [[threshold: 1, type: 'NEW']]
    }
  }
}