5

I'm using Jenkins 2.89, SonarQube Scanner for Jenkins 2.6.1 and SonarQube 6.7 configured with a webhook to Jenkins.

I'm triggering Sonar analysis with:

stage("SonarQube Analysis") {
script {
    workspace = resolveWorkspacePath()
    withEnv(["JAVA_HOME=${ tool 'java-8'}","PATH+MAVEN=${tool 'Maven 3.2.2'}/bin:${env.JAVA_HOME}/bin"]) {
        withSonarQubeEnv('Sonar Solem') {
            sh "mvn -f ${workspace}/pom.xml org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar -Dsonar.host.url=http://sonar.mycompany.cl"
        }
    }
}

and then gathering status at the next stage with:

stage("SonarQube Quality Gate") {
        steps {
            script {
                timeout(time: 1, unit: 'HOURS') {
                    def qg = waitForQualityGate()
                    if (qg.status != 'OK') {
                        echo "Status: ${qg.status}"
                        error "Pipeline aborted due to quality gate failure: ${qg.status}"
                    }
                }
            }
        }
    }

The log in console shows:

[Pipeline] script
[Pipeline] {
[Pipeline] timeout
Timeout set to expire in 1 hr 0 min
[Pipeline] {
[Pipeline] waitForQualityGate
Checking status of SonarQube task 'AV-nIGNjEMS3I3uac4Dq' on server 'Sonar MyCompany'
SonarQube task 'AV-nIGNjEMS3I3uac4Dq' status is 'IN_PROGRESS'
[Pipeline] echo
Status: NONE
[Pipeline] error
[Pipeline] }

Looking at logging level, I see the SonarQube webhook POST with a correct payload:

Received POST from 10.0.0.236
Nov 10, 2017 3:27:06 PM FINE org.sonarsource.scanner.jenkins.pipeline.SonarQubeWebHook
Full details of the POST was {"serverUrl":"http://sonar.mycompany.cl","taskId":"AV-nLx-zEMS3I3uac4Ds","status":"SUCCESS","analysedAt":"2017-11-10T15:25:50-0300","changedAt":"2017-11-10T15:25:50-0300","project":{"key":"com.mycompany:mycomponent","name":"My Company Component","url":"http://sonar.mycompany.cl/dashboard?id=com.mycompany%3Amycomponent"},"branch":{"name":"master","type":"LONG","isMain":true,"url":"http://sonar.mycompany.cl/dashboard?id=com.mycompany%3Amycomponent"},"properties":{}}

I didn't find a working solution to this, so I suppose it works correctly for the most of people. I'm using the latest version for every component, maybe a regression?

Regards

PRF
  • 821
  • 1
  • 9
  • 16
  • 1
    Possible duplicate of [Sonarqube quality gate not sending webhook to jenkins](https://stackoverflow.com/questions/45693418/sonarqube-quality-gate-not-sending-webhook-to-jenkins) – Simon Schrottner Nov 11 '17 at 14:19
  • As mentioned in above link, adding 'sleep 10' between stage('SonarQube analysis') AND stage("Quality Gate") helped us. – Seshagiri Nov 13 '17 at 08:22
  • 1
    Not a duplicate because the webhook is posting correctly to Jenkins. Anyway, I tried the 10 seconds sleep and the issue still happens. – PRF Nov 13 '17 at 14:51

2 Answers2

0

I came across a similar situation where waitForQualityGate() fails with Status NONE.

Looking at the console output

[Pipeline] waitForQualityGate
Checking status of SonarQube task 'AWWpiDY2hX3zDQY-CMoe' on server 'Sonar1'
SonarQube task 'AWWpiDY2hX3zDQY-CMoe' status is 'SUCCESS'
SonarQube task 'AWWpiDY2hX3zDQY-CMoe' completed. Quality gate is 'NONE'

Quality gate is 'NONE' ??? I wasnt sure what was causing this as previous test runs returned Quality gate is 'OK'.

Having a look on SonarQube server I notice that the default Quality Gate 'SonarQube Way' was NOT set as default. In my situation I was only working with this one Quality Gate. Resetting this to default resolved my issue.

[Pipeline] waitForQualityGate
Checking status of SonarQube task 'AWWpnnRThX3zDQY-CMpM' on server 'Sonar1'
SonarQube task 'AWWpnnRThX3zDQY-CMpM' status is 'PENDING'
SonarQube task 'AWWpnnRThX3zDQY-CMpM' status is 'SUCCESS'
SonarQube task 'AWWpnnRThX3zDQY-CMpM' completed. Quality gate is 'OK'
moglimcgrath
  • 357
  • 3
  • 5
0

after adding sleep 50 command after analysis it worked for me