Jacoco plugin showing 0% coverage in jenkins reports but when I ran the same command in local system, jacoco generates reports properly. I'm using following command:
mvn -s xyz/settings.xml -f xyz/xyz/pom.xml clean install org.jacoco:jacoco-maven-plugin:report-aggregate
So When I run this command in jenkins it generates wrong reports. I've checed it in WorkSpace directory for corresponding project in jenkins. It shows 0% coverage for every project. But when I run the same maven command in my local system jacoco-maven generates correct coverage reports. I can see them in as they are in HTML format.
My pom.xml has this to run jacoco with maven:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
I'm using following tools:
jacoco-maven-plugin version 0.7.7
jenkins-jacoco-plugin version 2.0.1
apache-maven version 3.5.0
Also this is my jenkins console log which I'm getting after the maven command is finished.
[JaCoCo plugin] Collecting JaCoCo coverage data...
[JaCoCo plugin] **/**.exec;**/target/classes;**/src; locations are configured
[JaCoCo plugin] Number of found exec files for pattern **/**.exec: 0
[JaCoCo plugin] Saving matched execfiles:
[JaCoCo plugin] Saving matched class directories for class-pattern: **/target/classes:
<<<<<<Classes folders list for all project>>>>>>>>
[JaCoCo plugin] Loading inclusions files..
[JaCoCo plugin] inclusions: []
[JaCoCo plugin] exclusions: []
[JaCoCo plugin] Thresholds: JacocoHealthReportThresholds [minClass=0, maxClass=0, minMethod=0, maxMethod=0, minLine=0, maxLine=0, minBranch=0, maxBranch=0, minInstruction=0, maxInstruction=0, minComplexity=0, maxComplexity=0]
[JaCoCo plugin] Publishing the results..
[JaCoCo plugin] Loading packages..
[JaCoCo plugin] Done.
[JaCoCo plugin] Overall coverage: class: 0, method: 0, line: 0, branch: 0, instruction: 0
Finished: SUCCESS
Below is my jenkins setup for jacoco reports:
And here is my folder structure of target directory.
target directory is present under project dir.
So my real concern is why on jenkins these files ie coverage files are not getting generated correctly while same command in my local system generates correct coverage report.
Thanks.
P.S. :- I'm doing this in multimodule environment where my source files are present in one project and test files are available in another project. So for every source project there exist a test project. Also one thing I just noticed that after running maven command, Class files are getting created under /target/classes directory of source while html files for the reports are getting generated under /target/site directory of test project. I'm not sure why this is.