簡體   English   中英

org.sonarqube.ws.client.HttpException: 錯誤 401

[英]org.sonarqube.ws.client.HttpException: Error 401

我正在嘗試運行聲納掃描儀並訪問質量門結果,並且在嘗試了論壇上建議的各種選項后有點卡住了。 這是我第一次嘗試發帖,所以如果我遺漏了任何細節,請告訴我。 我確實在 sonarqube 服務器 webhooks 控制台中看到了 json 有效負載,但它處於失敗狀態(紅色十字標記)。 我們的是共享的 CBJ 和 SonarQube 服務器,我對這兩個服務器的訪問權限都有限。 任何幫助/指導都非常感謝。 非常感謝。

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

SonarQube 配置

Project_Name > 管理 > Webhooks 名稱:Webhook_Name URL: https://CloudBeesJenkins_Server_FQDN/dev-master/sonarqube-webhook/秘密:'webhook_secret_text'

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

CBJ 配置

CredentialsID:'SonarQubeToken':值:范圍:全局憑證(不受限制)

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

Jenkins 工作 - 流水線腳本

/* 此階段成功 */

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-

這是一個防火牆問題。 從 Jenkins 到 SonarQube 服務器的通信已打開,但不是相反。 這個問題可以關閉。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM