Delivery of jenkins-webhook sonar Response: 403

I’m install Jenkins and Sonarqube via docker and. I"m trying to scan sonar and check quality gate my project have been set.
Sonarqube analyze is success and quality gate is Passed.However stage quality gate is not success, this stage is pending and nonstop.

My Pipeline:

    stage('Sonarqube') {
      steps {
        script {
          def scannerHome = tool 'sona-scanner-4.8';
          def sonar_token="XXXXXXXX"
            withSonarQubeEnv('Sonarqube9.9.1') {
            sh "${tool("sona-scanner-4.8")}/bin/sonar-scanner \
            -Dsonar.projectKey=XXXXXXXX \
            -Dsonar.projectName=XXXXXX \
            -Dsonar.sources=. \
            -Dsonar.projectVersion=1.0 \
            -Dsonar.sourceEncoding=UTF-8 "
            
                  }
              }
            }
         }
        
    stage('Quality Gate ') {
      steps {
        waitForQualityGate abortPipeline: false, credentialsId: 'Sonar-token'
        timeout(time: 5, unit: 'MINUTES') {
          script {
            def qg = waitForQualityGate()
            if (qg.status != 'OK') {
              error "Pipeline aborted due to quality gate failure: ${qg.status}"
            }
          }
        }
      } 
    }

and my delivery of jenkins-webhook on sonar web:

{
  "serverUrl": "http://localhost:9000",
  "status": "SUCCESS",
  "analysedAt": "2023-06-08T03:59:55+0000",
  "revision": "85d9bc3f78595416d8cf42b6f4847c6686d594d3",
  "changedAt": "2023-06-08T04:01:03+0000",
  "project": {
    "key": "DEVOPS.DEMO.TEST",
    "name": "DEVOPS.DEMO.TEST",
    "url": "http://localhost:9000/dashboard?id=DEVOPS.DEMO.TEST"
  },
  "branch": {
    "name": "main",
    "type": "BRANCH",
    "isMain": true,
    "url": "http://localhost:9000/dashboard?id=DEVOPS.DEMO.TEST"
  },
  "qualityGate": {
    "name": "DEMO.DEVOPS.QUALITYGATE",
    "status": "OK",
    "conditions": [
      {
        "metric": "new_reliability_rating",
        "operator": "GREATER_THAN",
        "value": "1",
        "status": "OK",
        "errorThreshold": "1"
      },
      {
        "metric": "new_security_rating",
        "operator": "GREATER_THAN",
        "value": "1",
        "status": "OK",
        "errorThreshold": "1"
      },
      {
        "metric": "new_maintainability_rating",
        "operator": "GREATER_THAN",
        "value": "1",
        "status": "OK",
        "errorThreshold": "1"
      },
      {
        "metric": "new_coverage",
        "operator": "LESS_THAN",
        "status": "OK",
        "errorThreshold": "80"
      },
      {
        "metric": "new_duplicated_lines_density",
        "operator": "GREATER_THAN",
        "value": "0.0",
        "status": "OK",
        "errorThreshold": "1"
      },
      {
        "metric": "blocker_violations",
        "operator": "GREATER_THAN",
        "value": "0",
        "status": "OK",
        "errorThreshold": "0"
      },
      {
        "metric": "critical_violations",
        "operator": "GREATER_THAN",
        "value": "0",
        "status": "OK",
        "errorThreshold": "0"
      },
      {
        "metric": "major_violations",
        "operator": "GREATER_THAN",
        "value": "0",
        "status": "OK",
        "errorThreshold": "5"
      },
      {
        "metric": "minor_violations",
        "operator": "GREATER_THAN",
        "value": "0",
        "status": "OK",
        "errorThreshold": "5"
      },
      {
        "metric": "new_security_hotspots_reviewed",
        "operator": "LESS_THAN",
        "value": "100.0",
        "status": "OK",
        "errorThreshold": "100"
      }
    ]
  },
  "properties": {
    "sonar.analysis.detectedci": "Jenkins",
    "sonar.analysis.detectedscm": "git"
  }
}

Please let me know how to fix it.

Hi,

Your pipeline doesn’t quite look like the one in the docs. The reason the docs example uses withSonarQubeEnv in both the analysis and Quality Gate steps is that the environment holds not only the credentials, but also a taskId that gets tucked into the SonarQube env at the end of the analysis step that’s used in the Quality Gate step.

Can you update your pipeline to match the docs and try again?

 
Ann