Skip to content

Raise circular dependencies error when job needs itself

Kasia Misirli requested to merge 354012/Fix_circular_self_in_needs into master

What does this MR do and why?

This MR is addressing a bug described in the following parent issue. It was possible to create jobs with needs where the needed job was the job itself. This fix is preventing such cases by raising following error: The pipeline has circular dependencies

Screenshots or screen recordings

Given the below job:

linux:rspec:
  parallel:
    matrix:
      - STACK: app1
        PROVIDER: aws
  needs:
    - job: linux:rspec
      parallel:
        matrix:
          - STACK: app1
            PROVIDER: aws
  script: echo "Running rspec on linux..."

Before the fix was implemented, the pipeline was showing as valid: Screenshot_2023-10-20_at_12.37.42 After the fix was implemented, we are raising expected circular dependencies error: Screenshot_2023-10-20_at_12.44.39

How to set up and validate locally

  1. Checkout this branch
  2. Add the below job to your .gitlab-ci.yml file
linux:rspec:
  parallel:
    matrix:
      - STACK: app1
        PROVIDER: aws
  stage: test
  needs:
    - job: linux:rspec
      parallel:
        matrix:
          - STACK: app1
            PROVIDER: aws
  script: echo "Running rspec on linux..."
  1. See that the error was raised once we try to validate the pipeline.
  2. To validate the bug in fact existed: Checkout master branch
  3. Paste the same job as above and verify that there is no error raised.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Kasia Misirli

Merge request reports