continuous-integration - Gitlab CI 允许手动操作,当上一阶段失败时

标签 continuous-integration gitlab gitlab-ci

我有一个 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:



    https://www.cqse.eu/en/blog/skipping-tests-gitlab-ci/skip_tests.png

    关于continuous-integration - Gitlab CI 允许手动操作,当上一阶段失败时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58898370/

    相关文章:

    git - Travis-CI:将不同的分支部署到不同的服务器

    google-chrome - 在不跨步骤共享的云构建步骤中安装 google-chrome(使用卷)

    git - 将现有的本地 Git Master Repo 导入 Gitlab : Git user Access Issues

    docker - 如何在Gitlab Runner上将卷装载到Docker镜像上? (gitlab-ci.yml)

    kubernetes - Helm 图表最佳实践 : latest tag or not

    git - Jenkins git 克隆到工作区的子目录中

    ruby-on-rails - Gitlab 与 openid 连接的集成

    docker - 我的管道不允许我通过 golang 连接,尽管它可以在开发环境中工作

    performance - GitLab CI 加速

    git - 如何使用 GitLab CI/CD 获取整个存储库?