Maven – Jenkins Cobertura plugin not finding the coverage.xml file

coberturaJenkinsmaven

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

Best Answer

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>
Related Topic