Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab executing next stage even if one fails (with dependency)

I'm setting up a gitlab pipeline with multiple stages and at least two sites each stage. How do iIconditionally allow the next stage to continue even if one site in the first stage failed (and the whole stage as it is marked as failed)? For example: I want to prepare, build and test and I want to do this on Windows & Linux runner. So if my Linux runner failed in preparation but my Windows runner succeeded, then the next stage should start without building the Linux package, because this already failed. But the windows build should start.

My Intention is that if one system fails at least the second is able to continue.

I added dependencies and i thought that this would solve my problem. Because if site "build windows" is dependent on "prepare windows" then it shouldn't matter if "prepare Linux" failed. But this isn't the case :/

image: node:10.6.0

stages:
  - prepare
  - build
  - test

prepare windows:
  stage: prepare
  tags:
    - windows
  script:
    - npm i
    - git submodule foreach 'npm i'

prepare linux:
  stage: prepare
  tags:
    - linux
  script:
    - npm i
    - git submodule foreach 'npm i'

build windows:
  stage: build
  tags:
    - windows
  script:
    - npm run build-PWA
  dependencies:
    - prepare windows

build linux:
  stage: build
  tags:
    - linux
  script:
    - npm run build-PWA
  dependencies:
    - prepare linux

unit windows:
  stage: test
  tags:
    - windows
  script:
    - npm run test
  dependencies:
    - build windows
  artifacts:
    paths:
      - dist/
      - package.json
    expire_in: 5 days

unit linux:
  stage: test
  tags:
    - linux
  script:
    - npm run test
  dependencies:
    - build linux
  artifacts:
    paths:
      - dist/
      - package.json
    expire_in: 5 days
like image 207
VLAmingo Avatar asked Nov 04 '25 04:11

VLAmingo


1 Answers

See allow_failure option:

allow_failure allows a job to fail without impacting the rest of the CI suite.

example:

job1:
  stage: test
  script:
    - execute_script_that_will_fail
  allow_failure: true
like image 76
Amityo Avatar answered Nov 07 '25 14:11

Amityo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!