I am using SonarQube Version 6.7.3 (build 38370) and my coverage report is not working (always showing 0%). I verified that after running ./mvnw clean verify install sonar:sonar -Dsonar.host.url=... the jacoco.xml file is created under the default expected location for the sonar-maven-plugin. The report is correctly showing 66% code coverage.
I see that my SonarQube's helm chart was installed with
plugins:
install:
- "https://github.com/stevespringett/dependency-check-sonar-plugin/releases/download/1.1.1/sonar-dependency-check-plugin-1.1.1.jar"
which makes me think that I need to install something extra for jacoco to work. Also, in this page it is said that
This plugin (provided by default with SonarQube 7.4+) allows you to load the JaCoCo data from its XML format for all the languages for which you can generate a JaCoCo report.
and my version is 6.7.3.
Yes - import of JaCoCo XML report requires a SonarQube JaCoCo Plugin.
Page about plugin that you cite contains not only
provided by default with SonarQube 7.4+
but also
JaCoCo 1.0.2 – Jun 28, 2019 – SonarQube 6.7+ (Compatible with LTS)
meaning that plugin is compatible with SonarQube versions starting from 6.7 and pre-installed starting from version 7.4.
https://docs.sonarqube.org/6.7/InstallingaPlugin.html describes how to install plugins:
Related
I am using sonarqube-gradle-plugin v2.2 to generate reports using code coverage data from clover. On my local system, I can see the reports on the sonarqube version 6. But as soon as I run the same gradle task on the build system I start seeing bunch of errors. The build system has sonarqube 5.4. Hence I was wondering which versions are compatible together. Some more information:
grade version = 3.1
for generating clover reports, I am using this plugin: com.bmuschko:cradle-clover-plugin:2.0.1
Examples of errors:
358 files in clover report did not match any file in SonarQube Index ...
Use the new property "sonar.web.file.suffixes" instead of the deprecated "sonar.web.fileExtensions"
[13:37:01]Class not found: javax.annotation.Nullable
[13:37:02]Class not found: org.springframework.jdbc.datasource.init.DatabasePopulator
Never-mind, I was using ${project.name} instead of ${name} hence it was showing up with a different name.
I recently upgraded to SonarQube 5.3 and now test coverage using Cobertura is no longer published/analyzed.
It looks like JaCoCo is default code coverage no matter what we install or configure. Log shows that SonarQube is looking and not finding JaCoCo reports.
Is there still support for Cobertura with 5.3?
I tried to configure cobertura but sonar.java.coveragePlugin does not seem to do much anymore. You can specify what you like using this property but the JaCoCo will be used.
[INFO] JaCoCoSensor: JaCoCo report not found : E:\myproject\jacoco.exec
[INFO] JaCoCoItSensor: JaCoCo IT report not found: E:\myproject\jacoco-it.exec
Since SonarQube 4.2 the test report isn’t generated by SonarQube anymore (see SonarQube blog post for more information). So you have to do it by your own before you run the sonar analyze. For Maven builds, I wrote a sample how to integrate JaCoCo test reporting generation into a Maven build.
For Cobertura, you have to install the Cobertura Plugin for SonarQube. On that site it is explained how to generate the reports.
Most of the projects that I'm working with used Gradle 1.6 upto 2.3 with Java7 and I'm using Jacoco for code coverage.
Jenkins version is: 1.565.3 and 1.618 (I have two instances)
Jenkins's Jacoco Plugin version: 1.0.12
Gradle version: 2.3
Gradle's Jacoco Plugin version: 0.7.2.201409121644
Now in Gradle, there's a jacoco plugin (which provides jacocoTestReport task) and in Jenkins there's a Jacoco plugin which reads the exec files generated by running various tests and shows the reports on the Jenkins job's dashboard.
These reports are not showing up now if I'm using Java 8 with Gradle 2.0 upto 2.3 versions. Jenkins jobs builds and runs the analysis on Jacoco successfully but the reports is gone.
Have you seen this issue?
If you see this, it shows Coverage is gone and with the latest build all what is there is RED / no coverage.
Main dashboard:
Jacoco Plugin report (if you click on the above report on the job):
NOTE:
I have valid .exec files which shows valid code coverage if I use Gradle's jacocoTestReport task to generate the coverage in HTML format but the Jacoco plugin dashboard reports are not showing anything (just shows the headers only with no data/no coverage at all).
Reports generated by jacocoTestReport and Jacoco plugin in Jenkins generated valid output when I'm using Java7.
Report generated by Gradle's jacocoTestReport task using the same .exec files shows that jacoco* .exec files that I have are valid.
I figured out the cause why code coverage is not showing for Java 8 projects.
It's due to the incompatible version of Jenkins's Jacoco Plugin which works only with Java7 in your Jenkins instance. Try updating Jacoco plugin in Jenkins it to the latest version (1.0.15+).
Support to Java 8 was provided with version 1.0.15. Release notes of Jacoco plugin
Version 1.0.15 (Jun 11, 2014)
• Fix [JENKINS-20440] Inspector problem
• Fix [JENKINS-22716] - Update to JaCoCo 0.7.x to support Java 8
• Fix #40 - Project Dashboard chart having data cut off
Hence, jacoco plugin needs to be upgraded in your Jenkins.
Also, see Version info/Release info here: https://wiki.jenkins-ci.org/display/JENKINS/JaCoCo+Plugin
You'd notice there's a warning message (at this time) which might be resolved in upcoming versions (in few days).
Unfortunately JaCoCo 0.7.5 breaks compatibility to previous binary formats of the jacoco.exec files, the JaCoCo plugin is currently based on JaCoCo 0.7.4, thus you cannot use this plugin with projects which already use JaCoCo 0.7.5 or newer, please stick to 0.7.4 or lower for now until the plugin is updated
I upgraded my sonarqube from 4.1 to 4.4. as in the latest java plugin 2.4 you don't need to have a JaCoCo plugin. I have deleted the jacoco plugin, but now i can not see Tes coverage on sonar dashboard - it's blank. We use bamboo for CI tool and run sonar build from Bamboo. we run below maven command from bamboo build .
clean verify -Psonar sonar:sonar -U -fae -Dsonar.forceAnalysis=true
With latest versions of the SQ Java plugin, tests are no longer automatically executed. They must be executed prior to the SonarQube analysis and configured so that they produce reports that can be read by the SQ Java plugin.
Everything is explained on the Code Coverage by Unit Tests for Java Project documentation page.
I have installed Sonarqube 4.3.2 on Linux Redhat, JDK 1.7_51 and used following plugins:
Checkstyle [checkstyle] 2.1
Cobertura [cobertura] 1.6.2,Java [java] 2.3
PMD [pmd] 2.2
SCM Activity [scmactivity] 1.7.1
Scm Stats [scmstats] 0.3.1
Running mvn sonar on java projects reports all other metrics except code coverage. What am i missing?
Earlier ran into java squid error with cobertura plugin 1.6.1, once i upgraded to 1.6.2 went past the error but still code coverage is not being reported.
Sonar has removed support for code coverage. you need to do coverage analysis on your own or by some tool and import these reports into sonar.
Please refer this : http://docs.codehaus.org/display/SONAR/C%23+Plugin
This can be the case for cobertura as well. Please check.