我有以下 .gitlab-ci.yml 文件:
image: docker
services:
- docker:dind
stages:
- test
- build
- deploy
test:
stage: test
before_script:
- apk add --update -y python-pip
- pip install docker-compose
script:
- echo "Testing the app"
- docker-compose run app sh -c "python manage.py test && flake8"
build:
stage: build
only:
- develop
- production
- feature/deploy-debug-gitlab
before_script:
- apk add --update -y python-pip
- pip install docker-compose
script:
- echo "Building the app"
- docker-compose build
deploy:
stage: deploy
only:
- master
- develop
- feature/deploy
- feature/deploy-debug-gitlab
before_script:
- apk add --update -y python-pip
- pip install docker-compose
script:
- echo "Deploying the app"
- docker-compose up -d
environment: production
when: manual
当Gitlab运行程序执行它时,出现以下错误:
$ apk add --update -y python-pip
bash: line 82: apk: command not found
ERROR: Job failed: exit status 1
我应该如何安装apk?还是我应该使用docker
以外的其他图像来运行此gitlab-ci.yml
文件?
答案 0 :(得分:1)
另一种选择是在{em> {3}}
中设置安装步骤在之上测试image: docker:latest
services:
- docker:dind
before_script:
- apk add --update python-pip
答案 1 :(得分:1)
好吧,事实证明,我有两个不同的跑步者:一个被标记为“ shell executor”(Ubuntu),另一个被标记为“ docker executor”。
仅在Ubuntu运行程序分发作业时才抛出此错误,因为Ubuntu并未附带apk。
我禁用了Ubuntu运行程序并解决了问题。