Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sonar Cobertura Plugin not finding coverage.xml file

I have a multi-module maven project in Jenkins 1.545.I am using Sonarqube version 4.2.I have installed cobertura plugin version 1.6.1 and java plugin version 2.2.1 in Sonarqube.I have successfully generated coverage.xml file at location- /target/site/cobertura/coverage.xml for each module using maven command- "cobertura:cobertura -Dcobertura.report.format=xml" For sonar,i have set the maven build option as sonar:sonar with properties as below:

sonar.dynamicAnalysis=reuseReports
sonar.junit.reportsPath=target/site
sonar.java.coveragePlugin=cobertura
sonar.cobertura.reportPath=/target/site/cobertura/coverage.xml

I can see coverage.xml file when I browse the workspace of my project in Jenkins but the plugin keeps saying that it can't find it.I get the following message in console output of jenkins-

Execute Findbugs 2.0.3 done: 48446 ms
Sensor FindbugsSensor done: 48800 ms
Sensor CoberturaSensor...
Cobertura report not found at /target/site/cobertura/coverage.xml
Sensor CoberturaSensor done: 4 ms
Sensor CpdSensor...

Any help is appreciated.Thanks in advance.

like image 218
user3472205 Avatar asked Jun 10 '14 06:06

user3472205


People also ask

What is the target location where cobertura coverage XML data will be generated?

Cobertura always uses default value target/site/coverage. xml path when running Sonar Scanner. Which Sonar property should be used to specify multiple cobertura coverage.

How does cobertura check code coverage?

Code coverage is directly calculated when you running the tests – each test you run will add coverage to your Java files.


1 Answers

I had the same issue (SonarQube 4.4., Cobertura 1.6.2, Jenkins + maven + java8) and I just finally figured out solution for the problem:

sonar.cobertura.reportPath=target/site/cobertura/coverage.xml

Notice the missing "/" from the beginning of the path!

It actually tried to search from absolute root directory in my Linux server.

like image 195
user2806909 Avatar answered Sep 27 '22 19:09

user2806909