我用脚本为gitlab创建模板。
.test-script: &test
- echo "hello"如何在.gitlab-ci.yml中使用这个脚本?我试过像这样
include: '/templates/test-template.yml'
example-stage:
script:
- *test“此GitLab CI配置无效:未知别名:测试”发生错误。因为合并的YAML中没有此脚本的别名。
GitLab版本: GitLab社区版14.6.0
发布于 2022-07-04 15:11:02
为什么不使用GitLab的扩展或引用关键字?
---
include:
- local: '/templates/test-template.yml'
example-stage:
script:
- !reference [.test-script, script]或
---
include:
- local: '/templates/test-template.yml'
example-stage:
extends: .test-script发布于 2022-06-30 09:11:12
也许您可以尝试使用以下语法:
.test-script: &test-script
script:
- echo "hello"对于你的例子阶段工作:
example-stage:
<<: *test-scripthttps://stackoverflow.com/questions/72802141
复制相似问题