Quality gate polling support for jenkins pipelines

I cant open up my jenkins server to the world and sonarcloud no longer has static IPs I can whitelist

I need to poll sonarcloud for quality gate status in my jenkins pipeline

Is there support for this? Do I have to script it myself or is there a function like waitForQualityGate() but for polling?

1 Like

Hello @red_888,

We provided an option to set a secret for your webhook, that way you can verify that the webhook call originated from SonarCloud. Iā€™m afraid there currently is no other alternative.


regardless of the auth support I cant open my jenkins server to the world

I can just keep calling waitForQualityGate() or I can make rest call myself

waitForQualityGate checks the current status of the task and then continues to wait for a webhook. so I have to force it to time out and then call it again. Is there any argument I can pass waitForQualityGate so it just checks the status and exits? I can do my own polling more easily then

Hello @red_888,

This currently does not exist, and it is not on our radar.
If you would like this you can suggest such a feature here.


Not sure if this topic is still actual for somebody, but for those who will be searching for ability how to configure jenkins pipeline without configuring webhook on SonarQube itself here is the workaround:

script {
                    def tries = 0
                    def sonarResultStatus = "PENDING"
                    while ((sonarResultStatus == "PENDING" || sonarResultStatus == "IN_PROGRESS") && tries++ < 10) {
                        try {
                            timeout(time: 5, unit: 'SECONDS') {
                                sonarResult = waitForQualityGate abortPipeline: false
                                sonarResultStatus = sonarResult.status
                        } catch(ex) {
                            echo "Waiting for 'SonarQube' report to finish. Attempt: ${tries}"
                    if (sonarResultStatus != 'OK') {
                        error "Quality gate failure for SonarQube: ${sonarResultStatus}"

This solution will basically poll the sonarqube once in 5 seconds for 10 times (could be configurable) to wait for Success response.

Welcome :slight_smile:

no need for such hacks anymore.
Starting with Sonarqube 8.9 LTS you can use a new generic feature, working for all CI servers.

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

For details see
Overview | SonarQube Docs => Failing a pipeline job when the Quality Gate fails
Broken pipelines for everyone!


1 Like

Good to know, thanks for the reference, but I assume that some projects could still use outdated sonarqube versions, so they will still have additional options to choose. :grinning: