我有一个像这样的管道设置的应用程序:
图A
使用这样的.gitlab-ci.yml
文件
stages:
- test
- deploy
test:
script:
- bash run_tests.sh
deploy_staging:
stage: deploy
script:
- rsync -rltvz --delete -e ssh --exclude=.git* public/ user@staging_node:/path/to/directory
environment:
name: staging
url: https://staging.app.example.com
only:
- master
deploy_production:
stage: deploy
script:
- rsync -rltvz --delete -e ssh --exclude=.git* public/ user@production_node1:/path/to/directory
- rsync -rltvz --delete -e ssh --exclude=.git* public/ user@production_node2:/path/to/directory
environment:
name: production
url: https://app.example.com
when: manual
only:
- master
我有另外一个我想要部署的应用程序,但我想使用并行作业,如下所示:
图B
在图A中,deploy_production
是一个手动步骤(例如rsync到多个服务器节点的目录);在图B中,部署到deploy_node1
和deploy_node2
只需一步(例如比rsync更多的时钟密集时间),通过Gitlab UI手动触发。
如何配置.gitlab-ci.yml
并行运行部署作业,同时仍保持一键式手动部署?
更新(回应Jakub Kania的回答):
这是你的想法,Jakub?
尝试使用触发器,引导我走向.gitlab-ci.yml
:
stages:
- test
- stage
- deploy
test:
script:
- bash run_tests.sh
staging:
stage: stage
script:
- rsync -rltvz --delete -e ssh --exclude=.git* public/ user@staging_node:/path/to/directory
environment:
name: staging
url: https://staging.app.example.com
only:
- master
except:
- triggers
deploy_trigger:
stage: deploy
script:
- "curl -X POST -F token=TOKEN -F ref=master https://gitlab.example.com/api/v4/projects/1234/trigger/pipeline"
environment:
name: production
url: https://app.example.com
only:
- master
except:
- triggers
when: manual
deploy_node1:
stage: deploy
script:
- rsync -rltvz --delete -e ssh --exclude=.git* public/ user@production_node1:/path/to/directory
environment:
name: production
url: https://app.example.com
only:
- master
- triggers
deploy_node2:
stage: deploy
script:
- rsync -rltvz --delete -e ssh --exclude=.git* public/ user@production_node2:/path/to/directory
environment:
name: production
url: https://app.example.com
only:
- master
- triggers