Observed May 16, 2019
SonarCloud
SonarQube Scanner for Jenkins 2.8.1
Kubernetes Plugin for Jenkins 1.15.2
Around 50% of the time waitForQualityGate
is timing out in our pipeline. The webhook is configured and we can see Status Code 200 with the correct payload in the SonarCloud Administration “recent deliveries” UI. Regardless, the logs for waitForQualityGate
never continue beyond “IN_PROGRESS” and our timeout option kicks in and aborts the build.
Logs from one such event:
Jenkins Pipeline Log
Checking status of SonarQube task 'AWrCbBP***********' on server 'sq-cloud'
SonarQube task 'AWrCbBP***********' status is 'IN_PROGRESS'
Jenkins Server Logs (Abbreviated)
May 16, 2019 8:52:37 PM INFO hudson.plugins.sonar.SonarBuildWrapper setUp
Injecting SonarQube environment variables using the configuration: sq-cloud
May 16, 2019 8:52:37 PM INFO hudson.plugins.sonar.SonarBuildWrapper createLoggerDecorator
Masking SonarQube passwords
May 16, 2019 8:53:45 PM INFO org.sonarsource.scanner.jenkins.pipeline.SonarQubeWebHook doIndex
Received POST from 18.195.64.198
May 16, 2019 8:53:45 PM FINE org.sonarsource.scanner.jenkins.pipeline.SonarQubeWebHook
Full details of the POST was {"serverUrl":"https://sonarcloud.io","taskId":"AWrCbBP***********","status":"SUCCESS","analysedAt":"2019-05-16T22:53:21+0200","changedAt":"2019-05-16T22:53:21+0200"....
Pipeline Definition (relevant portion)
stage('SonarQube Analysis') {
steps {
withSonarQubeEnv('sq-cloud') {
container('node-browsers') {
script {
sh "npm run sonar-scanner -- " +
"-Dsonar.host.url=${env.SONAR_HOST_URL} " +
"-Dsonar.login=${env.SONAR_AUTH_TOKEN} " +
"-Dsonar.branch.name=${env.GIT_BRANCH}"
}
}
}
}
}
stage('SonarQube Quality Gate') {
options { timeout(time: 30, unit: 'MINUTES') }
steps {
waitForQualityGate(abortPipeline: true)
}
}
It feels like a race condition but I don’t understand how that could be possible after reading the docs. SonarQube Plugin Docs
Note that to prevent race conditions, when the step starts (or is restarted) a direct call is made to the server to check if the task is already completed.
Perhaps it’s related to the use of the Kubernetes plugin. I don’t really know how withSonarQubeEnv
and waitForQualityGate
interact so I couldn’t really say for sure.