doug78
doug78

Reputation: 307

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

Upvotes: 10

Views: 19528

Answers (2)

Sreedhar GS
Sreedhar GS

Reputation: 2788

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>

Upvotes: 9

Guru
Guru

Reputation: 419

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...

Upvotes: 2

Related Questions