Failed to import externally generated report-jacoco.exec into Sonar

I was able to start my multi-module app instance located on a different server than my jenkins build server with the following JVM option: "-javaagent:${MAIN_DIR}/lib/jacocoagent.jar==destfile=/jacoco.exec,output=tcpserver,address=*"

In my Jenkins build I have the following steps: ant task calling the target jacocoReport. The build.xml file that I am using for this purpose has the following code:

<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
    <classpath path="/opt/hudson/tools/jacocoant.jar"/>
</taskdef>

<target name="jacocoReport">
        <jacoco:dump address="${jacoco.host}" port="${jacoco.port}" dump="true" reset="true" destfile="${jacocoReportFile}" append="false"/>
</target>

<target name="jacocoReset">
        <jacoco:dump address="${jacoco.host}" port="${jacoco.port}" reset="true" destfile="${jacocoReportFile}" append="false"/>
    <delete file="${jacocoReportFile}"/>
</target>

      

And finally, I have a maven build step that calls sonar: sonar

Here's a section in the POM regarding my integration report;

<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.itReportPath>${WORKSPACE}/it-jacoco.exec</sonar.jacoco.itReportPath>
<sonar.language>java</sonar.language>
<sonar.branch>9.9.5</sonar.branch>

      

and here's my plugin config:

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
          <append>true</append>
        </configuration>
        <executions>
          <execution>
            <id>pre-test</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>post-test</id>
            <phase>test</phase>
            <goals>
              <goal>report</goal>
              <goal>report-integration</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      

When the build finishes my sonar recording is still showing 0% for my integration tests. But when I take the same jacoco.exec report and import it using the Coverage Iclectage session, I get 26% coverage.

Finally, when I go through the Jenkins build logs, I see the following:

Sensor JaCoCoItSensor...
Analysing /var/lib/jenkins/workspace/XXXXXX/it-jacoco.exec
No information about coverage per test.
Sensor JaCoCoItSensor done: 34 ms

      

I don't have automated integration tests right now, I want to import the integration report from my external test machine.

+3


source to share





All Articles