【发布时间】:2018-04-20 11:47:50
【问题描述】:
我们有一个包含重复部分的 gitlab-ci yaml 文件。
test:client:
before_script:
- node -v
- yarn install
cache:
untracked: true
key: client
paths:
- node_modules/
script:
- npm test
build:client:
before_script:
- node -v
- yarn install
cache:
untracked: true
key: client
paths:
- node_modules/
policy: pull
script:
- npm build
我想知道,通过合并语法,我是否可以提取公共部分以在这两个部分的上下文中有效地重用它。
.node_install_common: &node_install_common
before_script:
- node -v
- yarn install
cache:
untracked: true
key: client
paths:
- node_modules/
但真正的问题是:我必须在哪个缩进级别合并块以确保策略:拉取应用于缓存部分。我试图这样做:
test:client:
<<: *node_install_common
script:
- npm test
test:build:
<<: *node_install_common
policy: pull
script:
- npm build
但我收到一个无效的 yaml 错误。如何缩进以获得正确的合并行为?
【问题讨论】:
标签: yaml