Jenkins waitForQualityGate issues when MR/PR decoration is involved

Versions in use:

  • SonarQube version: Enterprise 8.2
  • Jenkins version: 2.222.1
  • Jenkins sonar plugin version: 2.11
  • Sonar scanner version:
  • GitLab version: 12.10.8
  • Java version: OpenJDK Runtime Environment (build 1.8.0_222-b10)


When using Jenkins sonar scanner plugin combined with GitLab merge request decoration, timings mean that the build process may hang indefinitely when waiting for analysis completion. In particular, this seems to stem from the fact that the webhook for analysis completion is sent first, but the associated background task is not marked as complete until the MR decoration has been performed. The issue is most prevalent with small projects

Steps to reproduce:

  1. Create a Jenkinsfile to analyse a small project (in our example, 20 typescript files), ensuring that the ‘waitForQualityGate’ step is used after the scanning
  2. Create the project in SonarQube and configure Merge Request analysis
  3. Create a merge request in GitLab and run the associated build (by whichever means is required)

Observed behaviour:

  1. The Jenkins build process runs as expected up-to and including the analysis stage
  2. The SonarQube webhook is received by the Jenkins instance slightly before the waitForQualityGate step is started (this is not in itself unusual)
  3. The waitForQualityGate step starts and immediately polls SonarQube to check on the task status. However, because the MR decoration has not yet completed, the API response is ‘In Progress’
  4. The waitForQualityGate step waits for receipt of a webhook, which never happens.


The Jenkinsfile has to be coded such that when processing Merge Requests, a 30s delay is added between the sonar analysis and the ‘waitForQualityGate’ stage.

Suggested remedies:

  • The Jenkins plugin should cache the webhook until it is consumed by the waitForQualityGate step
  • The Webhook / Analysis and Merge Request decoration should be split into separate background tasks
  • The background task timings should be altered such that the webhook is last thing done before task completion

Welcome :slight_smile:

there’s already a Jira ticket to adress this

You may vote for this ticket as registered user.


1 Like