Skip to content

Add updated workflow rules to json schema

What does this MR do and why?

Related to #345352 (closed)

This adds the missing rules:changes and rules:exists definitions under the workflow keyword in the json schema for gitlab-ci.

With this, the user will be able to use workflow:rules:changes and workflow:rules:exists in their .gitlab-ci.yml file without triggering syntax errors from the validator.

More info on how these rules are used in: https://docs.gitlab.com/ee/ci/yaml/#workflow

Screenshots or screen recordings

Before After
Before After

How to set up and validate locally

  1. Enable the schema_linting feature flag. (rails c then Feature.enable(:schema_linting))

  2. Go the the pipeline editor (CI/CD > Editor).

  3. Paste the following content to your .gitlab-ci.yml file:

    workflow:
      rules:
        - if: '$CI_PIPELINE_SOURCE == "schedule"'
          exists:
            - Dockerfile
          changes:
            - Dockerfile
          variables:
            IS_A_FEATURE: "true"
          when: always
  4. There should be no syntax errors from the content. If you try this on the pipeline editor without the MR changes, you'll find syntax errors similar to the screenshots above.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Mireya Andres

Merge request reports