即使测试失败,Gitlab runner 也不会失败

Gitlab runner does not fail build even tests fails

我正在尝试为我的项目设置 gitlab ci。 我的 gitlab-ci 脚本看起来像:

stages:
  - build

before_script:
  - docker info
  - chmod -R a+x scripts

build:
  stage: build
  script:
    - pwd
    - ./scripts/ci-prepare.sh
    - ./scripts/dotnet-build.sh
    - ./scripts/dotnet-tests.sh
    - ./scripts/dotnet-publish.sh
    - ./scripts/docker-publish-ci.sh

after_script:
  - ./scripts/ci-success.sh

在构建日志中我有以下信息:

Total tests: 6. Passed: 5. Failed: 1. Ommited: 0.

但事件测试失败,构建过程已完成,并显示成功退出代码。 为什么?

我没有配置 allow_failure 选项。

Gitlab CI 检查命令或脚本的 退出代码 以确定它是失败还是成功。

一个成功的命令 returns a 0。所有其他退出代码都被视为错误。

我不知道您使用哪种软件进行测试 - 我认为您应该 return 脚本中的测试退出代码。

我在 bash 脚本中添加了 set -e 并且它工作正常。