0 coverage in sonarqube when not using jacoco.exec

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>

sonarqube version 6.7.1

Hello @sonaruser2021

It seems that you are using a version of SonarQube that is not supported anymore, this could explain the lack of answer to your problem.

You should definitely update to a newer version. In addition, this could solve your problem, because I don’t think 6.7.1 was supporting sonar.coverage.jacoco.xmlReportPaths as it is described today in the documentation.

Best,
Quentin

Thanks for the reply.I am using sonar qube provided by my company .I cant update it …I will raise the request though

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