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 the description column, and the commit status API returns it. A field with that name would be easy to confuse with it.
  • The field returns null for 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, RunnerJobsResolver and ProjectJobsResolver. A list of jobs does not run one query for each job. StageType already preloads it.
  • CiJobMinimalAccess does 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

Screenshots or screen recordings

Not applicable. This MR has no UI changes.

How to set up and validate locally

  1. Commit a .gitlab-ci.yml with a job description and run the pipeline:

    rspec:
      script: echo
      description: Unit tests for the application
  2. Open GraphiQL at http://127.0.0.1:3000/-/graphql-explorer and run the query. Replace the project path with your project:

    {
      project(fullPath: "root/my-project") {
        pipelines(first: 1) {
          nodes {
            jobs {
              nodes {
                name
                jobDescription
              }
            }
          }
        }
      }
    }

    The rspec job returns "Unit tests for the application". Jobs without description return null.

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: added trailer.
  • Documentation: doc/api/graphql/reference/objects.md is regenerated.
  • Database: no migrations. The query reads the existing job definition, which is preloaded.
Edited by Marius Bobin

Merge request reports

Loading
Loading