Answers: <p>It was related at the end to Sonar DB performance (after getting AWR reports):
  <a href="https://stackoverflow.com/questions/59982345/how-to-maintain-cleanup-of-the-sonar-table-project-measures">https://stackoverflow.com/questions/59982345/how-to-maintain-cleanup-of-the-sonar-table-project-measures</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2020-02-01T06:51:13.683Z
Answers: 2020-02-01T06:51:13.683Z
Answers: arielma
Body: <p>I have some pipelines in Jenkins, with the SonarQube stage (Version: 6.7.1, build 35068)
  In some builds it is aborted due to time out:</p>
  
  <pre><code>12:19:01 Sleeping for 3 min 0 sec
  [Pipeline] timeout
  12:22:10 Timeout set to expire in 25 min
  [Pipeline] waitForQualityGate
  12:22:10 Checking status of SonarQube task 'XXXXXXXXXX' on server 'Sonar'
  12:22:10 SonarQube task 'XXXXXXXXXX' status is 'PENDING'
  12:47:10 Cancelling nested steps due to timeout
  </code></pre>
  
  <p>and in some other builds it pass:</p>
  
  <pre><code>13:56:47 Sleeping for 3 min 0 sec
  [Pipeline] timeout
  13:59:47 Timeout set to expire in 25 min
  [Pipeline] {
  [Pipeline] waitForQualityGate
  13:59:47 Checking status of SonarQube task 'XXXXXXXXXX' on server 'Sonar'
  13:59:47 SonarQube task 'XXXXXXXXXXXX' status is 'SUCCESS'
  13:59:47 SonarQube task 'XXXXXXXXXXXX' completed. Quality gate is 'WARN'
  </code></pre>
  
  <p>Trigger command in bitbucket file:</p>
  
  <pre><code>    stage('Sonar Quality Gate') {
          sleep 180
          timeout(time: 25, unit: 'MINUTES') {
              def qg = waitForQualityGate()
                      if (!(qg.status == 'OK' || qg.status == 'WARN')) {
                          error "Pipeline aborted due to quality gate failure: ${qg.status}"
                      }
          }
      }
  </code></pre>
  
  <p>what might be the reason for it? how can I keep it stable? can it be network isssue?</p>
  
Comments: CC BY-SA 4.0
Comments: 2019-12-19T20:39:19.207Z
Comments: Can you post the command you are using to trigger the SonarScan?
Comments: Wesley Rolnick
Comments: CC BY-SA 4.0
Comments: 2019-12-19T20:49:46.777Z
Comments: added in the question
Comments: arielma
Comments: CC BY-SA 4.0
Comments: 2019-12-20T19:41:11.453Z
Comments: getting some general direction from here: https://community.sonarsource.com/t/sonar-quality-gate-behavior-in-jenkins-pipeline-is-unstable/18020/3
Comments: arielma
Comments: CC BY-SA 4.0
Comments: 2019-12-23T12:15:13.443Z
Comments: Could you post an answer?
Comments: 030
Tags: <jenkins-pipeline><jenkins-plugins><sonarqube>
Title: Sonar Quality Gate behavior in Jenkins pipeline is unstable
UserDisplayName: arielma
ThreadText: # Sonar Quality Gate behavior in Jenkins pipeline is unstable
  
  (Asked by: username_0 on 2019-12-19)
  
  I have some pipelines in Jenkins, with the SonarQube stage (Version: 6.7.1, build 35068)
  In some builds it is aborted due to time out:
  
  ```
  12:19:01 Sleeping for 3 min 0 sec
  [Pipeline] timeout
  12:22:10 Timeout set to expire in 25 min
  [Pipeline] waitForQualityGate
  12:22:10 Checking status of SonarQube task 'XXXXXXXXXX' on server 'Sonar'
  12:22:10 SonarQube task 'XXXXXXXXXX' status is 'PENDING'
  12:47:10 Cancelling nested steps due to timeout
  
  ```
  
  and in some other builds it pass:
  
  ```
  13:56:47 Sleeping for 3 min 0 sec
  [Pipeline] timeout
  13:59:47 Timeout set to expire in 25 min
  [Pipeline] {
  [Pipeline] waitForQualityGate
  13:59:47 Checking status of SonarQube task 'XXXXXXXXXX' on server 'Sonar'
  13:59:47 SonarQube task 'XXXXXXXXXXXX' status is 'SUCCESS'
  13:59:47 SonarQube task 'XXXXXXXXXXXX' completed. Quality gate is 'WARN'
  
  ```
  
  Trigger command in bitbucket file:
  
  ```
      stage('Sonar Quality Gate') {
          sleep 180
          timeout(time: 25, unit: 'MINUTES') {
              def qg = waitForQualityGate()
                      if (!(qg.status == 'OK' || qg.status == 'WARN')) {
                          error "Pipeline aborted due to quality gate failure: ${qg.status}"
                      }
          }
      }
  
  ```
  
  what might be the reason for it? how can I keep it stable? can it be network isssue?
  
  **Tags:** jenkins-pipeline, jenkins-plugins, sonarqube
  
  > **Comments:**
  > **username_1**: Can you post the command you are using to trigger the SonarScan?  
  > **username_0**: added in the question  
  > **username_0**: getting some general direction from here: https://community.sonarsource.com/t/sonar-quality-gate-behavior-in-jenkins-pipeline-is-unstable/18020/3  
  > **username_2**: Could you post an answer?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-02-01. Score: 0 | Accepted answer
  
  It was related at the end to Sonar DB performance (after getting AWR reports):
  <https://stackoverflow.com/questions/59982345/how-to-maintain-cleanup-of-the-sonar-table-project-measures>
  
  
  ---
  
  