Jake
Jake

Reputation: 2912

gitlab ci: "No files to upload" for job artifacts

This is my first time trying to generate a gitlab-ci job artifact. My ci script generates a csv file that I want to download as an artifact in the job. The yaml file is as below.

   unittest:
      script:
        - cd unittest
        - bash ci-test.sh
      artifacts:
        paths:
          - /*.csv
        when: always
        expire_in: 1 day

I obtained an error msg like this.

Uploading artifacts for successful job
00:02
Uploading artifacts...
WARNING: /*.csv: no matching files 
ERROR: No files to upload 

I have confirmed that the generated csv report is there.

Upvotes: 16

Views: 56250

Answers (4)

kirkadev
kirkadev

Reputation: 348

When I asked my tech-lead about it, he said "it's looks like a runner nas not internet connection", then I restarted my job and got success.

Upvotes: -7

kwick
kwick

Reputation: 787

You can also set your project directory path to the artifacts path:

  artifacts:
      paths:
      - $CI_PROJECT_DIR
      expire_in: 1 week 

This way in your code if you are not specifying any particular path for any file then it will always be in Project Directory and GitLab runner will be able to find it.

Upvotes: 4

Kolya Terletskyi
Kolya Terletskyi

Reputation: 181

You need to store your output file to $CI_PROJECT_DIR

An example:

test:
  stage: quality
  image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
  script:
    - cd /app
    - coverage run -m pytest
    - coverage report
    - coverage xml -o $CI_PROJECT_DIR/coverage.xml
  coverage: '/TOTAL.*\s([.\d]+)%/'
  artifacts:
    paths:
      - coverage.xml
    reports:
      cobertura:
        - coverage.xml

Upvotes: 1

rkm
rkm

Reputation: 3131

Paths are relative to the project directory. With that said, you cannot access files outside of the project directory, so /*.csv is incorrect.

If files are in the project, then just set path relative to the project, e.g. if you have it in reports folder, then make path equal reports/*.csv

Upvotes: 13

Related Questions