Sonarqube jenkins plugin : show unstable build if quality gate fails


We use sonarqube entreprise version 8.9.6 with Jenkins 2.346.1 and jenkins plugins sonnarQube Scanner in version 2.14 (cf SonarQube Scanner).

My jenkins job is configured not to fail on quality gate with this standard script :
waitForQualityGate abortPipeline: false

The false value is because of large legacy code base we want to improve progressively.

I was expecting it to work as the junit plugin : if some tests fail, the stage is displayed as unstable in jenkins but the job finishes ok.
With sonar quality gate with parameter abortPipeline at false, when my job does not meet the quality gate requirement, I would expect that if the quality gate fails, the stage is displayed as unstable (yellow) and the job finishes ok.
What I see as current behavior is the stage is ok (green) and the job finishes ok when the quality gate is not met.
So the precision of the result could be improved and I, for example, could configure jenkins to send a mail on unstable job to notify the team of quality gate failure but the build would be finished.

I did some search how it could be done and I discovered it is quite a recent behavior in Jenkins (introduced in 2019).
The following links could help you implement the wished behavior :

Could you please consider this small improvement and add the display of unstable stage when quality gate is not met and abort pipeline is configured at false.

Thank you,


In my pipeline I use:

warnError('<message to show on console and Blue Ocean>') {
  waitForQualityGate(abortPipeline: true)
  ... <other steps that may raise error> ...

This way, if QG is not met, the pipeline will be mark as unstable.

Yes, programming it in the JenkinsFile is a way to do it but we have lots of jobs using it in a dynamic way with such a syntax :
waitForQualityGate abortPipeline: params.isQGBlocking

I created this topic in the hope to have a native way for this behaviour in the sonar jenkins public directly. With this small improvement, the update of the plugin is the only action to have the correct behaviour for all jobs using it.

Well, you can dynamically wrap your command inside a warnError() { ... }.

Or, if you are willing to, file a PR in GitHub plugin repository that address this change.

I did it here : Mark jenkins build UNSTABLE if QG failed and pipeline abort parameter is false by cnico · Pull Request #11 · jenkinsci/sonarqube-plugin · GitHub
The code ans unit test was quite simple to implement but the integration test with a fresh installation of Sonar + jenkins + sonarscanner plugins was a longer. It works as expected.

If you can merge it and provide a new release of the plugin, it would be nice.