如何修复管道gitlab?
Posted
技术标签:
【中文标题】如何修复管道gitlab?【英文标题】:how to fix pipeline gitlab? 【发布时间】:2022-01-16 10:09:07 【问题描述】:我正在尝试制作一个 gitlab 管道。以便在每次推送时检查存储库的有效性 管道代码:
image: docker:dind
stages:
- test
test:
stage: test
script:
- cp -r ./ /golang_app/
- cd /golang_app/
- chmod +x /golang_app/run-tests.sh /golang_app/scripts/test_in_docker.sh
- chdir /golang_app/
- /bin/sh ./run-tests.sh
tags:
- docker
在文件 run-tests.sh 中:
#!/bin/bash
docker run \
-v $(pwd):/tests \
golang:1.16.6-alpine3.14 \
/tests/scripts/test_in_docker.sh
在我的存储库中:
total 68
drwxrwxrwx 5 root root 4096 Dec 12 16:26 .
drwxrwxrwx 4 root root 4096 Dec 12 14:22 ..
drwxrwxrwx 6 root root 4096 Dec 12 16:26 .git
-rw-rw-rw- 1 root root 77 Dec 12 14:22 .gitignore
-rw-rw-rw- 1 root root 171 Dec 12 16:26 .gitlab-ci.yml
-rw-rw-rw- 1 root root 267 Dec 12 14:22 Dockerfile
-rw-rw-rw- 1 root root 1071 Dec 12 14:22 LICENSE
-rw-rw-rw- 1 root root 1630 Dec 12 14:22 README.md
drwxrwxrwx 3 root root 4096 Dec 12 14:22 cmd
-rw-rw-rw- 1 root root 190 Dec 12 14:22 docker-compose.yaml
-rw-rw-rw- 1 root root 107 Dec 12 14:22 go.mod
-rw-rw-rw- 1 root root 13518 Dec 12 14:22 go.sum
-rwxrwxrwx 1 root root 117 Dec 12 14:22 run-tests.sh
drwxrwxrwx 2 root root 4096 Dec 12 14:22 scripts
我在 gitlab-runner 日志中得到了这个,只要我还没有尝试运行它,我就不想运行它
$ /bin/sh ./run-tests.sh
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/tests/scripts/test_in_docker.sh": stat /tests/scripts/test_in_docker.sh: no such file or directory: unknown.
time="2021-12-12T17:24:22Z" level=error msg="error waiting for container: context canceled"
【问题讨论】:
【参考方案1】:解决方案:
stages:
- test
test:
stage: test
script:
- /bin/sh ./run-tests.sh
tags:
- shell-runner
【讨论】:
以上是关于如何修复管道gitlab?的主要内容,如果未能解决你的问题,请参考以下文章