Sonar Cobertura Plugin not finding coverage.xml file
Asked Answered
T

1

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.

Timbale answered 10/6, 2014 at 6:48 Comment(7)
what cobertura version used? as i know, sonar4.2 has some problem with high version cobertura. The sonar 4.7.3 may be work.Suber
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.Suber
@CHmoonKa-I am using Cobertura version 1.6.1Timbale
It was not working with Sonar 3.7.4.Therefore i upgraded sonar to Sonarqube 4.2.Timbale
I am still facing the same issue.Can anyone help?Timbale
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).Timbale
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?Timbale
F
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.

Faletti answered 7/8, 2014 at 9:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.