简体   繁体   中英

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). Ours is a shared CBJ and SonarQube server with limited access for me on both of those. Any help/guidance is really appreciated. Thank you so much.

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

SonarQube Configuration

Project_Name > Administration > Webhooks Name: Webhook_Name URL: https://CloudBeesJenkins_Server_FQDN/dev-master/sonarqube-webhook/ Secret: 'webhook_secret_text'

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

CBJ Configuration

CredentialsID: 'SonarQubeToken': Value: Scope: Global credentials (unrestricted)

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

Jenkins Job - Pipeline Script

/* 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 */

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

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. This issue can be closed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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