[英]How to except regular expression in gitlab.ci?
I need to exclude branches with the names feature/ussues- from some steps.我需要从某些步骤中排除名称为 feature/ussues- 的分支。 There is a regular expression, but when I set except,rule or only, either the job always was included, or was not included at all.
有一个正则表达式,但是当我设置 except,rule 或 only 时,要么总是包含作业,要么根本不包含作业。
Initially I tried this using rules:
:最初我尝试使用
rules:
::
rules:
- if: $CI_COMMIT_BRANCH =~ '^feature\.*\/.*
when: never
I expected this to match on branches like feature/issues-70
, feature/issues-771
, etc.我希望这与
feature/issues-70
、 feature/issues-771
等分支相匹配。
The regex rule you used is slightly off.您使用的正则表达式规则略有偏差。 First, you need surrounding
/
for the regex pattern.首先,您需要围绕
/
来表示正则表达式模式。 Second, the \.
二、
\.
in the pattern will mean to match a literal .
在模式中将意味着匹配文字
.
character, which is not what you want, based on the branch names you expect to match.根据您希望匹配的分支名称,这不是您想要的字符。 Lastly, you need a matching rule for the job to be created at all (the default case when your rule doesn't match).
最后,您需要一个匹配规则才能创建作业(规则不匹配时的默认情况)。
This should match all the example branch names you provided:这应该与您提供的所有示例分支名称匹配:
rules:
- if: $CI_COMMIT_BRANCH =~ /^feature\/.*/
when: never
- when: on_success # the default when the first rule doesn't match
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.