No coverage for kotlin / maven project

Hi,

I have a kotlin project on github built by jenkins on ubuntu linux, it does not send coverage info.

project repo: https://github.com/kerubistan/kerub

jenkins config: clean org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar -Dsonar.projectKey=kerubistan_kerub -Dsonar.organization=kerubistan -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=XXXXXXXX

What could be wrong?

Hello Laszlo,

Kotlin code coverage is imported from reports created by JaCoCo plugin. So, in order to import it in :sonarcloud: you need to make sure the report is correctly generated in XML format.

For this to work, you need to remove the <forkMode>never</forkMode> configuration for maven-failsafe-plugin and maven-surefire-plugin. These options are not compatible with JaCoCo, as mentioned in the documentation. You’ll also need to run the JaCoCo report goal, in order to create the coverage report in XML format.

Once this is done, you need to add the sonar.coverage.jacoco.xmlReportPaths property when running the analysis, in order to tell the analyzer to read the coverage report file.

So, once you fix the configuration in your pom.xml, you should be able to run the analysis and import the coverage with a command simlar to this:

mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report sonar:sonar [other sonar properties] -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml

Best,

-Chris

It worked, thank you!

clean org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report sonar:sonar -Dsonar.projectKey=kerubistan_kerub -Dsonar.organization=kerubistan -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=XXXXXX -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml

The old one was not producing the jacoco.xml, only the jacoco.exec