No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths on Jenkins

I have integrated SonarQube & Jacoco plugin in our project, Issue is
When I try to run it on localhost:9000 it is working fine and giving the code coverage and picking the sonar.coverage.jacoco.xmlReportPaths from the specified location, but when we deploy it on Jenkins then code coverage not working we are getting a message in the Jenkins console like below:

No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths=‘app/build/reports/jacocoTestReport/jacocoTestReport.xml’. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml

Hello @Girish_Bhat ,

Welcome to the SonarSource community, :wave: we hope you’ll enjoy it.

Could you send the full Jenkins log. We can’t troubleshoot with your very limited extract
If the log is long, please send as attachment, not inline.

Olivier

I hope this would help…
17:28:29 11:58:29.669 INFO: Sensor JaCoCo XML Report Importer [jacoco]

17:28:29 11:58:29.675 WARN: No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths=‘app/build/reports/jacoco/test/jacocoTestReport.xml’. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml

17:28:29 11:58:29.675 INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer

17:28:29 11:58:29.676 INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=7ms

17:28:29 11:58:29.677 INFO: ------------- Run sensors on project

17:28:29 11:58:29.679 DEBUG: Sensors : Zero Coverage Sensor → Java CPD Block Indexer

17:28:29 11:58:29.679 INFO: Sensor Zero Coverage Sensor

17:28:29 11:58:29.769 INFO: Sensor Zero Coverage Sensor (done) | time=90ms

17:28:29 11:58:29.769 INFO: Sensor Java CPD Block Indexer

Sorry as we have many ORG-related data in log…we can’t share entire log file.

Hello @Girish_Bhat,

Sorry but what you shared is not sufficient. You may redact what you don’t want to disclose but I need to see more.
Related to the log: **17:28:29** 11:58:29.675 WARN: No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths=‘app/build/reports/jacoco/test/jacocoTestReport.xml’. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
We should verify if and where is generated the Jacoco report (I should not be in app/build/reports/jacoco/test/jacocoTestReport.xml) and that’s why coverage is not imported.

Hi @OlivierK

Today I downloaded the Jenkins artifacts just to make sure that reports folder present or not, and I found that it’s not. below is the dir structure…

And the task I am running:
As I mentioned earlier same task works on localhost

task jacocoTestReport(type: JacocoReport, dependsOn: [‘testProdReleaseUnitTest’]) {

reports {
    xml.enabled = true
    html.enabled = true
}

def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', 'android/**/*.*']
def debugTree = fileTree(dir: "${buildDir}/intermediates/javac/prodRelease/classes", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/java"

getSourceDirectories().setFrom(files([mainSrc]))
getClassDirectories().setFrom(files([debugTree]))
getExecutionData().setFrom(fileTree(dir: "$buildDir", includes: ["jacoco/testProdReleaseUnitTest.exec"]))

}

When I ran locally for localhost:9000, dir Structure which generated just by running
./gradlew clean jacocoTestReport sonarqube

SonarQube screen shot on localhost:

Hello,

So if the report files are missing in your pipeline, it’s normal that SonarQube does not report any coverage.
Sorry but my community support is limited to helping on SonarQube problem. In that case it seems to be a pipeline problem and I cannot help on this. I am not even an expert in that domain. You should seek help from Gradle experts to understand why the Jacoco XML report is not generated. You may also read this community guide if that can be of any help.

Olivier

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