Raise circular dependencies error when job needs itself
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:
After the fix was implemented, we are raising expected circular dependencies error:
How to set up and validate locally
- Checkout this branch
- 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..."
- See that the error was raised once we try to validate the pipeline.
- To validate the bug in fact existed: Checkout master branch
- 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.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Kasia Misirli