【问题标题】:GitLab continuous integration to run jobs in several branchesGitLab 持续集成以在多个分支中运行作业
【发布时间】:2017-09-12 23:03:21
【问题描述】:

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

job1:
  script: 
    - pwd
  only: 
    - master

使用only 我做这个虚拟工作job1 仅在它被推入分支master 时运行命令pwd。来自文档:

only 和 except 是设置 refs 策略限制的两个参数 何时建立作业:

定义将为其构建作业的分支和标签的名称。

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

onlyexcept 允许使用正则表达式。

我想说:

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

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

【问题讨论】:

    标签: continuous-integration gitlab gitlab-ci


    【解决方案1】:

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

    only:
        - master
        - my_test_branch
    

    【讨论】:

      【解决方案2】:

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

      大家一起:

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

      【讨论】:

        猜你喜欢
        • 2011-08-02
        • 2011-06-24
        • 1970-01-01
        • 2023-03-08
        • 2020-01-29
        • 2019-11-28
        • 2013-07-26
        • 2022-01-14
        • 2014-01-08
        相关资源
        最近更新 更多