Backend: Additional inputs for job:when: to allow for more flexible pipeline execution

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

Proposal

Currently you can specify to "run the job only when all jobs in earlier stages succeed" with on_success (the default value). You can also specify on_failure to "run the job only when at least one job in an earlier stage fails".

There is no way to specify to "run the job only when at least one job in an earlier stage succeeds". Using allow_failure: true with on_success allows some flexibility, but there's scenarios that are not currently covered, especially when needs:-jobs come into play.

The following new inputs for job:when: would allow for greater flexibility:

  • any_success
    • covering the "run the job only when at least one job in an earlier stage succeeds" case
  • on_needed_success
    • similar to how on_success works currently, but only taking needs: jobs into consideration
  • any_needed_success
    • combination of the two above – "run the job only when at least one of the needs: jobs succeeds"

Related issues

Implementing this would likely cover the existing proposal 'needs:' with logical OR. Both this proposal and Allow an arbitrary number of jobs from a list o... (#365781) were thought of as possible solutions to that issue with broader applicability.

Customer demand

A need for this kind of flexibility came up in the following internal tickets from customers:

Edited by 🤖 GitLab Bot 🤖