gitlab-ci - 在一个 gitlab-ci 中使用多个跑步者
问题描述
我想用 2 个作业运行 CI 管道:
- 作业将使用 docker-runner 启动 docker 映像并在 docker 内运行测试
- 将在 ssh runner 下运行并在远程服务器上拉取代码。
可能吗?
解决方案
是的,这是可能的。你需要:
- 使用所需的执行器(和)注册两个GitLab Runner,每个都有不同的标签(或者,其中至少一个带有构建标签)。
docker
shell
- 在你的, 中为给定的工作声明一个特定的标签。
.gitlab-ci.yml
Shell runner注册:
[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!
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!
.gitlab-ci.yml
buildWithShell:
stage: build
tags:
- shell
script:
- echo 'Building with the shell executor...'
buildWithDocker:
image: alpine:latest
stage: build
tags:
- docker
script:
- echo 'Building with the docker executor...'
推荐阅读
- ruby-on-rails - ransack rails:不适用于使用 *_in 匹配器的空值
- javascript - 如何在ajax调用中获得迭代ID的结果
- colors - Scilab colorbar - 拳头和最后一个颜色更小
- java - 在单例类中添加两个整数值
- webpack - Webpack:如何将 CommonsChunkPlugin (wp3) 迁移到 optimization.splitChunks (wp4)?
- jasper-reports - 如何在显示大小更改时设置为自动调整 Jasper 报告的大小
- node.js - 在 NodeJS 中锁定文件
- php - 如何用 php 代码计算电量?
- python - 如何通过其值获取变量的名称
- apache-kafka - Kafka Exactly once with Transactional Producer