configuring sonar to consume multiple jacoc.exec files

432 views
Skip to first unread message

vered.co...@gmail.com

unread,
Jun 6, 2018, 11:09:59 AM6/6/18
to SonarQube
Hello everyone!

I'm trying to enforce and monitor code coverage in our repositories. 
I added a new change in our multi maven module repo which generates upon build jacoco.exec files per module and inside site>jacoco I can see index.html report. 
My target is to see aggregated report of this html reports somehow in sonar.
We have a jenkins job that after each merge, runs a build on our repository and update our sonar but I could not succeed to update multiple jacoco files...only one.

From the console I can see that jacoco files were successfully generated:
[JaCoCo plugin] Collecting JaCoCo coverage data...
14:39:04 [JaCoCo plugin] **/javatools/**/target/**.exec;**/javatools/**/target/classes/com/sap/xs;**/javatools/**/src/main/java; locations are configured
14:39:05 [JaCoCo plugin] Number of found exec files for pattern **/javatools/**/target/**.exec: 11

Then it runs sonar goal and I configured sonar.jacoco.reportPaths in a way which I thought should MERGE/AGGREGATE the jacoco files given to it...

First I configured it explicitly with a comma separated list:
sonar.jacoco.reportPaths=$WORKSPACE/git/javatools/maven-module1/target/jacoco.exec,
$WORKSPACE/git/javatools/maven-module2/target/jacoco/target/jacoco.exec,
$WORKSPACE/git/javatools/maven-module3/target/jacoco.exec,
$WORKSPACE/git/javatools/maven-module4/target/jacoco.exec,
$WORKSPACE/git/javatools/maven-module5/java-maven-env/target/jacoco.exec,
$WORKSPACE/git/javatools/maven-module6/target/jacoco.exec,
$WORKSPACE/git/javatools/maven-module7/target/jacoco.exec,
$WORKSPACE/git/javatools/maven-module8/target/jacoco.exec,
$WORKSPACE/git/javatools/maven-module9/target/jacoco.exec,
$WORKSPACE/git/javatools/maven-module10/target/jacoco.exec


It starts scanning one module but tries to take coverage report from a different module
------------- Scan Module1
..
..
..
Analysing /usr/sap/jenkins/work/workspace/javatools-nexusdeploy-master/git/javatools/module2/target/jacoco.exec
15:33:32 [INFO] No information about coverage per test.

(It scans module1 but tries to analyze jacoco.exec from module2...and also it doesn't find any information per test..)





2. . With the following reportPaths configuration:
sonar.jacoco.reportPaths=$WORKSPACE/git/javatools/**/target/jacoco.exec
In this case it didn't find jacoco.exec files at all...

e.g. -taken from full log:
[INFO] ------------- Scan Module1
..
..
..
[INFO] JaCoCo report not found: '/usr/sap/jenkins/work/workspace/javatools-nexusdeploy-master/git/javatools/**/target/jacoco.exec'

3. Then I read that if I want to use existing jacoco files that were created already by the build I should configure:
sonar.dynamic=reuseReports
This also didn't seem to work even though I DO have already jacoco.exe files that I see in the workspace for each maven module.

If I changed it to be sonar.jacoco.reportPaths=$WORKSPACE/git/javatools/maven-module1/target/jacoco.exec I see in our sonar coverage percentage only for maven-module1 of course. I did this only for testing too see if one single path works...BUT I did not see the report html as I got by jacoco. e.g. I excluded some java file, I saw it was excluded from the report index.html but I still saw it in sonar...

So basically I have 2 questions:
1. How I can make sonar consume jacoco results from multiple maven modules?
2. Why the report I see in sonar is not identical to the one generated by jacoco?

Thanks a lot in advance for any help!!
Vered
Reply all
Reply to author
Forward
0 new messages