我现在已经尝试了几天让一个跑步者在码头工作箱上工作。我有一个安装了GitLab,gitlab-runner和docker的Debian运行系统。我想使用docker作为我的跑步者的容器,因为shell执行器正在我的CI机器上安装所有东西......
我到目前为止做了什么:我安装了像GitLab CE文档中描述的docker并运行此命令:
gitlab-runner register -n \
--url DOMAIN \
--registration-token TOKEN \
--executor docker \
--description "docker-builder" \
--docker-image "gliderlabs/alpine" \
--docker-privileged
然后我用这个.gitlab-ci-yml创建了一个测试仓库来查看它是否正常工作
variables:
# GIT_STRATEGY: fetch # re-uses the project workspace
GIT_CHECKOUT: "false" # don't checkout the working copy to a revision related to the CI pipeline
GIT_DEPTH: "3"
cache:
paths:
- node_modules/
stages:
- deploy
before_script:
- apt-get update
- apt-get install -y -qq sshpass
- ls -la
# ======================= Jobs=======================
# Teporaly disable jobs by adding a . (dot) before the job name
ftp-upload:
stage: deploy
# environment: Production
except:
- testing
script:
- rm ./package-lock.json
- npm install
- ls -la
- sshpass -V
- export SSHPASS=$PASSWORD
- sshpass -e scp -o stricthostkeychecking=no -r . $USERNAME@$HOST:/Test
only:
- master
# ===================== ./Jobs ======================
但我在GitLab CI控制台中收到错误:
Running with gitlab-runner 11.1.0 (081978aa)
on docker-builder 5ce3c211
Using Docker executor with image gliderlabs/alpine ...
Pulling docker image gliderlabs/alpine ...
Using docker image sha256:74a78e860d7b39aa694197a70d4467019b611b80c21d886fcd1bfc04d2e767d4 for gliderlabs/alpine ...
Running on runner-5ce3c211-project-3-concurrent-0 via srvvgit001...
Cloning repository for master with git depth set to 3...
Cloning into '/builds/additive/test'...
Skipping Git checkout
Skipping Git submodules setup
Checking cache for default...
Successfully extracted cache
/bin/sh: eval: line 64: apt-get: not found
$ apt-get update
ERROR: Job failed: exit code 127
我对这些docker容器了解不多,但它们似乎不需要修改我的CI系统就可以重用。它看起来正在安装另一个高山图像/容器,但是我没有说GitLab跑步者使用现有的吗?
希望有人可以更容易地向我解释这是如何工作的...我真的尝试了谷歌给我的任何东西。
您正在使用的Docker镜像是Alpine图像,这是一个最小的Linux发行版。
Alpine Linux没有使用apt
进行包管理,而是使用apk
。
问题出在你的.gitlab-ci-yml
的before_script
部分,你试图运行apt
。
要解决您的问题,请使用apt
替换apk
:
before_script:
- apk update
- apk add sshpass
...
阅读有关Alpine Linux软件包管理here的更多信息。