如何在gitlab-ci.yml的after脚本中添加规则.after_script配置应该是一个包含字符串的数组和字符



如果构建成功,我会尝试创建yml文件,在该文件中构建会调用另一个测试(项目(。因此,我尝试在after_script块中添加一个规则when on_success

before_script:
- echo "Before script section"
- echo "For example you might run an update here or install a build dependency"
- echo "Or perhaps you might print out some debugging details" 
after_script:
when: on_success
script:
- echo "success"
test2:
stage: test
script:
- echo "Hello world"      
deploy:
stage: deploy
script:
- echo "Do your build here"
test1:
stage: test
script:
- exit 1

在这个结果中,我得到了错误GitLab CI configuration is invalid: after_script config should be an array containing strings and arrays of strings

如何以正确的方式实现这个逻辑?

当您将before_script:after_script:放在.gitlab-ci.yml文件的级别顶部时,基本上就是说所有作业(包括test2deploytest(都将运行before_script:after_script:

我尝试创建yml文件,如果构建成功,构建会在其中调用另一个测试(项目(。

在这种情况下,请查看allow_failure:(请参阅:https://docs.gitlab.com/ee/ci/yaml/#allow_failure)。默认情况下,allow_failure:已经是false。我真的无法从您分享的示例.gitlab-ci.yml文件中弄清楚您真正想做什么,但我可以给您举一个快速的例子:

stages:
- build
- test
- deploy
build:
stage: build
script:
- echo build something
test:
stage: test
script:
- echo test something
deploy:
stage: deploy
script:
- echo test something

相关内容

最新更新