【问题标题】:Gitlab runner run my ci deploy in master branch with shared runnerGitlab runner 使用共享运行器在 master 分支中运行我的 ci 部署
【发布时间】:2019-01-04 10:58:33
【问题描述】:

我在 digitalocean 中有远程服务器 ubuntu 16。我还安装了 gitlab-runner 并配置它们并在我的项目中添加 gitlab-ci-yml 文件。 有时(1/99)它运行正确,但大多数情况下它不运行。

concurrent = 1
check_interval = 0

  [session_server]
  session_timeout = 1800

[[runners]]
  name = "Gitlab-Runner"
  url = "https://gitlab.com/"
  token = "***"
  executor = "shell"
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

我的 gitlab-ci-yml

image: docker

services:
  - docker:dind

stages:
  - test
  - deploy
test:
  stage: test
  only:
    - master
  script:
    - echo run tests in this section

step-deploy-prod:
  stage: deploy
  only:
    - master
  script:
    - sudo apt-get install -y python-pip
    - pip install docker-compose
    - sudo docker image prune -f
    - sudo docker-compose build --no-cache
    - sudo docker-compose up -d

这也在“gitlab-runner 11.5.0”中运行。但我的服务器使用“gitlab-runner 11.6”。我有这个错误:

Running with gitlab-runner 11.5.0 (3afdaba6)
  on docker-auto-scale fa6cab46
Using Docker executor with image docker ...
Starting service docker:dind ...
Pulling docker image docker:dind ...
Using docker image 
sha256:dfd9350d475b431e4b9b037fe31f4f0df70d597688776f3b10 
for docker:dind ...
Waiting for services to be up and running...
Pulling docker image docker ...
Using docker image 
sha256:21df41782cc5884b85b5d32f3d0ec552aaee788ac0a7a36d7d4e4b0 for 
docker ...
Running on runner-fa6cab46-project-10114523-concurrent-0 via runner- 
fa6cab46-srm-1546518230-c1805b24...
Cloning repository...
Cloning into '/builds/marattm/investordatabase'...
Checking out b15507d3 as master...
Skipping Git submodules setup
$ sudo apt-get install -y python-pip
/bin/sh: eval: line 68: sudo: not found
ERROR: Job failed: exit code 127

在这种情况下,我配置的 gitlab ci 不使用我的跑步者。它使用共享跑步者

【问题讨论】:

    标签: continuous-integration gitlab gitlab-ci gitlab-ci-runner


    【解决方案1】:

    使用 gitlab-runner 11.5.0 (3afdaba6) 运行 在 docker-auto-scale 上

    docker-auto-scale 上的 Gitlab runner 是 gitlab.com 提供的公共共享 runner
    转到设置 -> ci/cd -> 运行器 -> 正确的站点都是用它标记列出的共享运行器。

    有两种方法可以避免使用共享运行器。

    a) 进入设置 -> ci/cd -> 运行器 -> 点击“禁用共享运行器”
    b) 给你的跑步者一个独特的标签,并在你所有的工作上使用这个标签。这将确保作业仅在具有此标签的运行器上执行。

    更多信息:
    * https://docs.gitlab.com/ce/ci/yaml/#tags
    * https://docs.gitlab.com/ce/ci/runners/#using-tags

    【讨论】:

    • 如果我禁用共享运行器,当我运行时,出现错误“此作业被卡住,因为该项目没有在线分配任何运行器。”但在配置 CI/CD 中,我的跑步者处于活动状态
    猜你喜欢
    • 1970-01-01
    • 2017-05-31
    • 1970-01-01
    • 2019-07-04
    • 1970-01-01
    • 2022-06-10
    • 2021-11-30
    • 2021-11-23
    • 1970-01-01
    相关资源
    最近更新 更多