gitlab - 当我将执行器设置为 shell 时,为什么 gitlab-runner 作为 ruby​​ docker 运行执行?

标签 gitlab gitlab-ci gitlab-ci-runner

gitlab-ci

stages:
  - deploy
deploy:
  stage: deploy
  script:
    - npm install
    - npm run build
    - cp -R build/* /var/www/html

管道:

 Preparing the "docker+machine" executor
00:28
Using Docker executor with image ruby:2.5 ...

为什么选择 docker ruby​​?为什么不使用 shell 执行器?

我的config.toml

concurrent = 1
check_interval = 0

[session_server]
session_timeout = 1800

[[runners]]

    name = "test"
    url = "https://gitlab.com/"
    token = "123321123"
    executor = "shell"
    shell = "bash"

最佳答案

您很可能在存储库上启用了共享运行程序,并且恰好在提交作业时,该作业首先选择共享运行程序,而不是您的自定义 shell 运行程序。

因此可用的选项是 disable shared runners对于您的项目:

  • 转至项目的设置> CI/CD
  • 共享运行器部分中,禁用为此项目启用共享运行器

更好的解决方案是启用 tags关于运行者。

何时 registering对于运行者,在第 5 步,您可以提供与运行者关联​​的标签。如果您在以下方面拥有足够的权限,您还可以更改 GitLab UI 中的标签:

gitlab.com -> group -> settings -> CI/CD -> runner settings

请注意,config.toml 文件中的标签不可更改。

例如,您现在可以使用 shell-internal标记您的运行程序,然后要仅在此运行程序上运行作业,请添加标签: - shell -internal 在您的 gitlab-ci.yml 文件中:

build:
  script:
    - echo "running on shell-internal"
  tags:
    - shell-internal

此链接应该解释 GitLab 运行器的工作原理:https://docs.gitlab.com/ee/ci/runners/

关于gitlab - 当我将执行器设置为 shell 时,为什么 gitlab-runner 作为 ruby​​ docker 运行执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65673483/

相关文章:

docker - 为自己的 docker 注册表提供 dockerd 的 SSL 证书

bash - ./deploy.sh 不适用于 gitlab ci

javascript - 检查 gitlab 项目中文件的更新

api - GitLab API获取特定分支的所有提交

git - 限制 Git 扩展中的用户模拟

gitlab-ci - 用于检查代码格式的 gitlab CI 管道

scala - 如何在 gitlab-ci 中缓存

gitlab - Gitlab 的 "project workspace"是如何定义并在作业之间传播的?

gitlab-ci-runner - 错误 : cannot open . git/FETCH_HEAD:gitlab-runner 上的权限被拒绝

docker - 缓存 GitLab CI 构建阶段之间的依赖关系