我需要在Gitlab中查看Java Maven项目的代码覆盖率报告。
- 我已将
pom.xml
中的jacoco
加入插件列表。 - 向我的
.gitlab-ci.yml
文件添加了pages作业。 - 将代码覆盖率解析添加到项目设置中,代码为:
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
pom.xml
中的 jacoco
插件:
The jacoco
plugin in 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 个任务都已成功通过。
我该如何查看覆盖率报告?