3
votes

we had SonarQube v3.4 and recently upgraded to SonarQube V4.3. Also we use Jenkins to build and trigger sonar analysis on Maven projects and Cobertura as the code coverage tool.

In the version 3.4, Sonar used to trigger (with Jenkins) the cobertura execution and collect the data, but when we upgraded to Sonar 4.3, there was no option in Sonar to select the default code-coverage tool, the Jenkins Sonar execution no longer triggers cobertura and unit test execution. Now it expects a Jacoco dump file in order to provide coverage data to sonar.

I cannot find any useful documentation in Sonarqube confluence.

How can we configure Sonar to use Cobertura (without modifying ALL the projects pom files) and trigger code coverage unit test execution from Jenkins?.

Thanks!.

1
It seems that the recommended way now to execute Sonar is to reuse generated coverage reports, but can't find that information anywhere. What is more frustrating is that reusing a report from Cobertura throws an exception with Jacoco!. There is no visible way to disable Jacoco and it keeps throwing org.sonar.api.utils.SonarException: Can not add twice the same measure on ...yagamipaul
I had the same problem with Jacoco. The solution for me was to simply remove the jacoco jar from the plugins folder, this disables Jacoco.Steven Pessall
@StevenPessall This workaround will work but the real solution is the one I provided in my answer below.benzonico

1 Answers

4
votes

Since version 2.2 of Java Plugin and 1.6 of Cobertura plugin, SonarQube does not trigger unit test execution anymore : Only reuse report mode is available.

Please note that the recommended version for both of those plugins are the fixed versions Java 2.2.1 and Cobertura 1.6.1 to prevent the collision between JaCoCo and Cobertura plugin (which will happen with 2.2).

Because of all this, the property to select the default code coverage tool is not relevant anymore and you only have to provide a coverage report (either cobertura or JaCoCo) to get your coverage information.

Please refer to these piece of documentation to get a rough idea on how to do so : http://docs.codehaus.org/display/SONAR/Cobertura+Plugin http://docs.codehaus.org/display/SONAR/JaCoCo+Plugin