waitForQualityGate()失败,状态为NONE

问题描述 投票:5回答:1

我正在使用Jenkins 2.89,SonarsQube Scanner for Jenkins 2.6.1和SonarQube 6.7配置了一个webhook到Jenkins。

我正在触发声纳分析:

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"
        }
    }
}

然后在下一阶段收集状态:

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}"
                    }
                }
            }
        }
    }

登录控制台显示:

[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] }

查看日志记录级别,我看到SonarQube webhook POST具有正确的负载:

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":{}}

我没有找到一个有效的解决方案,所以我认为它适用于大多数人。我正在为每个组件使用最新版本,也许是回归?

问候

jenkins sonarqube
1个回答
0
投票

我遇到了类似的情况,其中waitForQualityGate()失败,Status NONE。

看着控制台输出

[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'

质量门是'无'???我不确定是什么导致这个因为之前的测试运行返回质量门是'确定'。

看一下SonarQube服务器,我注意到默认的Quality Gate'SonarQube Way'没有设置为默认值。在我的情况下,我只使用这一个质量门。将此重置为默认值解决了我的问题。

[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'
© www.soinside.com 2019 - 2024. All rights reserved.