在测试失败时,GitLab无法上传由代码接收生成的工件时,我遇到了问题。它仅上载.gitignore
文件夹中的_output
。
这是我的.gitlab-ci.yml
的相关部分:
- ./src/Vendor/codeception/codeception/codecept run acceptance || true
- ls -a tests/_output
artifacts:
paths:
- "tests/_output"
expire_in: 20 days
when: always
有趣的是,我可以在工作完成之前浏览工件(在这种情况下,仅是.gitignore文件)。我的跑步者的日志证明,这些工件确实存在于目录tests/_output
中(简称):
$ ls -a tests/_output
.
..
.gitignore
commentsCest.answerCommentTest.fail.html
commentsCest.answerCommentTest.fail.png
commentsCest.normalCommentTest.fail.html
commentsCest.normalCommentTest.fail.png
failed
Uploading artifacts...
tests/_output: found 2 matching files
Uploading artifacts to coordinator... ok id=123456789 responseStatus=201 Created token=abcdefghij
Job succeeded
我在做什么错了?
答案 0 :(得分:0)
我想出了一种解决方法:
gitlab-runner仅在项目目录中正确上传文件。
要获取工件,请将所有文件复制到${CI_PROJECT_DIR}
:
codeception_tests:
stage: <your stage-name>
image: <your image>
script:
- ...
after_script:
- mkdir ${CI_PROJECT_DIR}/artifacts
- mkdir ${CI_PROJECT_DIR}/artifacts/codecept
- cp tests/_output ${CI_PROJECT_DIR}/artifacts/codecept -R
artifacts:
paths:
- ${CI_PROJECT_DIR}/artifacts/
expire_in: 5 days
when: always