Redmo
Redmo

Reputation: 33

Jenkins Sonar jacoco

My JUnit testcoverage is not propagated to sonar when built on jenkins. The "Unit test coverage" field on sonar stays empty, the "Unit test success" field shows the correct values though. I'm using jacoco for the testcoverage. On jenkins, the report of jacoco works well and shows the correct coverage in the generated html. I just can't get it to sonar.

With the jacoco plugin from jenkins, I invoke a standalone Sonar Analysis with the following parameters.

# required metadata
sonar.projectKey=ePortal:Ejb
sonar.projectName=ePortal
sonar.projectVersion=1.0

# path to source directories (required)
sonar.sources=ePortalEjb/ejbModule

# path to test source directories (optional)
sonar.tests=ePortalEjb/src/test
sonar.core.codeCoveragePlugin=jacoco
sonar.surefire.reportsPath=ePortalEjb/junit
sonar.forceAnalysis=true
sonar.jacoco.reportPath=ePortalEjb/build_test/jacoco/jacoco.exec
sonar.dynamicAnalysis=reuseReports
sonar.jacoco.antTargets=test

Paths and ant-tasks are correct. Maybe I am missing something obvious? Thanks in advance for any help.

Greetings Redmo

Upvotes: 1

Views: 4614

Answers (1)

As you're not triggering the Sonar analysis with Ant but with the Sonar Runner, could you please remove the 'sonar.jacoco.antTargets' property from your project configuration file?

Do you confirm that the JaCoCo report has been generated and dumped at ePortalEjb/build_test/jacoco/jacoco.exec prior to the Sonar analysis?

Which version of Sonar are you running?

Could you provide the log of the analysis in debug mode (-X)? Could you run the same analysis outside of Jenkins and confirm that you encounter the same issue?

Thank you

David RACODON | SonarSource

Upvotes: 2

Related Questions