简体   繁体   English

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

[英]Gitlab runner run my ci deploy in master branch with shared runner

I have remote server ubuntu 16 in digitalocean. 我在digitalocean中有远程服务器ubuntu 16。 Also I install gitlab-runner and configure them and add gitlab-ci-yml file in my project. 另外,我安装gitlab-runner并对其进行配置,并在项目中添加gitlab-ci-yml文件。 Sometimes(1/99) it run correctly, but mostly it doesn't run. 有时(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]

My gitlab-ci-yml 我的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

Also this running in "gitlab-runner 11.5.0". 也可以在“ gitlab-runner 11.5.0”中运行。 But my server use "gitlab-runner 11.6". 但是我的服务器使用“ gitlab-runner 11.6”。 I have this error: 我有这个错误:

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

In this case, gitlab ci not using my runner,that i config. 在这种情况下,gitlab ci不使用我的运行程序,即我配置。 It using shared runner 它使用共享跑步者 在此处输入图片说明

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

Gitlab runner on docker-auto-scale are the public shared runner provided by gitlab.com docker-auto-scale上的Gitlab运行程序是gitlab.com提供的公共共享运行程序
Go to settings -> ci/cd -> runner -> right site are all shared runner listed with it tags. 转到设置-> ci / cd->跑步者->右侧站点,所有共享跑步者都带有它的标签。

There are two methods to avoid using shared runner. 有两种避免使用共享运行器的方法。

a) Go to settings -> ci/cd -> runner -> click "disable shared runners" a)转到设置-> ci / cd->运行器->单击“禁用共享运行器”
b) give your runner a unique tag and use this tag on all your jobs. b)给跑步者一个唯一的标签,并在所有工作中使用该标签。 this will ensure that the job is only executed on the runner which has this tag. 这样可以确保仅在具有此标签的运行器上执行作业。

For more information: 欲获得更多信息:
* https://docs.gitlab.com/ce/ci/yaml/#tags * https://docs.gitlab.com/ce/ci/yaml/#tags
* https://docs.gitlab.com/ce/ci/runners/#using-tags * https://docs.gitlab.com/ce/ci/runners/#using-tags

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM