SonarQube extension for Jenkins 2.17.2, incorrect links on the Jenkins job dashboard

Hi,

we noticed a bug in the current version 2.17.2 of the Sonarqube extension for Jenkins.
For Jenkins pipelines with multiple Sonarqube scans, the Jenkins job dashboard
shows one waves icon on the left bar and one status entry
<sonar.projectName>
server side processing
per project on the main dashboard.

But the problem is, the waves icon has no labeling with the <sonar.projectName> (only mouseover + link) and the entries beyond “Sonarqube Quality Gate” have all the same <sonar.projectName> whereas there should be different <sonar.projectName> entries.
It seems it’s always the first <sonar.projectName> that has been analyzed.

This means that you cannot see which Sonarqube projects have been analyzed without accessing all wave icons or opening their links - this is poor usability.

Gilbert

Hey @anon67236913 ,

Indeed there is an issue with those badges. I’ve created a ticket to deal with it: [SONARJNKNS-376] - Jira

Thanks for reporting this!

Hi,

thanks for looking into it.
But the Jira ticket adresses only one of the problems = the waves icons on the left don’t show the Sonarqube project key.

But we noticed, that the entries under the SonarQube Quality Gate beyond the stages, show always the same entry - it’s the projectkey linked to the first waves icon.

I am surprised that your screenshot in the Jira ticket shows different entries below the stages view, for us it showed always the same entry , means in your case it would be 2x test-maven, instead of test-maven and test-maven2.

Gilbert

@anon67236913

I’ve used the following configuration to reproduce, if you have example of your issue, I’m happy to have a look

stage('Analysis') {
            steps {
                sh "pwd"
                dir('/var/jenkins_home/workspace_test/java-module') {
                    sh "pwd"
                    echo 'before withSonarQubeEnv'
                    withSonarQubeEnv(installationName: 'sonarqube_local') {
                        sleep(5)
                        sh 'mvn clean verify sonar:sonar   -Dsonar.projectKey=test-maven   -Dsonar.projectName=test-maven'
                        echo('test point1')
                    }
                    withSonarQubeEnv(installationName: 'sonarqube_local') {
                        sleep(5)
                        sh 'mvn clean verify sonar:sonar   -Dsonar.projectKey=test-maven2   -Dsonar.projectName=test-maven2'
                        echo('test point2')
                    }
                    echo 'after withSonarQubeEnv'
                }
            }
        }

@jacek.poreda

Here is a reproducer, used the multimodule build from

Note =
we use multibranch pipeline and scripted syntax
we need to split a multimodule build in single Sonarqube projects for specific reasons

Jenkinsfile

node ('rhel') {
  stage('Checkout') {
    checkout scm
  }

  parentPom = readMavenPom file: 'pom.xml'
  modules = parentPom.getModules()
 
  for (module in modules) {
    dir(module) {
      stage("Analysis ${module}") {
        withSonarQubeEnv('SONARTEST') {
          withMaven(jdk: 'java-17-openjdk', maven: 'maven-3.9', globalMavenSettingsConfig: 'linux') {
            sh 'mvn clean verify sonar:sonar'
          }
        }
        timeout(time: 10, unit: 'MINUTES') {
        def qg = waitForQualityGate()
          if(qg.status != 'OK') {
            error "Pipeline aborted due to quality gate failure: ${qg.status}"
          }
        }
      }
    }
  }
}

and the result is

while the links of the wave icons on the left are correct.

If i use the same Jenkinsfile but without the waitForQualityGate() step, means

node ('rhel') {
  stage('Checkout') {
    checkout scm
  }

  parentPom = readMavenPom file: 'pom.xml'
  modules = parentPom.getModules()
 
  for (module in modules) {
    dir(module) {
      stage("Analysis ${module}") {
        withSonarQubeEnv('SONARTEST') {
          withMaven(jdk: 'java-17-openjdk', maven: 'maven-3.9', globalMavenSettingsConfig: 'linux') {
            sh 'mvn clean verify sonar:sonar'
          }
        }
        /*
        timeout(time: 10, unit: 'MINUTES') {
        def qg = waitForQualityGate()
          if(qg.status != 'OK') {
            error "Pipeline aborted due to quality gate failure: ${qg.status}"
          }
        }
       */
      }
    }
  }
}

the entries beyond Sonarqube Quality Gate are correct!

The problem is the waitForQualityGate() pipeline step of the Sonarqube Jenkins plugin.

@anon67236913

Thank you! That will indeed help investigate a problem, the link to the community is already there so we will have a look at this case as well