3

This is a SpringBoot project based on gradle build tool and I am using AzureDevOps task for SonarQube Analysis.

Here are the properties I added in task:

sonar.java.binaries=build\classes
sonar.jacoco.reportPaths=build\jacoco\test.exec
sonar.language=java
sonar.tests=src\test\java
sonar.verbose=false
sonar.test.inclusions=**\test\**

It was working fine few days back and today suddenly it started failing with the error that 0 % code coverage.

When I compared the logs from successful and failure build I found this message in failed build.

INFO: Sensor JaCoCoSensor [java]

INFO: Both 'sonar.jacoco.reportPaths' and 'sonar.coverage.jacoco.xmlReportPaths' were set. 'sonar.jacoco.reportPaths' is deprecated therefore, only 'sonar.coverage.jacoco.xmlReportPaths' will be taken into account.

But I haven't configured anything specific to xmlReportPaths so not sure why it started failing.

gradle version- 5.4.1
SonarQube Scanner version- 3.3.0.1492
SonarQube server version- 7.3.0

Any help is appreciated.

Avhi
  • 806
  • 2
  • 15
  • 29
  • "suddenly it started failing" something should have happened. May someone has upgraded a plugin or changed the build pipeline? – Jeroen Heier Jul 24 '19 at 16:30
  • No change in build pipeline. I have already verified that, and checked the SonarQube server version history also and no upgrade recently. last time used this pipeline on Jul 11and it worked fine and today it's simply failing. – Avhi Jul 24 '19 at 17:57
  • What's the result if you use sonar.coverage.jacoco.xmlReportPaths instead? – starian chen-MSFT Jul 25 '19 at 12:55
  • Tried to use xmlReportPaths and it resolved the warning message but still the same result. no code coverage at all. `sonar.java.binaries=build\classes sonar.language=java sonar.tests=src\test\java sonar.verbose=false sonar.test.inclusions=**\test\** sonar.coverage.jacoco.xmlReportPaths=build\reports\jacoco\test\jacocoTestReport.xml` – Avhi Jul 25 '19 at 13:22

2 Answers2

2

After struggling for few days and searching internet I finally found the mistake I did with my gradle task. I had enabled html and xml both reports which was caused the mention issue.

set the xml.enabled to false and it started working like before.

jacocoTestReport{
    additionalSourceDirs.from = files(sourceSets.main.allJava.srcDirs)
    reports {
        html.enabled true
        xml.enabled false
        csv.enabled false
        html.destination file("build/reports/jacoco/html")
    }
    executionData.from = files('build/jacoco/test.exec')    
}

But still I am not sure how it worked first time, because as I said earlier I didn't make any change in code or pipeline.

I saw that regarding the same message Sonarqube is working on a story as well.

Avhi
  • 806
  • 2
  • 15
  • 29
0

As stated in the docs sonarqube does not run tests, it simply imports report generated by other tools to display them along the other analysis.

So my guess is that you have not configured your CI chain to generate test reports to be shown in sonarqube.