【问题标题】:Gitlab CI Code Coverage with Jacoco Issue带有 Jacoco 问题的 Gitlab CI 代码覆盖率
【发布时间】:2018-10-25 00:16:24
【问题描述】:

我正在尝试设置 Gitlab CI。它正在工作,但我在尝试添加 Jacoco 代码覆盖率时遇到了问题。

我在 pom.xml 中的 Jacoco 插件就是这个。

...

  <plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.7.5.201505241946</version>
    <executions>
      <execution>
        <id>pre-unit-test</id>
        <goals>
          <goal>prepare-agent</goal>
        </goals>
      </execution>
      <execution>
        <id>post-unit-test</id>
        <phase>test</phase>
        <goals>
          <goal>report</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
....

我的 .gitlab-ci.yml 文件是这个。 ....

codecoverage:
image: kaiwinter/docker-java8-maven
script:
 - mvn install -B
 - cat target/site/jacoco/index.html
....

但是,我无法生成和显示代码覆盖率。我收到以下错误。

cat: target/site/jacoco/index.html: No such file or directory

请帮忙。

【问题讨论】:

    标签: gitlab-ci jacoco jacoco-maven-plugin


    【解决方案1】:

    您能否删除cat target/site/jacoco/index.html 行并检查它是否正常工作。该行不起作用,因为它在 docker 内部运行,并且您正在尝试访问其文件系统。

    如果它有效,请尽快告诉我。

    【讨论】:

    • 但是获得徽章覆盖率值的替代解决方案是什么?
    • 尝试使用$CI_PROJECT_DIR而不是相对路径
    猜你喜欢
    • 1970-01-01
    • 2016-11-11
    • 2019-01-02
    • 2012-11-02
    • 2014-11-09
    • 2018-01-06
    • 2018-05-28
    • 2012-06-11
    • 1970-01-01
    相关资源
    最近更新 更多