I am facing an issue while configuring Jacoco with sonar in Jenkins.
Currently I am creating a Jenkins job and my intention is to take an automatic build once I push code changes into git Hub. After that I need to take code coverage report and implemented using Jacoco with sonar.
Sonarqube configuration in Jenkins(Works in localhost) is as follows
Sonarqube server is in localhost and port with 9000
My Jenkins Home dir is as follows
Work space Root Dir: ${JENKINS_HOME}/workspace/${ITEM_FULLNAME}/
Then I created a new Job called Test123. Inside the Build option, I configured Maven,Sonar,Jacoco as follows
Maven Configuration
clean install
Sonar
Jacoco
My Pom.xml
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>unit-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${maven.test.skip}</skip>
<argLine>${argLine}</argLine>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skipITs}</skip>
<argLine>${argLine}</argLine>
<includes>
<include>**/*IntegrationTest.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.4.201502262128</version>
<configuration>
<skip>${maven.test.skip}</skip>
<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
<output>file</output>
<append>true</append>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Build Result is as follows
[JaCoCo plugin] Collecting JaCoCo coverage data...
[JaCoCo plugin] **/*.exec;**/*classes;**/src; locations are configured
[JaCoCo plugin] Number of found exec files for pattern **/*.exec: 1
[JaCoCo plugin] Saving matched execfiles: C:\Users\pxp167\.jenkins\workspace\Test123\target\coverage-reports\jacoco-unit.exec
[JaCoCo plugin] Saving matched class directories for class-pattern: **/*classes: C:\Users\pxp167\.jenkins\workspace\Test123\target\classes C:\Users\pxp167\.jenkins\workspace\Test123\target\test-classes
[JaCoCo plugin] Saving matched source directories for source-pattern: **/src: C:\Users\pxp167\.jenkins\workspace\Test123\src
[JaCoCo plugin] Loading inclusions files..
[JaCoCo plugin] inclusions: [**/*.class]
[JaCoCo plugin] exclusions: [**/*Test*]
[JaCoCo plugin] Thresholds: JacocoHealthReportThresholds [minClass=0, maxClass=50, minMethod=0, maxMethod=50, minLine=0, maxLine=50, minBranch=0, maxBranch=50, minInstruction=0, maxInstruction=50, minComplexity=0, maxComplexity=50]
[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
Build step 'Record JaCoCo coverage report' changed build result to UNSTABLE
Finished: UNSTABLE