我想使用 variables:
关键字创建一个 gitlab 变量,其中包含要传递给 GitLab dependencies:
关键字的依赖项数组。结构看起来像:
variables:
DEPENDENCY_LIST: ["dependency1", "dependency2", "dependency3"]
dependencies: "$DEPENDENCY_LIST"
但是上面的代码给出了一个 YAML 错误,指出“jobs:source code dependency should be an array of strings”
如何将 GitLab CI 变量的值设置为 .gitlab-ci.yml 作业中的数组?
最佳答案
How do you set a GitLab CI variable to an array in gitlab-ci?
你不能 - 环境变量的格式是名称=值。没有数组。
使用 yaml anchor 。
.dependency_list: &dependency_list
- dependency1
- dependency2
- dependency3
dependencies: *dependency_list
但是 gitlab-ci 不会展平依赖项中的嵌套数组,因此无法合并两个数组。
请参阅 gitlab ci 文档。
关于arrays - 如何将 GitLab CI 变量设置为 gitlab-ci 中的数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68106375/