简体   繁体   中英

multiple maven modules sonar code coverage is showing zero % on sonar qube

I'm using sonar version of 6.7.6 and maven 3.3.9 I'm having below configuration in my Jenkins its generating the jacoco reports and test cases reports as expected below paths.But I'm seeing 0% code coverage in sonarqube, can anyone please help me here?

sonar.language=java
sonar.java.coveragePlugin=jacoco
sonar.junit.reportPaths=ABC-1/target/surefire-reports, ABC-2/target/surefire-reports, ABC-3/target/surefire-reports, ABC-4/target/surefire-reports, ABC-5/target/surefire-reports, ABC-6/target/surefire-reports
sonar.jacoco.reportPaths=ABC-1/target/jacoco.exec, ABC-2/target/jacoco.exe, ABC-3/target/jacoco.exec, ABC-4/target/jacoco.exec, ABC-5/target/surefire-reports, ABC-6/target/jacoco.exec
sonar.projectKey=abc_Parent
sonar.projectName=abc_Parent
sonar.projectVersion=${POM_VERSION}
sonar.java.binaries=ABC-1/target/classes, ABC-2/target/classes, ABC-3/target/classes, ABC-4/target/classes, ABC-5/target/classes, ABC-6/target/classes
sonar.test.exclusions=**/src/test/**
sonar.sources=.

MavenGoal

-Dmaven.test.failure.ignore=true -U clean org.jacoco:jacoco-maven-plugin:1.1.1:prepare-agent test

ParentPOM

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>sonar-maven-plugin</artifactId>
                    <version>***</version>
                </plugin>
                <plugin>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>***</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

As you know, SonarQube does not do the analysis , just imports the results.

You really ought to upgrade to SQ LTS 8.9.x, which means going to 6.7.7 , then 7.9.6 , then to 8.9.x .

Your coverage issues is that you must jacoco:prepare-agent , then run tests ( -DskipTests=false ), then produce ajacoco:report , or since you are multi-module, jacoco:report-aggregate and finally, sonar:sonar

The sonar-jacoco plugin can then pick the results up from the sonar.coverage.jacoco.xmlReportPaths location(s).

If "'sonar.coverage.jacoco.xmlReportPaths" is not defined, default locations are:

"target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml"

SonarJava analyzer V 5.12. deprecated use JaCoCo's binary format ( .exec files) . Support for .exec format JaCoCo Coverage Reports was dropped in SonarQube 8.2

According to the release notes for the sonar-jacoco-plugin-1.1 , it now has " Support wildcard in sonar.coverage.jacoco.xmlReportPaths "

SonarQube explains why the numbers might not match expectations

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM