[英]Build step in pipeline is failing with connection refused error while running GitLab and GitLab-Runner docker instances locally
[英]Using gitlab-runner locally and passing artifacts from previous step
我正在尝试调试 GitLab CI 管道中的一些问题。 我有一个步骤 B,它使用了步骤 A 中的一些工件。
步骤 A 很长(并且在 CI 中工作),所以我不想在本地运行它:我只是从 GitLab 下载生成的工件。 所以我有一个artifacts.zip
,我提取它以获得output
和logs
目录。 到现在为止还挺好。
我想使用gitlab-runner
在本地运行步骤 B。 请注意,我使用的是 9.5 版( https://docs.gitlab.com/runner/install/old.html )。
我正在使用这个命令:
gitlab-runner exec docker step-b
正如我所解释的, step-b
需要来自伪影step-a
。 这是我尝试过的:
gitlab-runner exec docker --docker-volumes ~/Downloads/output step-b
在步骤 B 中执行的脚本之一正在执行类似mv ../output /some/where/else
。 但是,此脚本失败并出现以下错误:
mv: cannot stat '../output': No such file or directory
出现此错误后,我有两个问题:
这个脚本在哪里执行? 它是从.gitlab-ci.yml
:
./scripts/my_script.sh.
什么是.
在这种情况下?
--docker-volumes ~/Downloads/output
将目录安装在正确的位置,以便我的脚本可以找到它?编辑
根据要求,这里是步骤 A 的描述。
script:
- mkdir -p /usr/local/compil_result
- ./scripts/compil.sh
- mv /usr/local/compil_result ./output
artifacts:
paths:
- output
- logs
由于您没有提到您使用的 docker 镜像,我假设它是您或您的同事制作的自定义镜像。 我认为您需要检查 docker 映像的 Dockerfile,以确保该脚本的工作目录在哪里。
或者你也可以尝试进入外壳,首先查看容器内部的结构,
docker run --rm -it --entrypoint /bin/bash your-image-name
要挂载 Docker 卷,您需要使用冒号分隔的主机目录和容器目录,并为它们使用完整路径目录。
像这样的东西,
gitlab-runner exec docker --docker-volumes '/home/username/Downloads/output:/output' step-b
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.