Add error message for cyclic dependencies in pipeline execution policies
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem
When using pipeline execution policies, it's possible to inadvertently create a cyclic dependency between jobs, leading to a deadlock situation. Currently, this results in jobs being stuck in a 'created' state without any warnings or error messages.
Example scenario
- In the project's
.gitlab-ci.ymlfile:- Stage 1: build
- Stage 2: test
- In the pipeline execution policy:
- Inject a policy with a job in the 'build' stage that needs a job from the 'test' stage
Current behavior
Jobs become stuck in a 'created' state without any warnings or error messages, making it difficult for users to identify and resolve the issue.
Proposed solution
Implement an error message that alerts users when a cyclic dependency is detected between pipeline execution policy jobs and the jobs defined in the GitLab CI YAML. The error should specifically identify when:
- A pipeline execution policy job is defined in a later stage
- That job has a 'needs:' dependency on a job defined in the GitLab CI YAML
- The dependent job is configured to execute in a stage before the stage defined in the policy's job
Expected outcome
Users will receive a clear error message explaining the cyclic dependency, allowing them to quickly identify and resolve the issue in their pipeline configuration.