ANT SONAR - JaCoCo Code Coverage shows 0 when used sonar.coverage.jacoco.xmlReportPaths

  • versions used
    SonarQube - Community Edition Version 7.9.2 (build 30863),
    Sonar Scanner 3.0.3,
    Apache ANT 1.9.4
  • Property used in build.xml
    <property name="sonar.coverage.jacoco.xmlReportPaths" value="${basedir}/sonar-task/reports/jacoco.xml" />
  • error observed from Jenkins logs
    [sonar:sonar] Sensor JavaSquidSensor [java] (done) | time=262215ms
    [sonar:sonar] Sensor JaCoCo XML Report Importer [jacoco]
    [sonar:sonar] Coverage report ‘C:\Softwares\Jenkins\workspace\MYA_DevOps_PIPELINE.\sonar-task\reports\jacoco.xml’ could not be read/imported. Error: {}
    [sonar:sonar] java.lang.IllegalStateException: Failed to parse JaCoCo XML report: C:\Softwares\Jenkins\workspace\MYA_DevOps_PIPELINE.\sonar-task\reports\jacoco.xml
    [sonar:sonar] at org.sonar.plugins.jacoco.XmlReportParser.parse(

P.S.: use the #bug:fault sub-category if you’re hitting a specific crash/error , or the #bug:fp sub-category for rules-related behaviour

Resolved the issue by adding the below line when we generate an JaCoCo report

<xml destfile="${sonar.coverage.jacoco.xmlReportPaths}"/>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.