如何配置gitlab CI作业仅在受保护的分支上运行? [英] How do I configure gitlab CI jobs to run on protected branches only?
本文介绍了如何配置gitlab CI作业仅在受保护的分支上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将gitlab CI作业配置为仅在受限分支上运行,但是我找不到only
指令来执行此操作.
I am trying to configure a gitlab CI job to run only on the restricted branches, but I cannot find an only
directive to do this.
推荐答案
在Gitlab 11.11中,您可以通过访问环境变量CI_COMMIT_REF_PROTECTED
In Gitlab 11.11 you can check this accessing the environment variable CI_COMMIT_REF_PROTECTED
only:
variables:
- $CI_COMMIT_REF_PROTECTED
参考:
- https://docs.gitlab.com/ee/ci/variables /predefined_variables.html
- https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-高级
- https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
- https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-advanced
这篇关于如何配置gitlab CI作业仅在受保护的分支上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文