【发布时间】:2018-06-10 11:54:38
【问题描述】:
我需要在 Gitlab 中查看 java maven 项目的代码覆盖率报告。 根据this、this 和其他一些来源:
- 我在
pom.xml的插件列表中添加了jacoco。 - 已将页面作业添加到我的
.gitlab-ci.yml文件中。 - 将
Total.*?([0-9]{1,3})%添加到项目设置中的代码覆盖率解析中。
但是没有任何报道报告,或者至少我看不到。没有覆盖百分比或覆盖报告页面。
.gitlab-ci.yml 文件的内容:
image: maven:latest
variables:
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
cache:
paths:
- .m2/repository/
build:
stage: build
script:
- mvn $MAVEN_CLI_OPTS compile
test:
stage: test
script:
- mvn $MAVEN_CLI_OPTS test
artifacts:
paths:
- target/site/jacoco/
pages:
stage: deploy
dependencies:
- test
script:
- mkdir public
- mv target/site/jacoco/index.html public
artifacts:
paths:
- public
deploy:
stage: deploy
script:
- mvn $MAVEN_CLI_OPTS verify
only:
- master
jacoco 插件在pom.xml:
<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.com 上的私人项目。
管道及其所有 4 个作业均成功通过。
如何查看覆盖率报告?
【问题讨论】:
标签: maven gitlab code-coverage gitlab-ci jacoco