Expose job description keyword in GraphQL
What does this MR do and why?
Adds a nullable jobDescription field to the CiJob GraphQL type. It returns the value of the description keyword from the CI/CD configuration.
!268380 (merged) added the keyword and stores it in the job definition options. No API returns it yet. The job details page needs it, and that page already reads the job through GraphQL.
- The field is not called
description. Commit statuses keep their own value in thedescriptioncolumn, and the commit status API returns it. A field with that name would be easy to confuse with it. - The field returns
nullfor generic commit statuses, for jobs without a description, and for jobs whose job definition is gone after the pipeline is archived. - The job definition is preloaded for the field in
JobsResolver,AllJobsResolver,RunnerJobsResolverandProjectJobsResolver. A list of jobs does not run one query for each job.StageTypealready preloads it. CiJobMinimalAccessdoes not get the field.
The job details page change is a follow-up MR.
I did not add a feature flag. The change only exposes a value that users set themselves.
References
- Related to #16481
- Follows !268380 (merged)
Screenshots or screen recordings
Not applicable. This MR has no UI changes.
How to set up and validate locally
-
Commit a
.gitlab-ci.ymlwith a job description and run the pipeline:rspec: script: echo description: Unit tests for the application -
Open GraphiQL at
http://127.0.0.1:3000/-/graphql-explorerand run the query. Replace the project path with your project:{ project(fullPath: "root/my-project") { pipelines(first: 1) { nodes { jobs { nodes { name jobDescription } } } } } }The
rspecjob returns"Unit tests for the application". Jobs withoutdescriptionreturnnull.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
- Changelog: the commit has a
Changelog: addedtrailer. - Documentation:
doc/api/graphql/reference/objects.mdis regenerated. - Database: no migrations. The query reads the existing job definition, which is preloaded.