I'm using the below property to generate JaCoCo XML report
<property name="sonar.coverage.jacoco.xmlReportPaths" value="${basedir}/sonar-task/reports/jacoco.xml" />
When I invoke this ANT Task from Jenkins, I'm seeing the below exception in Jenkins logs and so I don't see the Code Coverage value in SonarQube
15:09:49 [sonar:sonar] Apache Ant(TM) version 1.10.7 compiled on September 1 2019
15:09:49 [sonar:sonar] SonarQube Ant Task version: 2.6.0.1426
.
.
.
15:14:55 [sonar:sonar] Sensor JavaSquidSensor [java] (done) | time=262215ms
15:14:55 [sonar:sonar] Sensor JaCoCo XML Report Importer [jacoco]
15:14:55 [sonar:sonar] Coverage report 'C:\Softwares\Jenkins\workspace\MYA_DevOps_PIPELINE\.\sonar-task\reports\jacoco.xml' could not be read/imported. Error: {}
15:14:55 [sonar:sonar] java.lang.IllegalStateException: Failed to parse JaCoCo XML report: C:\Softwares\Jenkins\workspace\MYA_DevOps_PIPELINE\.\sonar-task\reports\jacoco.xml
15:14:55 [sonar:sonar] at org.sonar.plugins.jacoco.XmlReportParser.parse(XmlReportParser.java:96)
I can see the HTML reports and I can see the jacoco.xml file is getting generated as well. But the content inside this file is not XML.
Just add the below line while you generate an XML JaCoCo report
<xml destfile="${sonar.coverage.jacoco.xmlReportPaths}"/>