8

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.

NorthCat
  • 9,643
  • 16
  • 47
  • 50
user3472205
  • 81
  • 1
  • 1
  • 3
  • what cobertura version used? as i know, sonar4.2 has some problem with high version cobertura. The sonar 4.7.3 may be work. – CHmoonKa Jun 10 '14 at 07:36
  • in my project, i use sonar4.2 and jacoco (same as cobertura). get same error as your. then i update sonar to 3.7.4 , all work. – CHmoonKa Jun 10 '14 at 07:39
  • @CHmoonKa-I am using Cobertura version 1.6.1 – user3472205 Jun 10 '14 at 08:40
  • It was not working with Sonar 3.7.4.Therefore i upgraded sonar to Sonarqube 4.2. – user3472205 Jun 10 '14 at 08:42
  • I am still facing the same issue.Can anyone help? – user3472205 Jun 11 '14 at 09:04
  • Finally my issue is resolved.While giving the relative path it should be "target/site/cobertura/coverage.xml" instead of "/target/site/cobertura/coverage.xml" (relative path should not start with a slash). – user3472205 Jun 12 '14 at 05:19
  • But now i am facing another error "SquidIndex can't be null" while running Sonar Analysis.My jenkins build fail with the following error in console output:- parsing {$MyPath}/target/site/cobertura/coverage.xml [ERROR] SquidIndex can't be null Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.3.1:sonar (default-cli) on project ing-top-level: Can not execute SonarQube analysis: SquidIndex can't be null Can anyone help me? – user3472205 Jun 12 '14 at 05:22

1 Answers1

14

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.

Arpit Aggarwal
  • 27,626
  • 16
  • 90
  • 108
user2806909
  • 141
  • 3