我有一个 Gitlab CI/CD 管道,它通常可以正常工作。
我的问题是我的测试需要超过 10 分钟并且它不稳定(YET ..)所以偶尔会随机地在我不关心的小测试中失败。
通常,重试后,它可以工作,但如果我需要紧急部署,我需要再等 10 分钟。
当我们遇到紧急错误时,再多 10 分钟时间就太长了,所以我正在寻找一种即使测试失败也能强制部署的方法。
我有下一个伪 ci yaml 场景,但我找不到方法来完成
stages:
- build
- test
- deploy
setup_and_build:
stage: build
script:
- build.sh
test_branch:
stage: test
script:
- test.sh
deploy:
stage: deploy
script:
- deploy.sh
only:
- master
如果测试阶段失败,我正在寻找一种手动部署的方法。
但如果我添加
when: manual
到部署,然后部署永远不会自动发生。所以像
when: auto_or_manual_on_previous_fail
这样的标志会很棒。目前,Gitlab ci 中没有这样的标志。
您对解决方法或实现方法有什么想法吗?
最佳答案
另一种方法是在紧急释放的情况下跳过测试。
为此,请关注 Skipping Tests in GitLab CI 中的“Andi Scharfstein” , 和:
那是:
.test-template: &test-template
stage: tests
except:
variables:
- $CI_COMMIT_MESSAGE =~ /\[skip[ _-]tests?\]/i
- $SKIP_TESTS
As you can see above, we also included the variable
$SKIP_TESTS
in the except block of the template.
This is helpful when triggering pipelines manually from GitLab’s web interface.
Here’s an example:
关于continuous-integration - Gitlab CI 允许手动操作,当上一阶段失败时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58898370/