GitlabCi部署在多台服务器上 [英] GitlabCi deploy on multiple servers
问题描述
我使用Gitlab运行程序,并且可以在单个服务器上正常工作. gitlab-ci.yml很简单:
I use Gitlab runner and works fine for a single server. The gitlab-ci.yml is simple:
stages:
- test
- deploy
test:
stage: test
image: php
tags:
- docker
script:
- echo "Run tests..."
deploy:
stage: deploy
tags:
- shell
script:
- sh deploy.sh
就像我说的那样,这对于一台服务器来说很好,但是可以在另一台服务器上部署相同的应用程序?我尝试使用相同的gitlab-runner配置(相同的conf.toml),但是它只是随机更新其中之一.
As i said this is fine for a single server but to deploy same app on another server? I tried with same gitlab-runner config (same conf.toml) but then it was only updating one of them randomly.
是否有不止一个跑步者触发gitlab Ci并根据gitlab-ci.yml部署了所有这些?
Is there somehow gitlab Ci to be triggered by more than 1 runner and deploy all of them according gitlab-ci.yml?
推荐答案
您可以注册来自不同服务器的多个运行程序(例如,标记为 serverA 和 serverB ),并可以进行多次部署作业,每个作业由不同的跑步者执行.这是因为您可以在一个工作中设置多个标签,并且只会使用具有所有标签的跑步者.
You can register several runners (e.g. tagged serverA and serverB) from different servers and have multiple deployment jobs, each of them performed by a different runner. This is because you can set more than one tag in a job and only a runner having all the tags will be used.
stages:
- test
- deploy
test:
stage: test
image: php
tags:
- docker
script:
- echo "Run tests..."
deployA:
stage: deploy
tags:
- shell
- serverA
script:
- sh deploy.sh
deployB:
stage: deploy
tags:
- shell
- serverB
script:
- sh deploy.sh
但是,考虑到其中一个部署作业失败的情况-这最终将导致您在服务器上拥有两个不同版本的代码.根据您的情况,这可能是问题,也可能不是问题.
However, take into account a situation when one of the deployment jobs fails - this would end up in you having two different versions of the code on the servers. Depending on your situation this might or might not be a problem.
这篇关于GitlabCi部署在多台服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!