简体   繁体   English

org.sonarqube.ws.client.HttpException: 错误 401

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

I am trying to run sonar-scanner and access quality gate results and am kind of stuck after trying various options suggested on forums.我正在尝试运行声纳扫描仪并访问质量门结果,并且在尝试了论坛上建议的各种选项后有点卡住了。 This is my first time trying to post, so please let me know if I am missing any details.这是我第一次尝试发帖,所以如果我遗漏了任何细节,请告诉我。 I do see the json payload in sonarqube server webhooks console but it is in failed status (red cross-mark).我确实在 sonarqube 服务器 webhooks 控制台中看到了 json 有效负载,但它处于失败状态(红色十字标记)。 Ours is a shared CBJ and SonarQube server with limited access for me on both of those.我们的是共享的 CBJ 和 SonarQube 服务器,我对这两个服务器的访问权限都有限。 Any help/guidance is really appreciated.任何帮助/指导都非常感谢。 Thank you so much.非常感谢。

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

SonarQube Configuration SonarQube 配置

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

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

CBJ Configuration CBJ 配置

CredentialsID: 'SonarQubeToken': Value: Scope: Global credentials (unrestricted) CredentialsID:'SonarQubeToken':值:范围:全局凭证(不受限制)

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

Jenkins Job - Pipeline Script Jenkins 工作 - 流水线脚本

/* this stage succeeds */ /* 此阶段成功 */

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

/* fails at waitForQualityGate */ /* 在 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}"
               }
         }

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

Logs from Jenkins Server - Job Running Sonarscanner and qualitygate来自 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-

It was a firewall issue.这是一个防火墙问题。 Communication from Jenkins to SonarQube server was opened but not the other way round.从 Jenkins 到 SonarQube 服务器的通信已打开,但不是相反。 This issue can be closed.这个问题可以关闭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM