[英]Cannot pass artifacts between jobs in GitLab CI/CD
I have a GitLab project and my .gitlab-ci.yml
looks like this:我有一个 GitLab 项目,我的
.gitlab-ci.yml
看起来像这样:
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:
如您所见,此自动化旨在执行以下操作:
repo
folder.repo
文件夹的内容。 Note I have set GitLab to use Docker images.注意我已经将 GitLab 设置为使用 Docker 镜像。 I am using a Unix image I have uploaded in my registry.
我正在使用已上传到我的注册表中的 Unix 映像。
The issue happens in the first job: render_site
.问题发生在第一份工作中:
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
I understand the issue is in the path I provide in .gitlab-ci.yml
.我知道问题出在我在
.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?每次我在
.gitlab-ci.yml
指定的命令中 push 和cd
到不同目录时,我都会创建一个容器,那么文档提到的项目工作区是什么?
Problem solved.问题解决了。 My question clearly came as a lack of understanding of GitLab and how a runner works.
我的问题显然是由于对 GitLab 以及跑步者的工作方式缺乏了解。 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.
我缺少的是,运行程序在从指定的 Docker 映像中创建容器后,实际上会在容器中创建一个包含提交的文件夹。
Therefore what I have in before_script
is completely useless.因此,我在
before_script
内容完全没用。 And thanks to @ensc for pointing that in comments.并感谢@ensc 在评论中指出这一点。
Coming to the question, the project path is exactly the directory created in the container where the repository is cloned at the specified commit.谈到这个问题,项目路径正是在指定提交时克隆存储库的容器中创建的目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.