Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Cobertura plugin not finding the coverage.xml file

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

like image 594
doug78 Avatar asked Feb 12 '14 18:02

doug78


People also ask

What is the target location where cobertura coverage XML data will be generated?

Maven will generate the Cobertura code coverage report at ${project}/target/site/cobertura/index.

How does cobertura check code coverage?

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.

What is cobertura XML format?

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.


1 Answers

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>
like image 185
Sreedhar GS Avatar answered Nov 16 '22 01:11

Sreedhar GS