Gitlab CI-将失败的测试结果发布到页面 [英] Gitlab CI - Publish Failed Test Results to Pages
问题描述
我正在使用Gradle
创建一个简单的Java项目,该项目会生成测试报告(即BDD Cucumber,JUnit等).该项目被部署到Gitlab
,该项目是Gitlab CI
流程的一部分.
I'm creating a simple java project using Gradle
which generates a test report (i.e. BDD Cucumber, JUnit, etc.). This project is deployed to Gitlab
where the project is built as part of the Gitlab CI
process.
我的JUnit
报告在相对于项目路径的文件夹build/reports/tests/test/
中生成(作为index.html
和某些CSS
文件等).
My JUnit
reports are generated in the folder build/reports/tests/test/
relative to the project path (as an index.html
and some CSS
files, etc.).
即使在测试用例失败之后,如何配置.gitlab-ci.yml
将build/reports/tests/test/
的内容发布到Gitlab页面?
How do I configure my .gitlab-ci.yml
to publish the content of build/reports/tests/test/
to the Gitlab Pages even after my test cases fail?
这是我在.gitlab-ci.yml
中所拥有的:(可以在中找到我的仓库这里)
This is what I have in my .gitlab-ci.yml
: (My repo can be found HERE)
版本1:不向页面发布任何内容
Version 1: Doesn't publish anything to pages
image: java:8-jdk
stages:
- test
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
test:
stage: test
script:
- mkdir public
- ./gradlew test
artifacts:
paths:
- build/reports/tests/test/
only:
- master
after_script:
- mv build/reports/tests/test/* public
版本2:由于test
失败,因此不执行deploy
阶段.
Version 2: Doesn't execute the deploy
stage since test
has failed.
image: java:8-jdk
stages:
- test
- deploy
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
test:
stage: test
script:
- ./gradlew test
artifacts:
paths:
- build/reports/tests/test/
pages:
stage: deploy
dependencies:
- test
script:
- mkdir public
- mv build/reports/tests/test/* public
artifacts:
paths:
- public
only:
- master
推荐答案
我通过在pages
阶段结束时添加when: always
解决了该问题.现在,无论从属阶段的退出代码如何,它都将执行该阶段.
I solved the issue by adding the when: always
at the end of my pages
stage. It now executes the stage regardless of exit code from the dependent stage.
这篇关于Gitlab CI-将失败的测试结果发布到页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!