Deployment 使用GitLab CI使发布分支的部署作业自动,使其他分支的部署作业手动
下一个解决方案应该可行Deployment 使用GitLab CI使发布分支的部署作业自动,使其他分支的部署作业手动,deployment,yaml,gitlab-ci,Deployment,Yaml,Gitlab Ci,下一个解决方案应该可行 deploy_release: stage: deploy tags: - linux only: - master - stable retry: 2 script: - do_action 1 - do_action 2 - git push artifacts deploy_manual: stage: deploy tags: - linux except: - master - stabl
deploy_release:
stage: deploy
tags:
- linux
only:
- master
- stable
retry: 2
script:
- do_action 1
- do_action 2
- git push artifacts
deploy_manual:
stage: deploy
tags:
- linux
except:
- master
- stable
when: manual
retry: 2
script:
- do_action 1
- do_action 2
- git push artifacts
但它有一个☝️ 显著缺失–脚本:
重复2次
我认为写这样的东西是个好主意:
但我怀疑这会起作用是否可以在YAML中执行类似操作?
另一个直截了当的想法是 将
script:
移动到单独的文件deploy\u script.sh
在萌芽状态下解决问题 多亏了这次问答
解决办法是:
更好的是:
继承.deploy\u base
:
.deploy\u base:&deploy\u base
阶段:部署
标签:
-DlpcsCore
-linux
重试:2
变量:
网址:'git@gitlab.com:Yahoo/HeavenShine bin.git'
脚本:&部署\u脚本
-你做什么
-行动2
部署发布:
给你
在GitLab 11.3中引入
extends
定义使用extends的作业将从中继承的条目名称。
扩展了
,作为使用YAML锚点的替代,YAML锚点更灵活、可读性更强
.tests:
only:
refs:
- branches
rspec:
extends: .tests
script: rake rspec
stage: test
only:
variables:
- $RSPEC
Gitlab现在通过规则指令支持此功能:
.deploy_base: &deploy_base
stage: deploy
tags:
- linux
retry: 2
script: &deploy_script
- do_action 1
- do_action 2
- git push artifacts
deploy_release:
only: &deploy_release_only
- master
- stable
script: *deploy_script
deploy_manual:
except: *deploy_release_only
when: manual
script: *deploy_script
.deploy_base: &deploy_base
stage: deploy
tags:
- DlpcsCore
- linux
retry: 2
variables:
URL: 'git@gitlab.com:Yahoo/HeavenShine-bin.git'
script: &deploy_script
- do_act_1
- do_action_2
deploy_release:
<< : *deploy_base
only: &deploy_release_only
- master
- stable
- CI
#- /^master[-_].+$/
#- /^(.+)[+]bin$/
deploy_manual:
<< : *deploy_base
except: *deploy_release_only
when: manual
.tests:
only:
refs:
- branches
rspec:
extends: .tests
script: rake rspec
stage: test
only:
variables:
- $RSPEC