Skip to content

Fix CI ref commit variables not accessible in YAML Linter

Rajendra Kadam requested to merge 441771-ref-name-include into master

What does this MR do and why?

As per #441771 (closed), the pipeline editor threw error in case someone used $CI_COMMIT_REF_NAME in their include configuration. Although the pipeline runs successfully, we should not error out on the editor.

This MR fixes this issue, by passing the ref name of the current project and sha while creating the pipeline so that it can be read in the context while pipeline is validated.

Rest of the logic stays same. The pipeline still runs successfully.

Check this comment for a demo video - #441771 (comment 1839597896)

Note: These changes are behind the feature flag project_ref_name_in_pipeline (#454773 (closed)).

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

How to set up and validate locally

  1. This needs a runner setup in your local.
  2. Setup runner using docker setup.
  3. Use the following CI yaml content -
include:
  - project: 'flightjs/Flight'
    ref: ${CI_COMMIT_REF_NAME}
    file: '.gitlab-ci.yml'


show-parent-variable:
  stage : .pre
  script:
    - echo I am running a variable ${CI_COMMIT_REF_NAME}
  1. Make sure the ref name of current project is used in other project or else it will error out.
  2. YAML content should be included and run in the pipeline as per job definitions.
Edited by Furkan Ayhan

Merge request reports