Jenkins jacoco plugin - Dashboard Reports are gone with Java8 - gradle

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

Related

Reporting coverage to sonarqube configured with cobertura from gradle

My sonarqube server version 8.3.1 has the cobertura plugin enabled for showing cobertura coverage reports. Now I want to report jacoco XML-coverage data (generated with gradle jacoco plugin) and its not working. Are there any known issues between cobertura and jacoco? Or should both mechanisms work on one sonarqube?
Just for someone running in this problem. The problem was that the plugin for importing jacoco xml files has been removed. If you use sonarqube its normally included. So if you can't see the coverage report check that the jacoco plugin has been installed.

Does SonarQube need extra config/plugins to understand jacoco reports

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:

After upgrade to SonarQube 5.3 Cobertura test coverage is missing

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.

SonarQube 4.4 upgrade can not show test coverage on dashboard

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.

Hudson build failing with NoClassDefFoundError when generating Cobertura coverage report

I'm having a problem generating a Cobertura report with Hudson and Maven, and I'm hoping that someone here may have a solution.
I can see that cobertura artifacts are generated when hudson builds my project. But when I configure my hudson project to publish the Cobertura coverage report, I see that the build fails with the following error:
Publishing Cobertura coverage report ...
Publishing Cobertura coverage results ...
FATAL: org/jfree/chart/axis/CategoryAxis
java.lang.NoClassDefFoundError: org/jfree/chart/axis/CategoryAxis
at hudson.plugins.cobertura.CoberturaXmlHandler.startDocument(...)
The build output shows that the Java version is 1.6.0_38
If I configure my project so that Cobertura coverage report is not generated, then the build succeeds.
The following plugins are installed on hudson:
Findbugs (version 4.41-h-2)
Checkstyle (version 3.28-h-1)
Cobertura (version 1-6-h-1)
Static Analysis Collector (version 1.28-h-1)
Static Analysis Utilities (version 1.42-h-1)
Maven 3 Build (version 3.0.0)
The following maven command is used:
clean install findbugs:findbugs checkstyle:checkstyle cobertura:cobertura
Any suggestions on how to fix this problem?
You need to install the JFreeChart plugin as well, it's needed for generating charts in cobertura (that's why the class not found exception while running cobertura) but it has been removed from main hudson distribution:
(JFreeChart ...) Moved to an external plugin. Available from Alpha release. Any
external plugins using JFreechart will need to add a dependency on
this external plugin to maintain compatibility. For future charting
needs BIRT Charts is now bundled as a core plugin
EDIT: there a bug in a transitive dependency as seen here.
Install cobertura-plugin version 1.6-h-3. mvn

Resources