1

我正在尝试运行声纳扫描仪并访问质量门结果,并且在尝试了论坛上建议的各种选项后有点卡住了。这是我第一次尝试发帖,所以如果我遗漏任何细节,请告诉我。我确实在 sonarqube 服务器 webhooks 控制台中看到了 json 有效负载,但它处于失败状态(红色叉号)。我们的服务器是一个共享的 CBJ 和 SonarQube 服务器,我在这两个服务器上的访问权限都是有限的。非常感谢任何帮助/指导。太感谢了。

=======================================

SonarQube 配置

项目名称 > 管理 > Webhook 名称:Webhook_Name URL:https://CloudBeesJenkins_Server_FQDN/dev-master/sonarqube-webhook/ 秘密:'webhook_secret_text'

=======================================

CBJ 配置

CredentialsID:'SonarQubeToken':值:范围:全局凭据(不受限制)

=======================================

Jenkins Job - 流水线脚本

/* 此阶段成功 */

stage('SonarQube Analysis') {
        def scannerHome = tool 'Sonar-Prod';
        withSonarQubeEnv('Sonar-Prod') {
        sh """${scannerHome}/bin/sonar-scanner -X \
            -Dsonar.projectKey=ProjKey \
            -Dsonar.sources=src \
            -Dsonar.host.url=https://sonarqube_server_fqdn \
            -Dsonar.login=sonar_project_secret_text"""
        }
      }

/* waitForQualityGate 失败 */

stage("Quality Gate Status Check") {
            timeout(time: 1, unit: 'HOURS')// Just in case something goes wrong, pipeline will be killed after a timeout
           // had previously tried using waitForQualityGate() and waitForQualityGate(webhookSecretId: 'webhook_secret_text' with same result  
           def qg = waitForQualityGate(webhookSecretId: 'webhook_secret_text', credentialsId: 'sonar_project_secret_text') // Reuse taskId previously collected by withSonarQubeEnv
              if (qg.status != 'OK') {
                 error "Pipeline aborted due to quality gate failure: ${qg.status}"
               }
         }

======================================

来自 Jenkins 服务器的日志 - 运行 Sonarscanner 和 qualitygate 的作业

SonarQube Scanner 4.2.0.1873
Java 1.8.0_242 Oracle Corporation (64-bit)
Linux 2.6.32-754.27.1.el6.x86_64 amd64
SonarQube server 7.9.1 - Community 7.9.1.27448
[CloudBees Jenkins Enterprise 2.204.3.7-rolling]


09:40:13.671 DEBUG: Upload report
09:40:13.931 DEBUG: POST 200 https://sonarqube_server_fqdn/api/ce/submit?projectKey=ProjKey | time=256ms
09:40:13.935 INFO: Analysis report uploaded in 264ms
09:40:13.938 INFO: ANALYSIS SUCCESSFUL, you can browse https://sonarqube_server_fqdn/dashboard?id=ProjKey
09:40:13.938 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
09:40:13.938 INFO: More about the report processing at https://sonarqube_server_fqdn/api/ce/task?id=AXDt34Wae-uSoUyAgrS-

[Pipeline] waitForQualityGate
Checking status of SonarQube task 'AXDt34Wae-uSoUyAgrS-' on server 'Sonar-Prod'

org.sonarqube.ws.client.HttpException: Error 401 on https://sonarqube_server_fqdn/api/ce/task?id=AXDt34Wae-uSoUyAgrS-
4

1 回答 1

1

这是一个防火墙问题。从 Jenkins 到 SonarQube 服务器的通信已打开,但不是相反。这个问题可以关闭。

于 2020-06-16T20:14:50.987 回答