Add conditions to rules array merged with !reference

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Hello.

This is a proposal after some discussions on the forum.

Proposal

In #322992 (closed), closed by !67922 (merged), we have the possibility to merge rules directly with !reference since Gitlab 14.3, for example:

.on-branch:
  rules:
    - if: $CI_COMMIT_BRANCH
      when: on_success

job1:
  script: echo "test"
  rules:
    - !reference [.on-branch, rules]

Now, I would like to add more conditions to the passing rule to check if some file changes or exists, for example, I want the following:

.on-branch:
  rules:
    - if: $CI_COMMIT_BRANCH
      when: on_success

job1:
  script: echo "test"
  rules:
    - !reference [.on-branch, rules]
      exists:
        - Dockerfile
Edited by 🤖 GitLab Bot 🤖