.gitlab-ci.yml 错误:“apk:找不到命令" [英] .gitlab-ci.yml error: "apk: command not found"

查看:135
本文介绍了.gitlab-ci.yml 错误:“apk:找不到命令"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 .gitlab-ci.yml 文件:

I have the following .gitlab-ci.yml file:

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 运行器执行它时,我收到以下错误:

When the Gitlab runner executes it, I get the following error:

$ apk add --update -y python-pip
bash: line 82: apk: command not found
ERROR: Job failed: exit status 1

我应该如何安装 apk?或者我应该使用 docker 以外的什么图像来运行这个 gitlab-ci.yml 文件?

How am I supposed to install apk? Or what image other than docker should I be using to run this gitlab-ci.yml file?

推荐答案

原来我有两个不同的运行器:一个标记为shell executor"(Ubuntu),另一个标记为docker executor".

Well, it turns out I had two different runners: one marked as "shell executor" (Ubuntu) and the other marked as "docker executor".

此错误仅在 Ubuntu 运行程序调度作业时被抛出,因为 Ubuntu 不附带 apk.

This error was being thrown out only when the Ubuntu runner was dispatching the job, since Ubuntu doesn´t come with apk.

我禁用了 Ubuntu 运行器并解决了问题.

I disabled the Ubuntu runner and solved the problem.

这篇关于.gitlab-ci.yml 错误:“apk:找不到命令"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆