Closed oboehm closed 6 years ago
I am facing same problem
/apps/jenkins/jenkins-2.19.3/workspace/ASR-BillingInvoice-Copy/target/site/clover/clover.xml ......
/apps/jenkins/jenkins-2.19.3/workspace/ASR-BillingInvoice-Copy/src/main/java/com/adobe/sesi/billinginvoice/config/BillingInvoiceConfig.java was not found.
Matched files in report : 0%
Please help
Modern SonarQube (6.5) does not support Clover reports? https://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Unit+Tests+for+Java+Project This page says that only Cobertura and JaCoCo reports are supported.
However https://docs.sonarqube.org/display/PLUG/Plugin+Version+Matrix says that Clover 3.1 (is this a very old version of Clover?) is supported by SonarQube up to 6.5.
I'm using clover (gradle builds) with SonarQube 7, and it seems to be working. I have enabled the Clover plugin on the Sonar server.
In gradle.properties:
systemProp.sonar.host.url=http://my-sonar.com
systemProp.sonar.host.login=<key created by sonar>
systemProp.sonar.clover.reportPath=build/reports/clover/clover.xml
In build.gradle:
apply plugin: 'com.bmuschko.clover'
apply plugin: 'org.sonarqube'
clover {
targetPercentage = '90%'
excludes = [
'**/ExcludedClass.java',
'**/excludedpackage/*.*',
]
// set property that will be read by sonar plugin to match coverage exclusions
project.ext.'sonar.coverage.exclusions' = excludes.join(',')
report {
html = true
xml = true
}
}
sonarqube {
properties {
// read coverage exclusions set by clover
property "sonar.coverage.exclusions", project.ext.'sonar.coverage.exclusions'
}
}
build.finalizedBy cloverGenerateReport
A couple of notes on the above:
sonarqube
block is only needed if you are excluding files or packages within the clover
block.clover
block, which is then being read by the sonarqube
block. Without this, the code coverage you see on the sonar server will not match what you see in the clover report.build.finalizedBy cloverGenerateReport
generates the report at the end of the gradle build
stage.With this configuration, when I run my build with ./gradlew clean build sonarqube
, I see the correct code coverage for the project on the sonar server.
This should be addressed by my pull request. Please let me know if you have any questions.
@dmitry-weirdo the page https://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Unit+Tests+for+Java+Project says that using sonarJava plugin, only jacoco and cobertura reports are supported. But you can use sonar-clover plugin and sonar-java plugin together.
@oboehm seems that the generated report is not in a good state. I'm able to get this type of issue when I use a relative path to configure clover and an absolute path to configure sonar and "vice versa".
This is an issue a hope to resolve soon
Thank your for the hint. But now we use JaCoCo and since version 0.8.0 of JaCoCo we are happy with it. I think the question is now answered and I will close the issue.
I tried Clover and the Sonar clover plugin, but there is no code coverage visible in Sonar. The clover.xml is generated and found by the plugin but I see the following warnings in the Jenkins log:
[INFO] Sensor Lines Sensor [INFO] Sensor Lines Sensor (done) | time=9ms [INFO] Sensor org.sonar.plugins.clover.CloverSensor [INFO] Parsing /home/jenkins/.jenkins/workspace/dok-printing_converter-sonar/target/site/clover/clover.xml [WARNING] Resource /home/jenkins/.jenkins/workspace/dok-printing_converter-sonar/src/main/java/de/drgueldener/dok/svd2pdf/controller/ConverterServiceController.java was not found. [WARNING] Resource /home/jenkins/.jenkins/workspace/dok-printing_converter-sonar/src/main/java/de/drgueldener/dok/svd2pdf/config/SwaggerConfig.java was not found. [WARNING] Resource /home/jenkins/.jenkins/workspace/dok-printing_converter-sonar/src/main/java/de/drgueldener/dok/svd2pdf/PrintingConverterApplication.java was not found. [WARNING] Resource /home/jenkins/.jenkins/workspace/dok-printing_converter-sonar/src/main/java/de/drgueldener/dok/svd2pdf/service/SvdConverterService.java was not found. [INFO] Matched files in report : 0%
The Java file exists. My question is: which version of SonarQube is supported by this plugin?