Sonarqube scan using gradle fails in the "Quality Gate" step of jenkins pipeline

I want to find an alternative way for sonar build-breaker plugin and found this article

I followed the steps mentioned and configured the pipeline as

node {
  stage('SCM') {
    git ''
  stage('build & SonarQube Scan') {
    withSonarQubeEnv('sonarhost') {
      sh "pwd"
      sh 'dir $WORKSPACE/sonarqube-scanner-gradle/gradle-basic'
      sh 'echo ${PWD}'
      sh 'gradle tasks --all'
      sh 'cd $WORKSPACE/sonarqube-scanner-gradle/gradle-basic'
      sh 'echo ${PWD}'
      sh 'gradle sonarqube --debug -Dsonar.login=my-login-token'
    } // SonarQube taskId is automatically attached to the pipeline context
// No need to occupy a node
stage("Quality Gate") {
  timeout(time: 1, unit: 'HOURS') {
    def qg = waitForQualityGate(webhookSecretId: 'my-login-token') 
    if (qg.status != 'OK') {
      error "Pipeline aborted due to quality gate failure: ${qg.status}"

The pipeline goes upto timeout(time: 1, unit: ‘HOURS’) step and then it fails with the error

Checking status of SonarQube task 'AX_5A5YSuhDrgrHn3OgE' on server 'sonarhost' Error 404 on : 
	at hudson.plugins.sonar.client.HttpClient.getHttp(
	at hudson.plugins.sonar.client.WsClient.getCETask(
	at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.checkTaskCompleted(

And when i checked the earlier log output, i saw this

Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
09:17:16.205 [INFO] [org.sonarqube.gradle.SonarQubeTask] More about the report processing at

The link where the report is uploaded and the link at the quality gate step are different
Error 404 on and
More about the report processing at [](

From where is this link picked up?
How can i fix this.

i tried to fix it by adding sonarqube link as sonar-host:9000/sonar in jenkins global settings page and now the error is something else.

SonarQube task 'AX_5Mge_uhDrgrHn3OgG' status is 'PENDING'

A webhook secret id was configured, but the corresponding credential could not be found
ERROR: Pipeline aborted due to failed webhook verification

Answering my own question “adding sleep 20” in between steps solved the error.
Thanks for reading and hope this helps someone else

1 Like


since Sonarqube 8.9 there is a new way, if for whatever reasons the waitForQualityGate step doesn’t work.
You might use the property sonar.qualitygate.wait=true which works the other way around,
means it does an active polling for the quality gate result instead of creating a listener and waiting for the webhook.
There’s also sonar.qualitygate.timeout with a default of 300 sec.