• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • sonar-plugin
    • None
    • Jenkins 2.48
      Linux (CentOS)
      SonarQube 6.2

      (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.

          [JENKINS-42954] Jenkins unable to operate SonarQube block

          Idan Adar created issue -
          Idan Adar made changes -
          Assignee Original: Sonar Team [ sonarteam ] New: Idan Adar [ idanadar ]

          Idan Adar added a comment -

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

          Idan Adar added a comment - This was a Sonar bug with remote slaves (see answer to the mentioned Stack Overflow question). Closing.
          Idan Adar made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          Idan Adar made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]
          Idan Adar made changes -
          Description Original: (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.
          New: (Based on: [https://stackoverflow.com/questions/42909439/using-waitforqualitygate-in-a-jenkins-declarative-pipeline)]

           It appears that stage like these are not possible?


          {code:java}
          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}"
                        }
                     }
                  }
               }
            }
          {code}


          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.

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

              Created:
              Updated:
              Resolved: