在一个 gitlab-ci 中使用多个跑步者

nik*_*ili 4 gitlab-ci gitlab-ci-runner

我想用 2 个作业运行 CI pipline:

  1. 作业将使用 docker-runner 启动一个 docker 镜像并在 docker 内运行测试
  2. 将在 ssh runner 下运行并在远程服务器上提取代码。

是否可以?

Vít*_*čka 8

是的,这是可能的。你需要:

  1. 使用所需的执行程序(和)注册两个GitLab Runner,每个都有不同的标签(或者,至少其中一个带有构建标签)。dockershell
  2. 在您的, 中为给定的工作声明一个特定的标签.gitlab-ci.yml

壳牌赛跑者注册:

[root@jsc00mca ~]# gitlab-runner register
Running in system-mode.                            

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https://example.com/
Please enter the gitlab-ci token for this runner:
1a2b3c
Please enter the gitlab-ci description for this runner:
[jsc00mca.example.com]: my-shell-runner
Please enter the gitlab-ci tags for this runner (comma separated):
shell
Whether to run untagged builds [true/false]:
[false]: 
Whether to lock the Runner to current project [true/false]:
[true]:
Registering runner... succeeded                     runner=ajgHxcNz
Please enter the executor: virtualbox, docker+machine, kubernetes, docker, shell, ssh, docker-ssh+machine, docker-ssh, parallels:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Run Code Online (Sandbox Code Playgroud)

Docker 跑步者注册:

[root@jsc00mca ~]# gitlab-runner register
Running in system-mode.                            

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https://example.com/
Please enter the gitlab-ci token for this runner:
1a2b3c
Please enter the gitlab-ci description for this runner:
[jsc00mca.example.com]: my-docker-runner
Please enter the gitlab-ci tags for this runner (comma separated):
docker
Whether to run untagged builds [true/false]:
[false]: 
Whether to lock the Runner to current project [true/false]:
[true]:
Registering runner... succeeded                     runner=ajgHxcNz
Please enter the executor: virtualbox, docker+machine, kubernetes, docker, shell, ssh, docker-ssh+machine, docker-ssh, parallels:
docker
Please enter the default Docker image (e.g. ruby:2.1):
alpine:latest
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Run Code Online (Sandbox Code Playgroud)

.gitlab-ci.yml

[root@jsc00mca ~]# gitlab-runner register
Running in system-mode.                            

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https://example.com/
Please enter the gitlab-ci token for this runner:
1a2b3c
Please enter the gitlab-ci description for this runner:
[jsc00mca.example.com]: my-shell-runner
Please enter the gitlab-ci tags for this runner (comma separated):
shell
Whether to run untagged builds [true/false]:
[false]: 
Whether to lock the Runner to current project [true/false]:
[true]:
Registering runner... succeeded                     runner=ajgHxcNz
Please enter the executor: virtualbox, docker+machine, kubernetes, docker, shell, ssh, docker-ssh+machine, docker-ssh, parallels:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Run Code Online (Sandbox Code Playgroud)