【问题标题】:Is it possible to set a top-level only/except in a .gitlab-ci.yml file?是否可以在 .gitlab-ci.yml 文件中设置仅顶级/除外?
【发布时间】:2018-01-27 10:42:06
【问题描述】:

我的 CI 文件中有三个阶段,它们都只有/除了这样:

test:
  only:
    - tags
  except:
    - branches
  script:
    - npm run test

在三个地方有唯一/例外似乎是多余的。有没有办法在脚本配置的顶层设置它?在docs 中看不到类似的内容。

【问题讨论】:

    标签: build continuous-integration gitlab


    【解决方案1】:

    您可以使用地图合并功能:https://docs.gitlab.com/ee/ci/yaml/#special-yaml-features

    .job_template: &job_definition
      only:
        - tags
      except:
        - branches
    
    test1:
        <<: *job_definition
        script:
          - npm run test
    
    test2:
        <<: *job_definition
        script:
          - # ...
    

    【讨论】:

    • 惊人的功能!
    猜你喜欢
    • 2022-04-12
    • 1970-01-01
    • 1970-01-01
    • 2021-11-13
    • 1970-01-01
    • 2018-07-09
    • 1970-01-01
    • 2016-07-16
    • 1970-01-01
    相关资源
    最近更新 更多