allinonemovie
allinonemovie

Reputation: 734

GitLab CI Build not uploading artifacts of codeception

I have problems with GitLab not uploading the artifacts generated by codeception when a test fails. It only uploads the .gitignore in the _output folder. This is the relevant part from my .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

Interesting is, that I can browse the artifacts (in this case only the .gitignore-file) before the job even finished. The logs of my runner prove, that the artifacts do indeed exist in the directory tests/_output (shorted):

$ 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

What am I doing wrong?

Upvotes: 2

Views: 1175

Answers (1)

allinonemovie
allinonemovie

Reputation: 734

I figured out a workaround:

The gitlab-runner only uploads files properly inside the project directory. To get the artifacts, copy all files to ${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

Upvotes: 4

Related Questions