Using waitForQualityGate in a Jenkins declarative pipeline

后端 未结 3 928
天命终不由人
天命终不由人 2021-02-06 01:08

The following SonarQube (6.3) analysis stage in a declarative pipeline in Jenkins 2.50 is failing with this error in the console log: http://pastebin.com/t2ja23vC. More specific

3条回答
  •  别跟我提以往
    2021-02-06 01:44

    This was discovered to be a bug in the SonarQube scanner for Jenkins, when using a Jenkins slave for jobs (if the job is run on the master, it'd work). You can read more here: https://jira.sonarsource.com/browse/SONARJNKNS-282

    I have tested this using a test build of v2.61 of the scanner plug-in and found it working. The solution is to upgrade to v2.61 when released.

    This stage will then work:

    stage ("SonarQube analysis") {
       steps {
          withSonarQubeEnv('SonarQube') {
             sh "../../../sonar-scanner-2.9.0.670/bin/sonar-scanner"   
          }
    
          def qualitygate = waitForQualityGate()
          if (qualitygate.status != "OK") {
             error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
          }
       }
    }
    

提交回复
热议问题