Sonarqube quality gate stuck on pending when inside jenkins pipeline node Sonarqube quality gate stuck on pending when inside jenkins pipeline node jenkins jenkins

Sonarqube quality gate stuck on pending when inside jenkins pipeline node


waitForQualityGate performs an HTTP call to the SonarQube server.

Make sure your build node has HTTP access to your SonarQube instance (the Jenkins master having access to it does not imply build nodes also have it).

Regardless, as I said in a comment, using a waiting step inside a node is not a good idea in general.


I was also facing the same issue and I fixed it by adding sleep before waitForQualityGate stage

sleep 10stage("Quality Gate") {        timeout(time: 1, unit: 'HOURS') {             def qg = waitForQualityGate()             if (qg.status != 'OK') {                error "Pipeline aborted due to quality gate failure: ${qg.status}"            }        }    }


This could be a better way to retry.

def retryForTimeoutExceeded(count = 3, Closure closure) {    for (int i = 1; i <= count; i++) {        try {            closure()            break        } catch (FlowInterruptedException error) {            int retriesLeft = count - i            def hasTimeoutExceeded = error.causes[0].getClass().toString() == 'class org.jenkinsci.plugins.workflow.steps.TimeoutStepExecution$ExceededTimeout'            println "Timeout Exceeded for clousre.\nRetries left: $retriesLeft"            if (retriesLeft == 0 || !hasTimeoutExceeded) {                throw error            }        }    }}stage("Quality Gate") {        retryForTimeoutExceeded {            timeout(time: 5, unit: 'MINUTES') {                // Just in case something goes wrong, pipeline will be killed after a timeout                def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv                if (qg.status != 'OK') {                    error "Pipeline aborted due to sonar quality gate failure: ${qg.status}"                }            }        }    }

Timeout can be configured accordingly