Jenkins : waitForQualityGate function returns PENDING status and stays like that, even if the status is SUCCESS after 1 second (1)

6 693 megtekintés
Ugrás az első olvasatlan üzenetre

Frederic Gibelin

olvasatlan,
2017. aug. 29. 9:19:412017. 08. 29.
– SonarQube
Hello,

I have an issue with the waitForQualityGate function in the Jenkinsfile.
  • SonarQube 6.5
  • SonarQube Scanner 3.0.3.778
  • Jenkins 2.76
  • All plugins at latest version

The Jenkinsfile data :
        stage('Analyze static code') {
            steps {
                echo 'Analyzing code...'
                withMaven(maven: 'Maven', mavenSettingsConfig: '<settings id>') {
                    withSonarQubeEnv('SonarQube') {
                        sh 'mvn sonar:sonar'
                    }
                }
            }
        }
        stage('Check Quality Gate') {
            steps {
                echo 'Checking quality gate...'
                script {
                    timeout(time: 1, unit: 'HOURS') {
                        def qg = waitForQualityGate()
                        if (qg.status != 'OK') {
                            error "Pipeline aborted due to quality gate failure: ${qg.status}"
                        }
                    }
                }
            }
        }

The result in the console is :
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http://<sonarqube-server>/api/ce/task?id=AV4t4NQb-rNsRjK6-Iov
[INFO] Task total time: 4.397 s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

[...........]

Checking status of SonarQube task 'AV4t4NQb-rNsRjK6-Iov' on server 'SonarQube' SonarQube task 'AV4t4NQb-rNsRjK6-Iov' status is 'PENDING' Cancelling nested steps due to timeout
Timeout has been exceeded
Finished: ABORTED

And when we click on the link above, we have a JSON payload with that :
{"task":{"organization":"default-organization","id":"AV4t4NQb-rNsRjK6-Iov","type":"REPORT","componentId":"AV4ZfNAW-rNsRjK6-IoT","componentKey":"<componentKey>","componentName":"<project>","componentQualifier":"TRK","analysisId":"AV4t4NhxuRG-2GpIV2PS","status":"SUCCESS","submittedAt":"2017-08-29T12:04:22+0000","startedAt":"2017-08-29T12:04:23+0000","executedAt":"2017-08-29T12:04:24+0000","executionTimeMs":448,"logs":false,"hasScannerContext":true}}

  • The webhook is well configured in the SonarQube instance, with the trailing '/'
  • Both Jenkins & SonarQube instances communicate well, ports are open
  • There is no "INFO: Received POST from ...." in the Jenkins logs (appears only if we do a testing curl command from the SonarQube instance server)
An answer here on StackOverflow says adding a delay between the analysis and the gate check fixes the problem.
I did that, and indeed that works, even with 1 second, but it's only a workaround and not the best solution I guess.

Thanks in advance for your feedbacks,

Fred

luis...@beeva.com

olvasatlan,
2017. nov. 6. 10:20:312017. 11. 06.
– SonarQube
Hi Frederic,

I have the same problem with Jenkins 2.73, and with a delay also works but its not the best solution. Maybe is a bug :S


Thanks,
Luis

haiy...@gmail.com

olvasatlan,
2018. jan. 23. 17:29:562018. 01. 23.
– SonarQube
I also have the same issue.

Julien HENRY

olvasatlan,
2018. jan. 24. 3:02:212018. 01. 24.
– SonarQube
Hi all,

Adding a delay is NOT the solution. When the waitForQualityGate step starts, it does a first synchronous call to SonarQube to check task status. According to your logs, the status was "PENDING", which is expected. Then the step will be on hold, waiting for the SonarQube webhook to "awake" it.

Adding a delay will will only increase the chance that the first synchronous call will return the completed task. But this is not 100% safe, and defeat the purpose of this asynchronous architecture.

So this is what you should investigate: look at your webhook configuration in SonarQube and ensure you have added the Jenkins server URL (<your Jenkins instance>/sonarqube-webhook/) to the list.
Then look at global Jenkins logs to see if any issue was faced during processing of the webhook.

Hope that help,

Julien

bfl...@keyholesoftware.com

olvasatlan,
2018. jan. 25. 14:47:322018. 01. 25.
– SonarQube
Hi all, 

We encountered this issue and found in the SonarQube logs (at DEBUG level, as I recall) that the TLS connection was not properly established).   If the SonarQube webhook contains a Jenkins link with https:, then this might be the problem.

We added the certificate and the issue was resolved.

Brad

G. Ann Campbell

olvasatlan,
2018. jan. 29. 16:07:442018. 01. 29.
– SonarQube
Hi Brad,

Thanks for sharing!


Ann

balaji....@gmail.com

olvasatlan,
2018. máj. 7. 6:40:172018. 05. 07.
– SonarQube
Hi Brad,

Could you please let us know, where can we get the certificate and how can we added that certificate in Jenkins?

Pl. share the certificate to resolve the issue.

Thanks for your support.

Regards,
Balaji
Válasz mindenkinek
Válasz a szerzőnek
Továbbítás
0 új üzenet