jenkins waitForQualityGate()失败,状态为NONE

62o28rlo  于 2023-10-17  发布在  Jenkins
关注(0)|答案(2)|浏览(213)

我使用的是Jenkins 2.89,SonarQube Scanner for Jenkins 2.6.1和SonarQube 6.7,配置了Jenkins的webhook。
我正在启动声纳分析

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

我没有找到一个有效的解决方案,所以我想它对大多数人来说都是正确的。我对每个组件都使用最新版本,也许是回归?
问候

eqqqjvef

eqqqjvef1#

我遇到了一个类似的情况,waitForQualityGate()失败,状态为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服务器上看了一下,我注意到默认的质量门'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'
oxosxuxt

oxosxuxt2#

在分析后添加sleep 50命令,它对我有效

相关问题