Gitlab运行程序与共享运行程序在master分支中运行我的ci部署

时间:2019-01-04 10:58:34

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

我在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不使用我的运行程序,即我配置的程序。它使用共享跑步者 enter image description here

1 个答案:

答案 0 :(得分:1)

  

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

docker-auto-scale上的Gitlab运行程序是gitlab.com提供的公共共享运行程序
转到设置-> ci / cd->跑步者->右侧站点,所有共享的跑步者均带有其标签。

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

a)转到设置-> ci / cd->运行器->单击“禁用共享运行器”
b)给跑步者一个唯一的标签,并在所有工作中使用该标签。这样可以确保仅在具有此标记的运行器上执行作业。

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