Skip to content

Add reference to needs for jobs

Derrike Nunn requested to merge derrike/gitlab:fix/add-reference-to-needs into master

What does this MR do and why?

This merge request will fix an issue with the CI Json Schema used for .gitlab-ci.yml files where a false-positive error is shown to the user if they use a !reference tag inside of a needs: block in a job. By referencing the needs of another job, you can build upon what the job you are creating actually needs in combination with the needs of another job.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
image image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Create a GitLab job like the example below in VSCode:

example.gitlab-ci.yml

example-job:
  extends: .deploy:base
  needs:
    - !reference [.deploy:base, needs]
  1. Observe the error on the !reference line
  2. Add in the following command to the top of the file to use the proposed CI.json Json Schema:
# yaml-language-server: $schema=https://gitlab.com/derrike/gitlab/-/raw/fix/add-reference-to-needs/app/assets/javascripts/editor/schema/ci.json

Your file should now look like:

# yaml-language-server: $schema=https://gitlab.com/derrike/gitlab/-/raw/fix/add-reference-to-needs/app/assets/javascripts/editor/schema/ci.json
example-job:
  extends: .deploy:base
  needs:
    - !reference [.deploy:base, needs]
  1. Validate that the error is gone.
Edited by Derrike Nunn

Merge request reports