这就是我的问题:我在一个单独的存储库中有一个GitLab-ci.yml模板,其中包含所有基本的阶段/步骤。在包含实际代码的另一个代码库中,我包含了该模板并覆盖了一个用于单元测试的变量。
下面是基本模板的外观:
---
image: docker:git
variables:
TEST_CMD: unit-test $UNIT_TEST_CMD_OPTIONS
stages:
- pre-build
- build
- test
actual_build:
stage: build
<<: *only-default
script:
- echo "build it"
- ...
....
现在,我将该模板包含到实际的存储库gitlab-ci.yml文件中,以执行整个管道:
---
include:
- project: blahfubar/gitlab-ci-template
ref: master
file: basic.gitlab-ci.yml
variables:
UNIT_TEST_CMD_OPTIONS: --testsuite unit
现在的问题是:我只想在这个存储库中添加一个额外的作业,即在那里执行安全检查,但这不起作用,并且使用"extends:"-keyword只能扩展作业。
---
include:
- project: blahfubar/gitlab-ci-template
ref: master
file: basic.gitlab-ci.yml
variables:
UNIT_TEST_CMD_OPTIONS: --testsuite unit
security-step:
stage: test
script:
- ./security-check
如果我这样做,只会执行"security-step“,而不是所包含的模板中的所有其他步骤。
希望任何人对此有一个解决方案,因为我在gitlab-ci文档中没有找到任何东西。
提前感谢:)
发布于 2021-03-18 18:45:24
如果我理解正确的话,Gitlab中的!reference
关键字可能会对您有所帮助,但可能不能完全解决您的问题:https://docs.gitlab.com/ee/ci/yaml/#reference-tags
您的security-step
可能如下所示:
security-step:
stage: test
script:
- !reference [actual_build, script]
- ./security-check
这将包括安全步骤之前的所有构建脚本行。
https://stackoverflow.com/questions/64785672
复制相似问题