Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Fail A Build In Jenkins If The Number Of Compiler Warnings Increases?

Tags:

java

jenkins

In TeamCity I can add a Build Failure condition that fails the build if the number of compiler/inspection warnings increases from the previousl successful build

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

How do I do the same thing in Jenkins?

like image 821
opticyclic Avatar asked Jul 11 '16 13:07

opticyclic


2 Answers

The Warnings Plug-in should do exactly what you want. It will mark the build as unstable or failed based on the number of warnings, or optionally new warnings of specific priorities.

Fail build on any new compiler warnings

If you set "All priorities" to "0" as shown, it should do what you want. If that is not sufficient, the plugin also includes the options "Use delta for new warnings", "Use previous build as reference", and "Only use stable builds as reference" with detailed descriptions of how each of those options changes the behavior.

like image 167
BitwiseMan Avatar answered Sep 28 '22 06:09

BitwiseMan


The warnings plugin has been deprecated and replaced by the Warnings Next Generation Plugin. The equivalent feature is referred to as a Quality Gate.

Use a Quality Gate type of "NEW", with a threshold of 1, to fail the build if there are new issues since the last successful build.

If using pipelines, this stage will parse the results, and fail if there is a new lint failure present.

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']]
    }
  }
}

like image 32
CamM Avatar answered Sep 28 '22 07:09

CamM