Set Build to Unstable status if Quality Gates fails

589 Views Asked by At

I need some help, i am trying to set the build status as "Unstable" if quality gate on sonarqube fail. Find below the configuration i've got so far:

Stage sonarQube Scan

I've found this also, but i am not sure how to integrate on my stage above:

step {                     
                qualitygate = waitForQualityGate()                     
                if (qualitygate.status != "OK") {                         
                    currentBuild.result = "UNSTABLE"                     
                }                 
            }  

Any suggestion? Thanks in advance for the support,

1

There are 1 best solutions below

0
On

Try this:

...
timeout(25) {
    def qualitygate = waitForQualityGate()
    if (qualitygate.status != "OK") {
        currentBuild.result = "UNSTABLE" 
    }
}

Inspired by Set the build unstable if sonar Quality Gate is failed