1
votes

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
1
Welcome to Stack Overflow. Please don't SHOUT in your posts, use emphasis or bold. You should also switch on the spellchecker for English before posting. - Anthon

1 Answers

2
votes

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