Quality Gate status is not reported back to Jenkins for the default branch

  • ALM used - GitHub
  • CI system used - Jenkins
  • Language of the repository - Java project with Maven

The process I followed for adding my project to Sonarcloud -

  1. Let it get discovered by the GitHub integration
  2. Uncheck “Automatic Analysis” from the Administration → Analysis Method page for the project on SonarCloud
  3. Modified the long-lived branch regex to “(develop|master)”
  4. Configure the SonarCloud under Jenkins → Manage Jenkins → SonarQube servers
  5. Configured my SonarScanner under Jenkins → Manage Jenkins → Tools → SonarQube scanner
  6. Run analysis from my scripted pipeline with below code
if ("true".equalsIgnoreCase("${run_test}") && "true".equalsIgnoreCase("${run_sonar_analysis}")) {
       def projectKeySC = "<proj-key>"
       def githubOrg = "<org-name>"                
       SonarQube_analysis("${projectKeySC}", "${githubOrg}")
       timeout(time: 1, unit: 'HOURS') {
       // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails
       / true = set pipeline to UNSTABLE, false = don't
              waitForQualityGate abortPipeline: true
def SonarQube_analysis(String projKey, String githubOrg) {
    def scannerHome = tool '<name of SonarScanner tool>'
    withSonarQubeEnv('SonarCloud') { 
        if (env.CHANGE_ID != null) {
            sh "mvn -B sonar:sonar \
                -Dsonar.projectKey=${projKey} \
                -Dsonar.pullrequest.provider=GitHub \
                -Dsonar.pullrequest.github.repository=${githubOrg}/${repo} \
                -Dsonar.pullrequest.key=${env.CHANGE_ID} \
                -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} \
        } else {
            if ("develop".equals(env.BRANCH_NAME)) {
                sh "mvn -B sonar:sonar \
                    -Dsonar.projectKey=${projKey} \
            } else {
                sh "mvn -B sonar:sonar \
            -        Dsonar.projectKey=${projKey} \
                    -Dsonar.branch.name=${env.BRANCH_NAME} \

Issue - My branch analysis succeeds and QG status is reported back to Jenkins. PR analysis also succeeds and QG status is reported back to Jenkins. But the main (“develop”) branch analysis succeeds but QG status is not reported back to Jenkins

Please help. I have been stuck with this issue since last two days


Welcome to the community!

Can you check your webhooks, server-side, to see if there were any errors for the develop analysis?

And BTW, the SonarCloud docs aren’t explicit about it, but I believe the pull request values should be picked up automatically from the environment.