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

Jenkins unable to operate SonarQube block

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: sonar-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.48
      Linux (CentOS)
      SonarQube 6.2
    • Similar Issues:

      Description

      (Based on: https://stackoverflow.com/questions/42909439/using-waitforqualitygate-in-a-jenkins-declarative-pipeline)

       It appears that stage like these are not possible?

      stage ("SonarQube analysis") {
           steps {
              script {
                 STAGE_NAME = "SonarQube analysis"
      
                 if (BRANCH_NAME == "develop") {
                    echo "In 'develop' branch, don't analyze."
                 }
                 else { // this is a PR build, run sonar analysis
                    withSonarQubeEnv("SonarGate") {
                       sh "../../../sonar-scanner-2.9.0.670/bin/sonar-scanner"   
                    }
                 }
              }
           }
        }
      
        stage ("SonarQube Gatekeeper") {
           steps {
              script {
                 STAGE_NAME = "SonarQube Gatekeeper"
      
                 if (BRANCH_NAME == "develop") {
                    echo "In 'develop' branch, skip."
                 }
                 else { // this is a PR build, fail on threshold spill
                    def qualitygate = waitForQualityGate()
                    if (qualitygate.status != "OK") {
                       error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
                    } 
                 }
              }
           }
        } 
      

      It fails with: "Please use the 'withSonarQubeEnv' wrapper to run your analysis.", but I am using it... Jenkins does not recognize it? full logs in the question link above.

        Attachments

          Activity

          Hide
          idanadar Idan Adar added a comment -

          This was a Sonar bug with remote slaves (see answer to the mentioned Stack Overflow question). Closing.

          Show
          idanadar Idan Adar added a comment - This was a Sonar bug with remote slaves (see answer to the mentioned Stack Overflow question). Closing.

            People

            Assignee:
            idanadar Idan Adar
            Reporter:
            idanadar Idan Adar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: