Jenkins Creation Unstable design when sonar limits are exceeded

We are launching Jenkins Sonar and would like to point out that the build is unstable when Sonar limits are exceeded. We have the appropriate restrictions set as β€œAlerts” in the quality profile.

We thought that we could use Build Breaker to mark Sonar as unsuccessful (which puts this fact in the Jenkins log), and then use the Jenkins Post-build Groovy script for unstable builds in this case.

Unfortunately, the Jenkins Sonar plugin reports a build failure (and stops the build process) if Sonar does not work, and Jenkins people indicated that, in accordance with the request and the installation of the corresponding defect, β€œnot fix”.

I also tried to set up Sonar's registration in Verbose, hoping that the fact that the limits that were exceeded would be in the log (so that we could use the post build Groovy task again), but that doesn't seem to either.

Any insight? At the moment, it seems to me that it is best to create a Build Breaker option that simply reports that it warns, but does not break the build, but I would prefer not to go through a custom plugin if it can be avoided.

+5
source share
3 answers

Well, we solved it to our satisfaction, although it did require a custom Sonar plugin.

BuildBreaker ( BuildWarner). ( , , ..) - 44 AlertThresholdChecker.java :

  fail("Alert thresholds have been hit (" + count + " times).");

to:

  logger.info("SONARTHRESHOLDSEXCEEDED - Alert thresholds have been hit (" + count + " times).");

Sonar, Jenkins SONARTHRESHOLDSEXCEEDED, .

Jenkins Groovy Postbuild. Groovy script:

if(manager.logContains(".*SONARTHRESHOLDSEXCEEDED.*")) {
     manager.addWarningBadge("Sonar Thresholds Exceeded")
     manager.createSummary("warning.gif").appendText("<h1>Sonar Thresholds Exceeded</h1>", false, false, false, "red")
     manager.buildUnstable()
}

Jenkins Text Finder, .

, Sonar Groovy Post Build Text Finder.

, .

+5

Sonar Build Breaker, ERROR_THRESHOLD_EXCEEDED, WARNING_THRESHOLD_EXCEEDED, . build warner https://github.com/NitorCreations/sonar-build-warner-plugin

, Jenkins, . github.

+3

All Articles