Add previousStageJobs to JobType
What does this MR do and why?
This MR adds previousStageJobs field to Ci::JobType. This field will be used with the existing needs field to provide a more performant replace to the previousStageJobsOrNeeds field.
This MR also fixes an existing N+1 in the previous_stage_jobs method. This removes the N+1 from both the new previousStageJobs field and from previousStageJobsOrNeeds
Issues: #424255 (closed), #389195 (closed), #422079 (closed)
Screenshots or screen recordings
The above query comes from a pipeline run using this .gitlab-ci.yml:
build:
script: ls
stage: build
test:
script: ls
stage: test
deploy:
script: ls
stage: deploy
How to set up and validate locally
- Run a pipeline using this
.gitlab-ci.yml:build: script: ls stage: build test: script: ls stage: test deploy: script: ls stage: deploy - Make this query in
/-/graphql-explorer{ project(fullPath: PROJECT_FULL_PATH) { pipeline(iid: PIPELINE_IID) { jobs { nodes { name previousStageJobs { nodes { name } } } } } } } - See that you get the result:
{
"data": {
"project": {
"pipeline": {
"jobs": {
"nodes": [
{
"name": "deploy",
"previousStageJobs": {
"nodes": [
{
"name": "test"
}
]
}
},
{
"name": "test",
"previousStageJobs": {
"nodes": [
{
"name": "build"
}
]
}
},
{
"name": "build",
"previousStageJobs": {
"nodes": []
}
}
]
}
}
}
}
}
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 Avielle Wolfe
