Code coverage is not being reported - Sonarqube 4.3.2 - installation

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.

Related

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:

Sonar 5 returns no code coverage data using the groovy plugin and using cobertura for code coverage

Sonar 5 returns no code coverage data using the groovy plugin and using cobertura for code coverage. Maven also fails to return code coverage.
Configure a test instance with SonarQube 5.4 and the flowing plugins:
Build Breaker 1.1
Findbugs 3.3
Git 1.2
Groovy 1.3.1
Java 3.9
JavaScript 2.11
LDAP 1.5.1
PHP 2.8
Python 1.5
SVN 1.3
Web Analyze HTML 2.4
PMD 2.5
The old instance with Version 4.3.2 works? Does the cobertura plugin need to be installed, since it has been deprecated, or can the Java plug-in provide the correct support?
Indeed the import of Cobertura reports is no more supported out of the box. This requires to install the following dedicated community SonarQube Cobertura plugin : https://github.com/SonarQubeCommunity/sonar-cobertura/releases

SonarRunner Failing in Java 8

I have a java project with build system as Gradle. Recently we migrated to Java 8. After this migration sonarRunner task started failing with the following error :
05:10:51.823 INFO - Execute Findbugs 2.0.3...
05:10:56.502 INFO - Findbugs output report: /pathtoproject/build/sonar/findbugs-result.xml
The following errors occurred during analysis:
Unable to get XClass for java/util/function/BiConsumer
java.lang.ArrayIndexOutOfBoundsException: 1792
I started googling it and found out Findbugs 2.0.3 does not support I need to upgrade it and it was recommended that I should use Sonar server 5.x.x (my current sonar server is 5.4.x). I have some constraints yet I want my sonarRunner to be successful. Here are my constraints :
I can not upgrade the sonar server version (not in my hand)
Can not downgrade Java version.
I tried to search how to just upgrade the findbugs version in SonarRunner plugin that also I could not find. Please help me.

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.

Jenkins jacoco plugin - Dashboard Reports are gone with Java8

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

Resources