SonarScanner for Jenkins - incorrect analysis ID referred by waitForQualityGate step

Hi,

there’s an alternative solution.
Instead of using the waitForQualityGate() Jenkins pipeline step, you might use a new generic
feature, working for all CI servers.

It works the other way around, polling for the quality gate result instead of waiting for webhook
with the matching analysisid from Sonarqube server.

That’s what we did for Sonarqube scans in Jenkins parallel step, as this is still not officially
supported =
[SONARJNKNS-316] - Jira (which was created after we raised
a ticket for Sonarsourc support)

and it works.

Simply use property sonar.qualitygate.wait=true
There is an additional property sonar.qualitygate.timeout with default 300 / 5 mins

For details see
CI integration overview => Failing a pipeline job when the Quality Gate fails
Broken pipelines for everyone!

The docs have

[…]
This increases the pipeline duration and causes the analysis step to fail any time the Quality Gate fails, even if the actual analysis is successful. You should only use this parameter if it’s necessary.

but it works for us and in fact it decreased the pipeline duration, as there were hacks like an additional sleep before the waitForQualityGate() step to make it work with Jenkins parallel step.
Using sonar.qualitygate.wait=true was also the recommendation from Sonarsource itself for our use case.

Gilbert

1 Like