0

We have project with following layout

  1. parent
    • app
    • core
    • instrumentation

There is cobertura plugin in core module. I'm able to generate reports from command line no problem at all (XML and HTML) I'm even able to see them in workspace on Jenkins. However I'm not able to link these reports with Jenkins Cobertura plugin. The default as per Jenkins documentation is

**/target/site/cobertura/coverage.xml

This doesn't work due to reports generated in sub-module. I tried following

core/target/site/cobertura/coverage.xml
/core/target/site/cobertura/coverage.xml
**/core/target/site/cobertura/coverage.xml
peter_budo
  • 1,748
  • 4
  • 26
  • 48

2 Answers2

1

OK, the problem is that I used cobertura plugin as

<build>
    <pluginManagement>
      <plugins>
        <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>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>

Instead it should be as

<build>
    <plugins>
      <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>
          <check/>
        </configuration>
        <executions>
          <execution>
            <phase>clean</phase>
            <goals>
              <goal>cobertura</goal>
            </goals>
          </execution>
        </executions>
      </plugin> 
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.5.1</version>
      </plugin>
    </plugins> 
  </reporting>

After this I point Jenkins Cobertura plugin to core/target/site/cobertura/coverage.xml

peter_budo
  • 1,748
  • 4
  • 26
  • 48
0

Add below lines to your application Goals:(configure section of the application in jenkins)

cobertura:cobertura -Dcobertura.report.format=xml

Cobertura xml report pattern:
*/target/site/cobertura/.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>

Sreedhar GS
  • 2,694
  • 1
  • 24
  • 26