问题
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:
- Clone a repository.
- Invoke a build command inside the repository (I am using R). This step will generate some output files in the repository folder.
- 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?
回答1:
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.
来源:https://stackoverflow.com/questions/55313542/cannot-pass-artifacts-between-jobs-in-gitlab-ci-cd