Using !reference in rules


I am testing with using !reference in rules.

    - if: '$GITLAB_CI == "true"'
    - echo hi

    - !reference [source, rules]
    - echo hi

With the above config I get the following error.

This GitLab CI configuration is invalid: jobs:test rules should be an array of hashes.

I’m not sure if this is a bug in the docs (it doesn’t say where !reference can/can’t be used) or a bug in the !reference for rules itself.

Rules are one of the places I find a lot of duplication, but always with some variation.
This means the !reference option is of great value.

I have mentioned this topic in this issue: CI rules parameter hard to generalize across jobs (#35093) · Issues · / GitLab · GitLab

Feel free to leave a comment in the issues if you think its related and would help you.