子模块cobertura jenkins报告



我们有以下布局的项目

    • 应用程序
    • 堆芯
    • 仪表

核心模块中有cobertura插件。我能够从命令行生成报告,没有任何问题(XML和HTML),甚至可以在Jenkins的工作区中看到它们。然而,我无法将这些报告与Jenkins Cobertura插件链接起来。根据Jenkins文档,默认为

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

由于子模块中生成了报告,因此此操作不起作用。我试着跟随

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

好吧,问题是我使用了cobertura插件作为

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

相反,它应该是

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

之后,我将Jenkins Cobertura插件指向core/target/site/Cobertura/coverage.xml

向您的应用程序目标添加以下行:(在jenkins中配置应用程序的部分)

cobertura:cobertura -Dcobertura.report.format=xml

Cobertura xml报告模式:
*/target/site/cobertura/.xml

pom.xml更改:

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

最新更新