Jenkins Cobertura plugin not finding the coverage.xml file
Asked Answered
S

2

10

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

Salters answered 12/2, 2014 at 18:52 Comment(0)
C
9

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>
Cineraria answered 5/6, 2014 at 9:3 Comment(0)
C
2

The output of Cobertura in either xml or html..

<formats>                       
   <format>xml</format>
 </formats>

and make sure results (coverage.xml) is available in this directory, $JENKINS_HOME/workspace/..job../app/web-app/target/site/cobertura/coverage.xml file..

or Destination directory where you check cobertura reports..

or grab one sample file and try ..putting under job directory and see how it works...

Claiborn answered 12/2, 2014 at 19:44 Comment(1)
The extra html format doesn't trip up the jenkins-cobertura plugin. At least not for me.Salters

© 2022 - 2024 — McMap. All rights reserved.