Hello,
we have a problem about java sonar analisys using gradle. It doesn’t find coverage report.
Sonarqube version:
Developer EditionVersion 8.2 (build 32929)
Gradle sonarqube plugin:
id “org.sonarqube” version "2.6.2"
Java release:
java version "1.8.0_271"
Java™ SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot™ 64-Bit Server VM (build 25.271-b09, mixed mode)
Our gradle properties:
systemProp.sonar.host.url=http://sonar-sonarqube-01.kite.lab
systemProp.sonar.projectKey=mc-java-sonar-test
systemProp.sonar.projectName=mc-java-sonar-test
systemProp.sonar.language=java
systemProp.sonar.java.coveragePlugin=jacoco
systemProp.sonar.scm.provider=git
systemProp.sonar.sourceEncoding=UTF-8
systemProp.sonar.java.source=1.8
systemProp.sonar.java.binaries=build/libs
systemProp.sonar.java.coveragePlugin=jacoco
systemProp.sonar.coverage.jacoco.xmlReportPaths=build/reports/coverage.xml
http://sonar-sonarqube-01.kite.lab is an empty sonarqube instance, no project has been analized yet.
We analize executing:
./gradlew clean build jacocoTestReport sonarqube
This produces a coverage report at:
./java-test-project/build/reports/coverage.xml
Which was not find by analysis:
Cobertura report not found at /home/emontero/trabajo/smartM2M/pdihub/mc-java-sonar-test/java-test-project/target/site/cobertura/coverage.xml
I note that analysis does not seek at: systemProp.sonar.coverage.jacoco.xmlReportPaths=build/reports/coverage.xml, it goes to default sonarqube server defined path: Myproject->Project settings->Code coverage->Report path: target/site/cobertura/coverage.xml
Trying to solve it, i have saw at sonarqube a coverage property:
Key: sonar.cobertura.reportPath
If i use this at my gradle.properties file:
Instead using → systemProp.sonar.coverage.jacoco.xmlReportPaths=build/reports/coverage.xml
Use → systemProp.sonar.cobertura.reportPath=build/reports/coverage.xml
I’ve got a null pointer exception:
07:14:12.916 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
07:14:12.916 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
07:14:12.916 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
07:14:12.916 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':sonarqube'.
07:14:12.916 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.lang.NullPointerException (no error message)
07:14:12.916 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
07:14:12.916 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
07:14:12.916 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. Run with --scan to get full insights.
07:14:12.916 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
07:14:12.916 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
07:14:12.916 [WARN] [org.gradle.internal.featurelifecycle.LoggingDeprecatedFeatureHandler]
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5.1/userguide/command_line_interface.html#sec:command_line_warnings
07:14:12.916 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
07:14:12.916 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 4s
I think something is happen with that property because other analisys stuff like bugs, codesmells…are shown at sonarqube server.
I have upload a java test project to: GitHub - rt01145/java-test-project, i have upload all project, including build folders and coverage report in case can help you in any way
Also I have read: sonar.coverage.jacoco.xmlReportPaths not reporting coverage - #6 by dmeneses but dont understand what is “Moving the files to the java-style directory structure seemed to work and coverage was reported.”
I have tried to put coverage report at:
build/reports/jacoco/test/coverage.xml
and change path to:
systemProp.sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/coverage.xml
But i have the same problem:
Cobertura report not found at /home/emontero/trabajo/smartM2M/pdihub/mc-java-sonar-test/java-test-project/target/site/cobertura/coverage.xml
I think analylis does not take my gradle defined property because that “/target/” path is only defined at sonar server
Regards
Eloy