Cobertura 2.0.3 and Sonar not showing code coverage

4.4k Views Asked by At

I am trying to get Cobertura code coverage to work for a multi-package project. I had to update from 2.5.2 to 2.6 to work correctly with JDK 1.7 and now I am able to run and create cobertura code coverage reports. The files for the project are stored on a repo and are being built using Jenkins.

I have been able to get Cobertura to run correctly through Jenkins as well, and the reports can be seen through Jenkins; however I have hit a speed bump because I want them to show in Sonar.

My sonar is a out of the box build and is a much older version. From researching however it looks as though the most current cobertura-sonar plugin (1.6.1) does not work with JDK 1.7 so it would not function with Cobertura 2.0.3.

So I am wondering if it is possible to get Sonar to publish the metrics. Is there a way to just ignore the cobertura plugin all together and just have sonar grab the reports? or for sonar to talk to jenkins to get them?

I have seen information to get this to work, however I do not believe they are ever Cobertura 2.0.3; I would hate to update sonar and the cobertura plugin to the latest version just to see it not work; considering that updating sonar would most likely mess with other metrics I am passing it.

Sonar - 3.2

Cobertura-maven-plugin - 2.6 --> cobertura 2.0.3

https://jira.codehaus.org/browse/SONARPLUGINS-3170 link to the bug report of sonar not supporting cobertura maven 2.6 because of Java 7 syntax

1

There are 1 best solutions below

0
On BEST ANSWER

In order to import cobertura report into SonarQube you need the cobertura-sonar plugin. You can refer to this page http://docs.codehaus.org/display/SONAR/Plugin+version+matrix to know which version of the plugin to use with your version of the platform.

For version of cobertura plugin prior to 1.6 you would need to use sonar.dynamicAnalysis=reuseReports and set the coverage tool to cobertura : sonar.java.coveragePlugin=cobertura as stated in sonarqube coverage documentation

However I would really recommend you to upgrade to, at least, a LTS version of the platform.