GraphQL method previousStageJobsOrNeeds returns empty value if there are no jobs in previous stage
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
We want to use graphQL functionality for building pipeline dependencies graph.
Analogically, like you use it in pipeline job dependencies. But we met a weird bug.
If there is stage without jobs, between two jobs in another stages (before and after empty stage), then graphQL returns empty previousStageJobsOrNeeds.
Steps to reproduce
- Create CI/CD configuration
stages:
- stage1
- empty1
- stage2
- empty2
- stage3
job0:
stage: .pre
script: echo test
job1:
stage: stage1
script: echo test
needs: []
job2:
stage: stage2
script: echo test
job3:
stage: stage3
script: echo test
- Go to graphql-explorer and run:
{
project(fullPath: "madest92/empty-needs") { # replace to your project name
pipeline(iid: "1") { # replace to your pipeline IID
jobs {
nodes {
name
stage {
name
}
needs {
nodes {
... on CiBuildNeed { iid:id, name }
}
}
previousStageJobsOrNeeds{
nodes {
__typename
... on CiBuildNeed { iid:id, name }
... on CiJob { id, name }
}
}
}
}
}
}
}
Example Project
https://gitlab.com/madest92/empty-needs/-/pipelines/946376722
What is the current bug behavior?
We see empty previousStageJobsOrNeeds for all jobs. Because of previous stage empty1, empty2, which actually has no jobs.
There is another feature in graphQL: CiJob.needs, but it doesn't allow to understand:
- Job has no needs
- Job doesn't depend on another jobs
CiJob.needs would be empty for job1 and job0.
What is the expected correct behavior?
We expect, that in graphQL job3 depends on job2 and job2 depends on job1
If we remove empty stage and keep only these:
stages:
- stage1
- stage2
- stage3
It works as should.
Output of checks
This bug happens on GitLab.com


