Compatible versions of Gradle, Sonar, clover plugin? - gradle

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.

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 Maven plugin is failing because of a newer maven assembler plugin, how can I get the new plugin to pass properties correctly?

Had to update our maven assembler version to 1.1.8 from 1.1.6. It's the only change that happened and now Sonar Maven Plugin is throwing this exception:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar
(default) on project ReconCoverage: java.util.ArrayList cannot be cast to java.lang.String ->
Plugins:
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.7</version>
<groupId>com.CORPNAME.raptor.build</groupId>
<artifactId>assembler-maven-plugin</artifactId>
<version>1.1.8</version>
I have been looking into this for about a week, upgrading to this assembler version is required. No other teams are experiencing this issue from the upgrade because they are using Sonar through jenkins. I'm using the maven plugin because our project has many modules, and it structures the coverage results to match it.
I have looked through sonar's code and it seems to be happening in sonar.batch.bootstrap.userproperties. I'm guessing this is happening when the sonar properties are being passed in, items like: sonar.language, sonar.java.coveragePlugin, sonar.host.url, etc. etc.
Example of Coverage Properties:
<sonar.language>java</sonar.language>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.host.url>http://corp.sonar.url/</sonar.host.url>
<sonar.jdbc.url>jdbc:oracle:thin:#sonardb.corp.com:0000:sonardb</sonar.jdbc.url>
<sonar.jdbc.username>username</sonar.jdbc.username>
<sonar.jdbc.password>password</sonar.jdbc.password>
<sonar.jdbc.driver>oracle.jdbc.driver.OracelDriver</sonar.jdbc.driver>
According to sonar's code, it normally takes properties through a Map. And it throws this exception when one of those strings is an array list. Is there anyway to configure my properties so that the new maven assembler will pass these values correctly?
We have implemented a workaround in version 3.1.1 to circumvent buggy plugins injecting non string properties:
https://jira.sonarsource.com/browse/MSONAR-145
To use it just update you pom.xml to use:
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.1.1</version>
I finally found a workaround for this problem. I decided to not go the route of running Java 7 and then 8 to build the coverage report(check previous answers and comments). I'm sure that would work, but since none of our dev or CI machines had Java 8 environments set up, I tried a different route.
I was initially building the sonar report at the end of a mvn clean install through a module CoverageModule(which as the last module to build). The 1.1.8 java assembler version was throwing a fit when it built the project, and then ran the analysis.
I kept the module so that during a normal build, it would still run my ant task plugin to merge all of our module's Jacoco reports. I removed the sonar-maven-plugin from that module's pom and put it in the Project's aggregator module(parent of all modules). After running a full mvn clean install, I can run a mvn sonar:sonar and there appears to be no conflict with the new assembler version, and the old sonar version I was using.

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

Unable to get sonar-fortify plugin configured with Jenkins and SonarQube

I have scoured the forums and cannot seem to quite understand the config for the fortify plug-in with Sonar.
I understand it simply builds a widget based on data from a previously generated .fpr file.
My setup:
Maven 3 project
Jenkins 1.606
SonarQube 5.0.1
Sonar-Fortify plug-in 2.0
Prerequisites:
.fpr file is in Jenkins workspace
Sonar is added to pom.xml
sonar-fortify-plug-in v2.0 added to pom.xml - (wasn’t sure this was needed or not)
Sonar server configured in Jenkins
sonar fortify plug-in v2.0 added to Sonar – (only see a dropdown to ‘enableReportLink’ under ‘Configure widgets’
should there be more config somewhere?
Questions:
Where should this property be set? Jenkins Sonar config, Sonar, pom file?
sonar-runner -Dsonar.fortify.reportPath=/path/to/project.fpr
Is that path to the .fpr file where it is within the Jenkins workspace?
The setup instructions on Github seem short and I feel I am missing something specific in my understanding.
Any help or direction to additional documentation is great appreciated.
First of all as documented version 2.0 can not be used anymore. Version 2.1 is going to be released soon. Vote for release will be started this week. Meanwhile you can:
download 2.1-SNAPSHOT version and copy it in extensions/plugins of your SonarQube server installation
restart server. The Fortify rules should be available in the page "Rules".
execute Fortify command "sourceanalyzer", independently from SonarQube. It generates a report file suffixed by .fpr.
execute a standard SonarQube analysis of your project by adding the property sonar.fortify.reportPath, for example:
mvn sonar:sonar -Dsonar.fortify.reportPath=/path/to/project.fpr
sonar-runner -Dsonar.fortify.reportPath=/path/to/project.fpr
If everything works, then you can automate these steps in Jenkins.

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