"sonar.coverage.jacoco.xmlReportPaths" cannot find jacoco test reports

Template for a good new topic, formatted with Markdown:

  • ALM used Bitbucket Cloud
  • CI system used Circle CI
  • Scanner command used when applicable ./sonar-scanner
  • Languages of the repository java

I use an sonarcloud orb in my multiproject in Circleci and have an issue with jacoco reports.

Project structure:

HOMEDIR=/home/circleci/repo

~/module1/build/reports/jacoco/test/jacocoTestReport.xml
~/module2/build/reports/jacoco/test/jacocoTestReport.xml
~/module3/build/reports/jacoco/test/jacocoTestReport.xml
~/module4/build/reports/jacoco/test/jacocoTestReport.xml

sonar-project.propterties:

...
sonar.coverage.jacoco.xmlReportPaths=*/build/reports/jacoco/test/jacocoTestReport.xml

Sonar cli cannot find jacoco reports:

INFO: Sensor JaCoCo XML Report Importer [jacoco]
WARN: Report doesn't exist: '/home/circleci/repo/*/build/reports/jacoco/test/jacocoTestReport.xml'

I tried also with absolute path, but got same error:

sonar.coverage.jacoco.xmlReportPaths=/home/circleci/repo/*/build/reports/jacoco/test/jacocoTestReport.xml

I’m sure the path is correct. It seems the cli cannot recognize “". It only works when I use a path without "” i.e.:

sonar.coverage.jacoco.xmlReportPaths=module1/build/reports/jacoco/test/jacocoTestReport.xml

Is it a bug?

I guess file searches is not supported? However dynamically searching for those XML files is pretty simple; add build sonar.coverage.jacoco.xmlReportPaths parameter like so:

mvn sonar:sonar -Dsonar.projectKey=xyz -Dsonar.coverage.jacoco.xmlReportPaths=$(find "$(pwd)" -path '*jacoco.xml' | sed 's/.*/&/' | tr '\n' ',')

for Maven, or correspondingly for Gradle.

1 Like

I would like to use sonarqube cli, not maven/gradle plugin.
According to the documentation it should be possible to use “*”

  • any number of characters|
    ** any number of directories|

https://sonarcloud.io/documentation/analysis/coverage/

Well technically, the documentation says

Some properties support the following wildcards in paths. The remarks for properties that support wildcards will mention that fact. If the remarks do not say wildcards are supported, then they are not.

So some, i.e. not all.

2 Likes

Edit: This post is outdated, wildcards are now supported.

Hello

Indeed, @skjolber is correct, wildcards are (currently) not supported for sonar.coverage.jacoco.xmlReportPaths as stated in the documentation you linked.

For the record, I just wanted to say that there is a ticket (JACOCO-15) to add support for wildcards in progress, you can expect them to be supported in the near future!

Best,
Quentin

4 Likes

Hi,
I have a similar issue, the sonar analysis cannot find the file.

This is the mvn output

[WARNING] No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths='./core/target/site/jacoco/jacoco.xml,core/target/site/jacoco/jacoco.xml

But if I run

ls -la ./core/target/site/jacoco/jacoco.xml

This is the output

-rw-r--r-- 1 root root 1408650 Nov  4 16:09 ./core/target/site/jacoco/jacoco.xml

the file is there.

I configure the path in SonarCould Project and not in the mvn command.
What I did wrong?

Thanks