【问题标题】:Gitlab runner does not seem to load docker imageGitlab runner 似乎没有加载 docker 镜像
【发布时间】:2022-01-06 11:10:19
【问题描述】:

对于旧代码库,我们尝试从仅通过 FTP 上传更改到使用 Gitlab CI/CD。但是,我们都没有丰富的 Gitlab 经验,我一直在尝试按照本指南设置部署:

https://savjee.be/2019/04/gitlab-ci-deploy-to-ftp-with-lftp/

我现在正在我自己的 mac 上运行 gitlab-runner,但是,我的 yml 文件中的 docker 映像似乎没有正确加载。使用文章中的 yml 时:

image: ubuntu:18.04

before_script:
  - apt-get update -qy
  - apt-get install -y lftp

build:
  script:
    # Sync to FTP
    - lftp -e "open ftp.mywebhost.com; user $FTP_USERNAME $FTP_PASSWORD; mirror -X .* -X .*/ --reverse --verbose --delete local-folder/ destination-folder/; bye"

它告诉我apt-get: command not found。我也尝试过使用 apk-get,但没有区别。我试图找到一个提前安装了 lftp 的不同 docker 映像,但后来我得到了一个 lftp: command not found

image: minidocks/lftp:4

before_script:
  # - apt-get update -qy
  #- apt-get install -y lftp

build:
  script:
    - lftp -e "open ftp.mywebhost.com; user $FTP_USERNAME $FTP_PASSWORD; mirror -X .* -X .*/ --reverse --verbose --delete local-folder/ destination-folder/; bye"
    - echo 'test this'

如果我注释掉 lftp/apt-get 位,我会得到 echo 命令,但是(它确实有效)。

我在网上搜索时似乎找不到任何原因。抱歉,如果这是一个重复的问题,或者我只是在错误的地方寻找。

【问题讨论】:

  • 你在机器上安装runner时选择了哪个executor?
  • 我想我选择了 shell 执行器。我的印象是我必须选择那个,因为我是从命令行运行它的,但我从问题中假设它不是如何工作的?
  • docs.gitlab.com/runner/executors/#compatibility-chart => shell 执行器不处理image 标签。你真正想要的执行器类型是 docker。
  • 感谢您的帮助,是时候使用那个执行器了。
  • @Zeitounator 这确实是问题所在。如果您可以发布回复以便我将其标记为答案?

标签: gitlab continuous-integration continuous-deployment


【解决方案1】:

从您的问题来看,您似乎正在使用 shell 执行器在 gitlab-runner 上执行任务。

shell 执行程序不处理 image 关键字,正如在 the runner compatibility matrix 中公开的那样。

此外,由于您想部署在 docker 容器上,所以无论如何都需要 docker executor

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-09
    • 2021-03-04
    • 2021-09-07
    • 2018-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-20
    相关资源
    最近更新 更多