简体   繁体   中英

Cannot pass artifacts between jobs in GitLab CI/CD

I have a GitLab project and my .gitlab-ci.yml looks like this:

stages:
  - build
  - deploy

image: registry.gitlab.com/myuser/myproj/ubuntuxenial:v1

before_script:
  - cd /home
  - mkdir docker
  - cd docker
  - git clone "https://xxx@github.com/myuser/myproj.git" repo
  - cd repo

render_site:
  stage: build
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME--$CI_JOB_STAGE-$CI_COMMIT_REF_NAME"
    expire_in: 1 week
    paths:
      - home/docker/repo/
  script:
    - Rscript build.R

...

I have provided the essential parts of the file in the context of this issue. As you can see, this automation is intended to do the following:

  1. Clone a repository.
  2. Invoke a build command inside the repository (I am using R). This step will generate some output files in the repository folder.
  3. Make sure to publish artifacts, I want to publish the content of the whole repository repo folder.

Note I have set GitLab to use Docker images. I am using a Unix image I have uploaded in my registry.

Problem

The issue happens in the first job: render_site . Everything goes fine, the commands are executed and all builds fine. However, the last line in the log for that task is:

Uploading artifacts...
WARNING: home/docker/repo/: no matching files      
ERROR: No files to upload

Troubleshooting

I understand the issue is in the path I provide in .gitlab-ci.yml . I have tried the following:

  • home/docker/repo/
  • /home/docker/repo/
  • repo/

Nothing works. This path that we specify, what is it relative to??? The documentation mentions:

You can only use paths that are within the project workspace.

What does it mean? I am creating a container every time I push and I cd into different directories in the commands I specify in .gitlab-ci.yml , so what is the project workspace the documentation mentions?

Problem solved. My question clearly came as a lack of understanding of GitLab and how a runner works. What I was missing is the fact that the runner, after creating a container out of the specified Docker image, will actually create, in the container, a folder with the commit.

Useless cloning

Therefore what I have in before_script is completely useless. And thanks to @ensc for pointing that in comments.

Project path

Coming to the question, the project path is exactly the directory created in the container where the repository is cloned at the specified commit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM