'gitlab-ci.yaml `config contains unknown keys: rules` when trying to use rules

I've pasted the example for rules in my gitlab-ci.yaml (from https://docs.gitlab.com/ee/ci/yaml/#rules):

job:
  script: "echo Hello, Rules!"
  rules:
    - if: '$CI_MERGE_REQUEST_TARGET_BRANCH == "master"'
      when: always
    - if: '$VAR =~ /pattern/'
      when: manual
    - when: on_success

But I get

Error: jobs:job config contains unknown keys: rules

Am I missing something?



Solution 1:[1]

The “rules” were introduced in GitLab 12.3. Check your version. Go to?(question mark next to the account image) / Help. There you will find the version you are currently using.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Simon Slominski