We use SonarQube and BitBucket extensively in our org. In a previous position in the same org, I’d constructed a well-working build process, where pull requests created in BitBucket would automatically spawn a build including a SonarQube scan of the branch, and it would report back the results and integrate coverage and issues into the pull request view. We didn’t use quality gates then.
I’m now on a new team, where quite a few things are different. When the build process was set up, they didn’t implement builds of pull requests. That’s part of what I’m trying to accomplish now. On the SonarQube side, they implemented the branch plugin and quality gates. They initially used the BuildBreaker plugin.
I’m attempting to convert to the webhook strategy. I followed instructions described at https://blog.sonarsource.com/breaking-the-sonarqube-analysis-with-jenkins-pipelines .
The block of code in my Jenkins pipeline script now looks something like this:
withSonarQubeEnv("SonarQube") {
sh 'mvn ' \
+ ' -Dsonar.host.url=' + props['sonar.host.url'] \
...
+ ' -s $MAVEN_SETTINGS sonar:sonar'
}
timeout(time: 1, unit: 'HOURS') { // Just in case something goes wrong, pipeline will be killed after a timeout
def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
My console output looks something like this:
[INFO] org.sonar.plugins.stash.StashIssueReportingPostJob@63fc39c7 not enabled, skipping
[INFO] Task total time: 1:16.734 s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
waitForQualityGate
Checking status of SonarQube task 'AWQAkwgAuZdogdUABtHN' on server 'SonarQube'
SonarQube task 'AWQAkwgAuZdogdUABtHN' status is 'PENDING'
After the last line here is displayed, the job hangs essentially forever. The last time I tried it, I killed the job after waiting 30 minutes.
I also note that the BitBucket pull request still has the old scan information (I can tell because the previous one that completed failed the quality gate, because it was using the BuildBreaker plugin, which causes weird bugs). I don’t know whether that message about the “StashIssueReportingPostJob” not being enabled is the cause of this.
So what might I be doing wrong?