Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48540

QualityGate Eror On Success Finished Sonar Analysis

    Details

    • Similar Issues:

      Description

      In Jenkins Pipeline, waitForQualityGate() function checks wrong sonarqube project id when sonar analysis (with maven) is already finished before qualitygate check.  But this error do no happen if sonar analysis (with maven ) is IN_PROGRESS status when quality gate check happens.

       [INFO] Analysis report generated in 2108ms, dir size=170 KB
      [INFO] Analysis reports compressed in 672ms, zip size=79 KB
      [INFO] Analysis report uploaded in 99ms
      [INFO] ANALYSIS SUCCESSFUL, you can browse http://sonar/dashboard/index/Otomat.otomatdb:master
      [INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
      [INFO] More about the report processing at AWBQJZXt3d5I4mceYXPp*" class="external-link" rel="nofollow">http://sonar/api/ce/task?id=AWBQJZXt3d5I4mceYXPp
      [INFO] Task total time: 1:28.576 s
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 01:34 min
      [INFO] Finished at: 2017-12-13T15:52:09+02:00
      [INFO] Final Memory: 33M/692M
      [INFO] ------------------------------------------------------------------------
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      Deleting 1 temporary files
      [Pipeline] // configFileProvider
      [Pipeline] }
      [Pipeline] // withSonarQubeEnv
      [Pipeline] timeout
      Timeout set to expire in 1 hr 0 min
      [Pipeline]

      { [Pipeline] waitForQualityGate Checking status of SonarQube task 'AWBQJZXt3d5I4mceYXPp' on server 'SonarQube_Prod' SonarQube task 'AWBQJZXt3d5I4mceYXPp' status is 'SUCCESS' [Pipeline] }

      [Pipeline] // timeout
      [Pipeline] }
      [Pipeline] // dir
      [Pipeline] mail
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      org.sonarqube.ws.client.HttpException: Error 403 on AWBQJZabCxYTfZ9a0SFz*" class="external-link" rel="nofollow">http://sonar/api/qualitygates/project_status?analysisId=AWBQJZabCxYTfZ9a0SFz
      at org.sonarqube.ws.client.BaseResponse.failIfNotSuccessful(BaseResponse.java:34)
      at hudson.plugins.sonar.client.HttpClient.getHttp(HttpClient.java:36)
      at hudson.plugins.sonar.client.WsClient.getQualityGateWithAnalysisId(WsClient.java:85)
      at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.checkTaskCompleted(WaitForQualityGa

       

       

      Below is the part of the script

       

      withSonarQubeEnv(env.SonarQube_Prod) {
      jdkPath = tool name: "JDK_18"
      mvn = tool name: genericLibrary.getGlobalMavenToolName(), type: 'com.cloudbees.jenkins.plugins.customtools.CustomTool'
      configFileProvider([configFile(fileId: genericLibrary.getMavenSettingsFileId(), variable: 'MAVEN_SETTINGS')]) {
      withEnv(["JAVA_HOME=$

      {jdkPath}

      "]) {
      if ( isUnix() == true ) {
      sh "${mvn} -s $MAVEN_SETTINGS sonar:sonar -Dsonar.java.binaries=$WORKSPACE -Dsonar.branch=${gitBranch} -Dsonar.projectKey=Otomat.otomatdb -Dsonar.projectVersion=${env.BUILD_NUMBER} "
      }
      else{
      bat "${mvn} -s $MAVEN_SETTINGS sonar:sonar -Dsonar.java.binaries=$WORKSPACE -Dsonar.branch=${gitBranch} -Dsonar.projectKey=Otomat.otomatdb -Dsonar.projectVersion=${env.BUILD_NUMBER} "
      }
      }
      }

      }
      def qualityGateResult = null
      timeout(time: 1, unit: 'HOURS') {
      qualityGateResult = waitForQualityGate()
      if (qualityGateResult.status != 'OK') {
      error "Pipeline aborted due to quality gate failure: ${qualityGateResult.status}"
      }
      }

        Attachments

          Activity

          Hide
          sateeshmn Sateesh M added a comment -

          What was the fix ? please provide the solution

          Show
          sateeshmn Sateesh M added a comment - What was the fix ? please provide the solution
          Hide
          aytuncbeken Aytunc BEKEN added a comment -

          Solution is to give Browse permission for the project to integrationuser in sonar. Interesting part is, this error occurs only if  analysis is finished before quality check. Browse permission for project is not necessary if analysis continues when quality check function runs. Before solution i thought this is a jenkins problem but it seems it is related to sonar. 

          Show
          aytuncbeken Aytunc BEKEN added a comment - Solution is to give Browse permission for the project to integrationuser in sonar. Interesting part is, this error occurs only if  analysis is finished before quality check. Browse permission for project is not necessary if analysis continues when quality check function runs. Before solution i thought this is a jenkins problem but it seems it is related to sonar. 

            People

            • Assignee:
              ivanash Ivana Sh
              Reporter:
              aytuncbeken Aytunc BEKEN
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: