I have a multi-module maven project in Jenkins 1.502 with the jenkins-cobertura plugin version 1.9.3. My cobertura.xml file is generated in the web-app module and I can see it when I browse the workspace of my project in Jenkins. I've tried multiple different ways to approach the path setting in the post build action to point to the cobertura.xml file but the plugin keeps saying that it can't find it. I get the error:
[Cobertura] No coverage results were found using the pattern 'app/web-app/target/site/cobertura/cobertura.xml' relative to 'C:\Jenkins\jobs\Dev - appName - trunk\workspace'
My maven pom.xml for the web app has cobertura set up in the section of the pom.xml as follows:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<formats>
<format>xml</format>
<format>html</format>
</formats>
<instrumentation>
<excludes>
<exclude>**/*Test.class</exclude>
<exclude>**/Mock*.class</exclude>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
Also in jenkins, my maven build option is as follows:
-Pqa clean cobertura:cobertura install
EDIT I found my issue, I was naming the file "cobertura.xml" instead of "coverage.xml" or better yet picking them all up with
**/target/site/cobertura/*.xml
Maven will generate the Cobertura code coverage report at ${project}/target/site/cobertura/index.
Cobertura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage. It is based on jcoverage.
xml is an xml file in Coloratura report format, which contains information about covered lines. The file name can be chosen arbitrarily, as one of the arguments for exportResult method. src is the folder that contains source files, listings, or both.
Add below lines to your application Goals (configure section of the application in jenkins):
cobertura:cobertura -Dcobertura.report.format=xml
pom.xml changes:
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
</plugins>
</reporting>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With