我想要一个 CI 在不同的生产服务器(服务器 1、服务器 2、服务器 3 等)上部署两个命令(“bash X”和“bash Y”)。
我寻找了多个阶段,但它似乎没有回答我的问题。我真的不在乎它是并行运行还是A之后B运行。(手册部分用于调试)
我不知道该怎么做:我尝试了多个扩展,但它只需要管道中的最后一个(bashB)。
stages:
- get_password
- bashA
- bashB
get_password:
stage: get_password
# Steps
.bashA:
stage: bashA
script:
- lorem ipsum
when: manual
only:
changes:
- script/bashA.sh
.bashB:
stage: bashB
script:
- ipsum loreem
when: manual
only:
changes:
- script/bashB.sh
# SRV1
deploy-srv1:
extends:
- .bashA
- .bashB
variables:
SRV_1: urlsrv1
# SRV2
deploy-srv2:
extends:
- .bashA
- .bashB
variables:
SRV_1: urlsrv2Run Code Online (Sandbox Code Playgroud)
我只是希望能够在 X 服务器上部署 bashA 和 bash B(我只以 2 台服务器为例)。
MrB*_*rta 11
在 GitLab 中使用多个扩展时,某些值不会被合并,而是被覆盖。如果您查看此处的文档:
\n\nhttps://docs.gitlab.com/ee/ci/yaml/#extends
\n\n他们写:
\n\n\n\n\n用于合并的算法是\xe2\x80\x9c最接近的范围wins\xe2\x80\x9d,因此最后一个成员的键将始终隐藏在其他级别上定义的任何内容
\n
您并不是唯一一个希望功能能够合并脚本而不是覆盖它们的人。这是 GitLab 上的一个未解决问题,可以按照您所描述的操作:
\n\nhttps://gitlab.com/gitlab-org/gitlab/issues/16376
\n\n与此同时,仅查看您提供的示例,您可以通过手动将bashA和合并bashB到一项作业中来获得类似您想要的东西:
stages:\n - get_password\n - bash\n\nget_password:\n stage: get_password\n\n# Steps\n\n.bash_both:\n stage: bash\n script:\n - lorem ipsum\n - ipsum loreem\n when: manual\n only:\n changes:\n - script/bashA.sh\n - script/bashB.sh\n\n# SRV1\ndeploy-srv1:\n extends: \n - .bash_both\n variables:\n SRV_1: urlsrv1\n\n# SRV2\ndeploy-srv2:\n extends: \n - .bash_both\n variables:\n SRV_1: urlsrv2\nRun Code Online (Sandbox Code Playgroud)\n