3
votes

I'm trying to setup gitlab ci for my project. My gitlab-ci script looks like:

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

In build log I have this information:

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

But event tests fails the build process is finished with success exit code. Why?

I have no configured allow_failure option.

2
What is the exit code of your scripts? Make them return anything <> 0 and ci knows it has failedSascha Frinken

2 Answers

3
votes

I added set -e in bash scripts and it works properly.

1
votes

Gitlab CI checks the exit code of a command or script to decide if it has failed or succeeded.

A successful command returns a 0. All other exit codes are considered as an error.

I don't know what kind of software you are using for your tests - I think you should just return the exit code of your tests in your scripts.