Skip to content

CI : on_failure : specify expected failed stage

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Description

When you set 'on_failure' on 'when' keyword, the job is launched if any previous step fails.

'execute job only when at least one job from prior stages fails.' - Online doc

This issues cover the idea to specify whether or not you want to run this step if any previous step failed or if a step from a specific stage failed.

For example :

stages:
 - build
 - test
 - deploy

#If this one fails
building:
    stage:build
    script: 
      - false

#This one is ran
on_build_failure:
    stage: test
    script: <Stuff on build failure>
    when: on_failure

#This one is not ran
testing:
    stage: test
    script: <run testing>

#This one is ran (AND SHOULD NOT, as i haven't ran my tests)
on_test_failure:
    stage: deploy
    script: <Stuff on test failure>
    when: on_failure

#This one is not ran (Good)
deploying:
    stage: deploy
    script: <deploy>

Proposal

It would be nice to be able to specify which stage failure can trigger the job. For example:

on_test_failure:
    stage: deploy
    script: <Stuff on test failure>
    when: 
      on_failure: test #If any of the 'test' stage job failed, i will run !

Links / references

Documentation blurb

It is necessary to update the online doc if this feature is accepted : Turbo Direct Anchored Super Link

Feature checklist

I am not sure what to put here... I prefer leaving it blank.

Edited by 🤖 GitLab Bot 🤖