My application is java (spring boot) maven project.I am using Bamboo pipeline for CI/CD
I am using these properties and i am able to generate code coverage in sonar(omitted maven-jacoc0-plugin config for brevity)
But i read the document that jacoco.exec is depracted ,so i want to avoid using jacoco.exec
<properties>
<!-- Sonar -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.language>java</sonar.language>
</properties>
-- snipper of jacoco plugin tag
<configuration>
<destFile>${sonar.jacoco.reportPath}</destFile>
</configuration>
To avoid jacoco.exec ,i configured my pom.xml as below but i started getting 0 coverage in sonarqube but the below configuration works fine in local (my laptop) .In local i am able to see report coverage generated correctly
- sonar.coverage.jacoco.xmlReportPaths: ${basedir}/target/jacoco_report/jacoco.xml
- jacoco.path: ${basedir}/target/jacoco_report
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<destFile>${sonar.jacoco.reportPath}</destFile>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<!-- Ensures that the code coverage report for unit tests is created
after unit tests have been run. -->
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>${sonar.jacoco.reportPath}</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>${jacoco.path}</outputDirectory>
</configuration>
</execution>
In the surefire plugin configuration, we have this:
<argLine>${surefireArgLine}</argLine>