【发布时间】:2021-03-22 19:10:13
【问题描述】:
为了改进我的 Gitlab CI 文件的结构,我包含了一些特定的文件,例如
include:
- '/ci/config/linux.yml'
- '/ci/config/windows.yml'
# ... more includes
为了避免路径的容易出错的冗余,我想把它放入一个变量中,比如:
variables:
CI_CONFIG_DIR: '/ci/config'
include:
- '${CI_CONFIG_DIR}/linux.yml' # ERROR: "Local file `${CI_CONFIG_DIR}/linux.yml` does not exist!"
- '${CI_CONFIG_DIR}/windows.yml'
# ... more includes
但是这不起作用。 Gitlab CI 声称${CI_CONFIG_DIR}/linux.yml 不存在,尽管文档说包含路径中的变量是允许的,请参阅https://docs.gitlab.com/ee/ci/variables/where_variables_can_be_used.html#gitlab-ciyml-file。
同样不起作用的是包含一个文件 /ci/config/main.yml 并从中包含没有路径的特定配置:
# /ci/config/main.yml
include:
- 'linux.yml' # ERROR: "Local file `linux.yml` does not exist!"
- 'windows.yml'
# ... more includes
我怎样才能完成这项工作,或者是否有替代方法可以只在一个地方定义路径而不会使其过于复杂?
【问题讨论】:
标签: continuous-integration gitlab include gitlab-ci