我有一个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中没有这样的标记。
您对解决方法或实施方法有任何想法吗?
答案 0 :(得分:2)
另一种方法是在紧急发布的情况下跳过测试。
为此,请遵循Skipping Tests in GitLab CI中的“ Andi Scharfstein”,然后:
也就是说:
public static void loadInBackground(int taskId) {
// create the loading task
BackgroundTask backgroundTask = new BackgroundTask(taskId);
// No need to run in async, as it already in executor
backgroundTask.run();
}
正如您在上面看到的,我们还在模板的except块中包含了变量
.test-template: &test-template stage: tests except: variables: - $CI_COMMIT_MESSAGE =~ /\[skip[ _-]tests?\]/i - $SKIP_TESTS
。
当从GitLab的Web界面手动触发管道时,这很有用。
这是一个示例: