A Jenkins pipeline that calls withSonarQubeEnv and stops there does not gate anything. It runs the analysis, ships the results to SonarQube, and reports success whatever the quality gate says. To actually fail the build you need two more things — the waitForQualityGate step, and a webhook configured in SonarQube pointing back at Jenkins. Miss the webhook and the step has nothing to wake it up.
A SonarQube stage that is only withSonarQubeEnv('SonarQube') { sh 'mvn clean verify sonar:sonar …' } cannot fail a build on quality. Nothing in it reads the gate.
Table of Contents
What SonarSource actually requires
From SonarSource’s Setting up a pause in Jenkins pipeline, step 2 of the procedure, their emphasis:
“Configure a webhook for your project in your SonarQube Server pointing to
<yourJenkinsInstance>/sonarqube-webhook/(This is the URL exposed by the Jenkins extension). You may use a webhook configured at global level if applicable to your project. … This step is mandatory!“
And the key-features page on why: “the extension makes webhook available: a webhook call must be configured in SonarQube Server to call back into Jenkins to allow the pipeline to continue or fail.” The gate result travels from SonarQube to Jenkins. Jenkins does not go and ask.
The plugin’s own in-product help — which I pulled out of the artifact, see below — adds the detail that eats an afternoon: “Configure a webhook in your SonarQube server pointing to <your Jenkins instance>/sonarqube-webhook/. The trailing slash is mandatory!“
The working shape
SonarSource’s own declarative example, verbatim from the page above:
stage("Quality Gate") {
steps {
timeout(time: 1, unit: 'HOURS') {
// Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails
// true = set pipeline to UNSTABLE, false = don't
waitForQualityGate abortPipeline: true
}
}
}
Those two comment lines disagree with the plugin. The plugin’s help for the same parameter says: “Setting the parameter abortPipeline to true will abort the pipeline if quality gate status is not green.” Abort, not UNSTABLE. Both texts are published by SonarSource; I have not run a pipeline to settle which the code does, so treat the outcome as worth confirming on your own controller before you rely on it. Either way abortPipeline: true is the flag you want — the default is not to stop.
The timeout wrapper is not decoration. SonarSource’s scripted example comments it as “Just in case something goes wrong, pipeline will be stopped after a timeout”. My inference, not theirs: a missing or misdirected webhook is the ordinary way “something goes wrong”, and the visible symptom is a Quality Gate stage that hangs for the timeout and then fails for a reason that has nothing to do with your code. Without the timeout it hangs indefinitely. Neither failure mode looks like “webhook”.
What the plugin needs from Jenkins, and where the token goes
Here is what the current plugin actually demands, taken from the artifact rather than from anyone’s memory:
$ curl -sSL -o uc.json https://updates.jenkins.io/current/update-center.actual.json
$ python3 -c "import json;d=json.load(open('uc.json'));p=d['plugins']['sonar'];print(d['core']['version'],p['version'],p['requiredCore'],p['releaseTimestamp'])"
2.577 2.18.3 2.479.3 2026-06-17T05:53:09.00Z
$ curl -sSL -o sonar.hpi https://updates.jenkins.io/download/plugins/sonar/2.18.3/sonar.hpi
$ shasum -a 256 sonar.hpi | cut -d' ' -f1 | xxd -r -p | base64
y+BK9iCcPyPNqZNSMBdVdHT3OBYok25YHBoUWxponTo= # identical to the update centre's declared sha256
$ unzip -p sonar.hpi META-INF/MANIFEST.MF | grep -E 'Short-Name|Long-Name|Plugin-Version|Jenkins-Version'
Short-Name: sonar
Long-Name: SonarQube Scanner for Jenkins
Plugin-Version: 2.18.3
Jenkins-Version: 2.479.3
The plugin requires Jenkins 2.479.3. The plugin ID to search for in the Jenkins plugin manager is sonar; its display name is SonarQube Scanner. Worth knowing that SonarSource’s current documentation calls the thing “the Jenkins extension” and no longer uses the older product name in prose — but the jar it ships still carries Long-Name: SonarQube Scanner for Jenkins, which is why you will keep meeting both names.
Do not put the token in a committed sonar-project.properties as sonar.login=your_generated_token, and do not pass -Dsonar.login=$SONARQUBE_TOKEN on the Maven command line either. A SonarQube token is a bearer credential; a file in your repository root and a process argument are both places it does not belong, and that is my judgement rather than a quotation from anyone. The documented route is a Jenkins credential — SonarSource’s setup page says “Kind: Secret Text” and “Secret: Generate a token at User > My Account > Security in SonarQube Server” — after which withSonarQubeEnv injects it and you pass no token anywhere. Per-job override is withSonarQubeEnv(credentialsId: '…', installationName: '…'). And if you want the webhook payload itself authenticated, the plugin takes a secret: waitForQualityGate(webhookSecretId: 'yourSecretID').
What was not tested
No Jenkins controller and no SonarQube Server were run. No pipeline was executed and no gate was made to pass or fail — every behavioural statement above is a quotation from SonarSource’s documentation, a quotation from the plugin artifact I downloaded, or labelled inference. What was executed is exactly the block shown: the update-centre fetch, the plugin download, the hash comparison, the manifest read, and the extraction of WaitForQualityGateStep/help.html; integrating-sonarqube-with-jenkins.sh repeats all five against the live update centre and then re-fetches SonarSource’s pages to grep for the quoted wording. The contradiction between the docs comment and the plugin help is reported, not resolved.
For what the gate is actually measuring once it works, see JaCoCo coverage gates in SonarQube — the default gate’s conditions are all on new code, which surprises most people the first time. For driving SonarQube from outside a pipeline, see the SonarQube Web API guide; for the surrounding pipeline, the Laravel Jenkins CI/CD pipeline.