Add the ability to define the next job to execute once the current job completes

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

Proposal

Introduce new keyword that allows jobs to declare which downstream jobs depend on them, enabling reverse dependency specification. This solves critical composability challenges when consuming reusable components where the consumer knows their pipeline structure but the component cannot make assumptions about job names or existence.

Current Limitation

Currently, job dependencies in GitLab CI/CD can only be declared in the dependent job using needs or dependencies:

Current approach - dependency declared in job_b

job_a:
  stage: build
  script:
    - build-application

job_b_from_component: 
  stage: test
  dependencies: 
    - job_a  
  script:
    - test-application

job_c_from_component: # applied from component or template
  stage: build
  needs: 
    - job_a  
  script:
    - test-application

The two challenges here is:

  • this locks consumers of the component or template into using the same job name or designing their own. This reduces the reusability or functionality of components/templates.
  • job dependencies definitions are distributed in differenet jobs.

What is needed

job_a:
  stage: build
  next:
    - job_b
    - job_c
  script:
    - build-application

job_b_from_component: 
  stage: test
  script:
    - test-application

job_c_from_component: # applied from component or template
  stage: build 
  script:
    - test-application
Edited by Charl Marais