GitLab 持续集成到多个分支机构的 运行 个工作

GitLab continuous integration to run jobs in several branches

我的 .gitlab-ci.yml 文件包含以下作业:

job1:
  script: 
    - pwd
  only: 
    - master

使用 only 我将这个虚拟作业 job1 运行 命令 pwd 只有当它被推送到分支 master 时。来自文档:

only and except are two parameters that set a refs policy to limit when jobs are built:

only defines the names of branches and tags for which the job will be built.

现在我想在多个标签上 运行 这个,所以请遵循文档:

only and except allow the use of regular expressions.

我试着说:

job1:
  script: 
    - pwd
  only: 
    - (master|my_test_branch)

但它根本不起作用:在 mastermy_test_branch 中都不起作用。正则表达式有什么问题?

我没有找到任何关于它的文档,但显然 .gitlab-ci.yml 中的正则表达式需要包含在 / / 中。因此,/(master|my_test_branch)/ 有效。

总计:

job1:
  script: 
    - pwd
  only: 
    - /(master|my_test_branch)/

为什么不直接使用多个值(在我看来更具可读性):

only:
    - master
    - my_test_branch