GitLab CI Build没有上传代码接受的工件

时间:2019-06-11 13:56:38

标签: gitlab gitlab-ci

在测试失败时,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

我在做什么错了?

1 个答案:

答案 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