Jenkins Pipeline that analyzes multiple projects shows the first project over and over

SonarQube Community Build v25.5.0.107428

I have a Jenkins pipeline that does SonarQube analysis on 14 projects. After the pipeline runs, in Jenkins if you click on the pipeline there is a section titled “SonarQube Quality Gate”. For each project it should show:

<project name> PASSED/FAILED
server-side processing: Success

You can then click on the project name and it will take you to the SonarQube dashboard for that project.

The problem I am having is, whichever project is analyzed first, that name is repeated over and over for all the projects that are analyzed.

So for example, let’s assume we are analyzing “project1”, “project2” and “project3”. The Jenkins pipeline shows…

project1 Passed
server-side-processing: Success
project1 Passed
server-side-processing: Success
project1 Passed
server-side-processing: Success

Instead of:
project1 Passed
server-side-processing: Success
project2 Passed
server-side-processing: Success
project3 Passed
server-side-processing: Success

I’m using a declarative script for the pipeline. Each project looks like this (just focusing on the Maven projects)

		stage("SonarQube analysis - project1") {
			steps {
                dir("project1") {
                    withSonarQubeEnv(credentialsId: "xxxxxxxxx", installationName: "SonarQube for MyProject") { 
                        bat "mvn sonar:sonar"
                    }
				}
		    }
        }
		stage("SonarQube Quality Gate - project1") {
            steps {
                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
                }
            }
        }

Note that all project analysis are sent to the SonarQube server under the correct project key / project name. So I’m confident that the maven scanner correctly getting the project key / project name from the artifact in the pom.xml.

Any help would be appreciated!

Hi,

Can you share why you’ve got one pipeline processing 14 different projects? It just wasn’t designed to handle this.

 
Ann

Hi G Ann !

I work for one of the largest logistics companies in the world. This is their ERP package which is large and complex.

But let me simplify the problem. Let’s say my application was much simpler. Let’s say we had a project for the web deployables (HTML, JavaScript, CSS…) called MyWebProject. Then we also have a project for the back-end web services (Java) deployable called MyServiceProject. I build both of these in the same pipeline. I’m also analyzing them using the declarative pipeline shown below. I would have the same issue. Jenkins would show:

MyWebProject Passed
server-side-processing: Success
MyWebProject Passed
server-side-processing: Success

Instead of:
MyWebProject Passed
server-side-processing: Success
MyServiceProject Passed
server-side-processing: Success

		stage("SonarQube analysis - MyWebProject") {
			steps {
                dir("MyWebProject") {
                    withSonarQubeEnv(credentialsId: "xxxxxxxxx", installationName: "SonarQube for MyWebProject") { 
                        bat "mvn sonar:sonar"
                    }
				}
		    }
        }
		stage("SonarQube Quality Gate - MyWebProject") {
            steps {
                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
                }
            }
        }
		stage("SonarQube analysis - MyServiceProject") {
			steps {
                dir("MyServiceProject") {
                    withSonarQubeEnv(credentialsId: "xxxxxxxxx", installationName: "SonarQube for MyWebProject") { 
                        bat "mvn sonar:sonar"
                    }
				}
		    }
        }
		stage("SonarQube Quality Gate - MyServiceProject") {
            steps {
                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
                }
            }
        }

I know this is somewhat of a cosmetic issue. However I’m evaluating SonarQube for the company. I will be demoing it for various groups. I’m sure I’ll have people asking me why it’s behaving this way. I just want to be absolutely sure it’s not something I’ve done wrong.

Thanks!
Todd

Hi Todd,

Yes, but why tho? :sweat_smile:

Why not have one pipeline per checkout?

Nope.

 
Ann

That’s our workflow. Those projects are dependent on each other. Our pipelines deploy to various environments automatically. We wouldn’t want to deploy say the MyWebProject if the build of MyServiceProject fails. I’m sure there are other ways to do what we are doing, but again I’m evaluating the product for various groups. I cannot dictate to other groups how they manage their CI/CD processes. But thank you for confirming it isn’t an issue with my setup or configuration, I appreciate it.

Hi,

Thanks for the explanation.

Our approach to projects that deploy together is different: Applications.

The idea is to - as you do - have a project per repo and then aggregate projects that depend on each other or deploy together into a single, synthetic project. So in this case, we would say to make the deployment dependent on the Application Quality Gate.

And/or, rather than relying on the display on the Jenkins homepage, you could use the pipeline failure feature which you can use to fail your pipeline if your Quality Gate fails. You have to be careful how you set it up, but let’s say project #4 fails its QG. This would then fail the whole pipeline, rather than spending the cycles to analyze all the rest of the projects.

 
HTH,
Ann

Thanks Ann! I’m currently evaluating the Community addition which I don’t believe supports project aggregation (portfolios and applications). However I am waiting for the sales team to contact me as we do want to discuss licensing either the Developer or Enterprise versions for those and other features (branches, etc).

I guess if we had to summarize the solution it comes down to either one of these two things…

  1. It’s a bug that should be documented

or

  1. SonarQube does not support analyzing multiple projects in a single pipeline in Jenkins. At least not without this issue occurring.

In either case, from my perspective, it’s nothing I’ve directly caused in the setup. So that was my main concern. Thank you again for all the help.

Todd

Hi Todd,

I would summarize it slightly differently.

  • There’s an incidental UI bug in the Jenkins extension.
  • SonarQube offers support for analyzing multiple projects in a single pipeline in Jenkins through pipeline failure and serial configuration of: analysis - QG check - analysis - QG check - &etc.

 
:smiley:
Ann

Hi Ann. I can’t explain why, but a created a new pipeline with the same Jenkins pipeline script and now it’s working as expected. All 14 projects are being displayed correctly on the Jenkins pipeline page with the correct status after the build completes. I guess we just chalk it up to Jenkins being Jenkins. Thanks again for the help.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.