Hi all,
I am using SonarQube v6.7.2 with Jenkins 2.89.4 and Maven 3.0.2.
I launched the SonarQube analysis with the following configurations:
POM.xml
<!--Plugin to lauch unit and integration tests-->
<plugin>
<!-- Separates the unit tests from the integration tests. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Skip the default running of this plug-in (or everything is run twice...see below) -->
<skip>true</skip>
<!-- Show 100% of the lines from the stack trace (doesn't work) -->
<trimStackTrace>false</trimStackTrace>
</configuration>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<argLine>${jacoco.agent.ut.arg}</argLine>
<!-- Never skip running the tests when the test phase is invoked -->
<skip>false</skip>
<includes>
<!-- Include unit tests within integration-test phase. -->
<include>**/*Test.java</include>
</includes>
<excludes>
<!-- Exclude integration tests within (unit) test phase. -->
<exclude>**/*IT.java</exclude>
</excludes>
<properties>
<property>
<name>listener</name>
<value>org.sonar.java.jacoco.JUnitListener</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.7</version>
<configuration>
<includes>
<include>**/*/TestSuiteInt.java</include>
</includes>
<argLine>-Xmx1024m -XX:MaxPermSize=256m ${jacoco.agent.it.arg}</argLine>
<properties>
<property>
<name>listener</name>
<value>org.sonar.java.jacoco.JUnitListener</value>
</property>
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.7</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<argLine>-Xmx1024m -XX:MaxPermSize=256m ${jacoco.agent.it.arg}</argLine>
<properties>
<property>
<name>listener</name>
<value>org.sonar.java.jacoco.JUnitListener</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
<executions>
<!-- Prepares a variable, jacoco.agent.ut.arg, that contains the info
to be passed to the JVM hosting the code being tested. -->
<execution>
<id>prepare-ut-agent</id>
<phase>process-test-classes</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${sonar.jacoco.reportPath}</destFile>
<propertyName>jacoco.agent.ut.arg</propertyName>
<append>true</append>
</configuration>
</execution>
<!-- Prepares a variable, jacoco.agent.it.arg, that contains the info
to be passed to the JVM hosting the code being tested. -->
<execution>
<id>prepare-it-agent</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${sonar.jacoco.itReportPath}</destFile>
<propertyName>jacoco.agent.it.arg</propertyName>
<append>true</append>
</configuration>
</execution>
<execution>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<dependencies>
<dependency>
<groupId>org.codehaus.sonar-plugins.java</groupId>
<artifactId>sonar-jacoco-listeners</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
</dependencies>
Jenkins configuration for Sonar:
# unique project identifier (required)
sonar.projectKey=ADNCore
# project metadata (used to be required, optional since SonarQube 6.1)
sonar.projectName=ADNCore
sonar.projectVersion=4.0.0
# path to source directories (required)
sonar.sources=src_adnAccountController,src_adnCommon,src_adnDbRepresentation,src_adnException,src_adnFilters,src_adnGenericDao,src_adnKCM,src_adnKnowledgeIndex,src_adnLogging,src_adnNotifications,src_adnRightsAccess,src_adnWebServices,src_aspect_ordering,src_cmd,src_conflicts,src_excel,src_export,src_hbSessionOnDemand,src_KBEConnector,src_licensing,src_rightsAccessCheck,src_validation
# path to test source directories (optional)
sonar.tests=src/test/java
# path to Java project compiled classes (optional)
sonar.java.binaries=target/classes
#path to libraries
sonar.java.libraries=target/ADNCore/WEB-INF/lib/**.jar
sonar.test.inclusions=target/test-classes/
#path to reports
sonar.junit.reportPaths=target/failsafe-reports/**.xml
#Path to Jacoco reports
sonar.jacoco.reportPaths=target/jacoco-it.exec
With these configurations, I have all metrics on the SonarQube server, but the coverage percentage is always 0%. I have around 120 tests in my project and all tests are successfully launched and respecting reports were also created. I see that jacoco-it.exec file is also created with some data in it. And also, I see no error or warnings in any of the logs. But I still cannot see the coverage percentage in sonarqube server.
I would be grateful, if anyone could guide me this please?
Thanks in advance,
SD