Must-share information (formatted with Markdown):
which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
Sonarqube 8.5.1, sonar maven plugin version 126.96.36.1996
what are you trying to achieve
We are building a multi-module maven project. Because we need to test in different environments (linux/windows) we need to run the maven build with different profiles (general modules + modules specific to that platform) on different build slaves. We use jenkins Jenkinsfile/pipelines for this (but i think that is not important).
We use the report-aggregate goal of jacoco-maven-plugin to aggregate the coverage information of each environment using the corresponding set of active profiles.
We configure the property sonar.coverage.jacoco.xmlReportPaths to point to the aggregated jacoco.xml file.
The Problem is, I can add the goal sonar:sonar to the respective maven builds but this way I only get one or the other coverage in SonarQube.
What we need is the overall coverage of all modules aggregated. (Tests on different platform can lead to different execution paths in the very same module of course)
Perfect would be to be able to combine multiple sonar:sonar runs into one result on the SonarQube server. (by using a special token or ID)
- what have you tried so far to achieve this
I tried different setup’s where we try to “transport” the jacoco data using the stash/unstash function of the Jenkins pipeline from one machine to the other but in the end this hasn’t been successful because sometimes the class files to java files are missing (different build env) or different version of class files get mixed (e.g. compiled under linux vs. compiled under windows).
Any ideas on how to solve this problem are very welcome.
since there was no activity on my question i’ll try to make my problem more clear by using images.
Basically my question is, is there a way to combine multiple sonar “runs” of the same project in different “configuration” into one final sonarqube analysis?
That would look somethins like this:
Use Case is that different type of tests need to run on different nodes while generating test result and coverage which should be combined for a single sonarqube analysis. In this example it’s junit and ui test need to run on different nodes but are testing a common set of maven modules. (could also be different environments like windows and linux)
When that is not possible what else could be done?
In this example the sonar analysis is an additional step, but here the problem is, that test and coverage data is only available from the test run on the same node in the step before:
In this setup i tried to copy (jacoco) coverage information from Node2 to Node1 but then sonarqube analysis fail because of missing (and i think “not matching”) class information.
Would that essentially work? What Data needs to be transferred from Node2 to Node1?
Thanks for any hints or pointers on how to get that setup working.
First, your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:
8.5.1 → 8.9.3 → 9.2.1 (last step optional)
You may find the Upgrade Guide helpful.
Regarding your actual question, you cannot update an analysis with late-breaking results. You’re going to need to run all of your different tests and then aggregate them before analysis. Note that you may have problems with this if the paths don’t match from build agent to build agent. Generally, we council to run your tests on the same file system you run analysis on so all the paths in the coverage reports match the paths that SonarQube sees during analysis.
If this isn’t possible, you may need to just treat each module/testing unit as a separate project.
G Ann thank you for your answer.
Regarding your suggestion to run all tests “in line”: does that on the other hand mean that sonarqube analysis for scenarios like this
are not supported? In that example they run tests on windows and linux in parallel. And before the Deploy step in their example i would expect the SonarQube analysis run. That shoud not be possible?
It’s not clear to me what you’re asking. When I click through a see an image at the top of the page that shows the run branching and then rejoining. Analysis belongs after the paths reconverge & you would feed the test results from all the branches of the execution into it - with the filepath caveats I mentioned above.