“Project coverage is set to 0%” – JaCoCo and Sonar in Jenkins with Ant

I moved my job from a single Hudson machine to a multi-slave Jenkins environment, and now JaCoCo coverage no longer works.

WORKING (old):
Hudson 2.0.1,
Jenkins Sonar Plugin 1.7.1,
Sonar 2.1.2

BROKEN (new):
Jenkins 1.446,
Jenkins Sonar Plugin 1.7.2,
Sonar 2.1.2

My Hudson job is called Pinnacle and it used to run on a single Hudson server with Sonar on the same machine. I set up my (NO MAVEN) build by doing the following.

1) Added an Ant target to my build.xml called test-with-coverage

2) Configured the Pinnacle job in Hudson to “invoke standalone Sonar Analysis” with these properties:


(Note that the code is checked out into Pinnacle directory in the Jenkins job workspace.)

3) Configured Sonar “general settings” to use JaCoCo for code coverage

Everything worked beautifully!

But in the new Jenkins environment, I see this error in the Jenkins build output:

23:15:17.863 INFO  Sensor JaCoCoSensor...
23:15:17.868 INFO  Project coverage is set to 0% as no JaCoCo execution data has been dumped: /var/lib/jenkins/workspace/Pinnacle/Pinnacle/jacoco.exec

That file does not exist on the slave where the build ran. (The directory /var/lib/jenkins/workspace/Pinnacle/Pinnacle does exist.)

All other sensors (FindBugs, PMD, etc) appear to be working OK. Just JaCoCo is broken.

Does Sonar/JaCoCo even work in a multi-slave Jenkins environment?

I suspect that the Ant task test-with-coverage is not getting run. How does Sonar locate the build.xml? And what is different between old and new installations?

  • Multiple views of same project in SonarQube
  • Sonar Runner does not use properties of sonar-project.properties
  • SonarQube exclude Maven module
  • How do I get Sonarcloud to run on pull requests from forks with Travis, Maven & github
  • How do I make Jenkins, Sonar and the JaCoCo plugin work together for Eclipse Tycho Plugin Projects (or maybe Cobertura)?
  • sonar build stability plugin gives 403 forbidden error for sonarqube version 3.1.1
  • Can SonarQube fetch Data from a Git Repository?
  • Unable to TFS annotate the following file which is not in a mapped TFS workspace
  • One Solution collect form web for ““Project coverage is set to 0%” – JaCoCo and Sonar in Jenkins with Ant”

    I’ve recently setup and successfully got Sonar and Jacoco running together. Since I’m recent with the topic, I figured I’d check on stackoverflow for similar issues and help out. I am getting results from Jacoco, but found you had to explicitly set the following parameters in addition to the properties you’ve listed in your post:


    You have to set sonar.core.codeCoveragePlugin=jacoco if you want to be able to use the sonar.jacoco.reportPath property. Otherwise, you will have to use the sonar.jacoco.itReportPath property. However, I recommend just setting the codeCoveragePlugin and reportPath properties. Otherwise, it won’t display under the default coverage widget in sonar. Please make note, you cannot use the default coverage tool and jacoco together. It has to be one or the other. I decided to use Jacoco.

    Your ant target must be configured to generate the jacoco.exec results prior to running the sonar tasks:

    <jacoco:coverage enabled="${tests.code.coverage}" destfile="${jacoco.exec.dest}">
      <junit fork="yes" printsummary="withOutAndErr" dir="${tests.working.dir}">

    Be sure to tell sonar to reuse reports and any sunfire reports if you’re running junit before sonar, that is if you’re running junit outside of sonar:


    For whatever reason, if you need more verbose debugging, use the following property:


    Git Baby is a git and github fan, let's start git clone.