Jenkins quality gate plugin checking the wrong scan

Hi,

You should try to do the scan inside the method dir() for both scans :

stage("SonarQube-batch"){
  when {
    expression { env.BRANCH_NAME.startsWith("PR-") }
  }
  agent {
    node {
      label 'docker_node'
    }
  }
  steps{
    dir('project-batch') {
      withSonarQubeEnv(credentialsId: '...', installationName:'Sonar'){
        sh "mvn clean compile sonar:sonar"
      }
    }
}

stage("Quality Gate-batch") {
  when {
    expression { env.BRANCH_NAME.startsWith("PR-") }
  }
  steps {
    dir('project-batch') {
      timeout(time: 10, unit: 'MINUTES') {
        waitForQualityGate(webhookSecretId: 'Sonar-Secret' , abortPipeline: true)
      }
    }
  }
}

That’s how I solved it. It appears that the waitForQualityGate method is missreading the .scannerwork as there are multiples .scannerwork, it always picks the first one.
I guess that only putting the waitForQualityGate inside the dir method should work.

2 Likes