Cobination of keyword rules: exists, when: never - does not work as expected in stage

Hello GitLab community,

this is my first post here and like probably most of you who make the first post I have a question. I hope I can return your help on occasion.

After reading `.gitlab-ci.yml` keyword reference | GitLab I expected a certain stage not to be executed, when a .NORELEASE file is existent, which is created at an earlier stage and made accessible with the keyword artifacts.

→ Version determination stage

[do something that creates a .VERSION and a .NORELEASE file if the version should not be released]
 artifacts:
    paths:
      - .VERSION
      - .NORELEASE

→ deployment stage

 rules:
    - exists: 
      - .NORELEASE
      when : never
    - if: $CI_COMMIT_BRANCH == "develop"
      when : manual

As I ran it the first time the job was able to be executed manually. I thought, that the .NORELEASE file is not existent for any reason and added a section to the scripts keyword as follows:

script:
    - test -f .NORELEASE && echo ".NORELEASE file detected, container deployment will be aborted." && exit 0

The output of the next run showed the following line:

$ test -f .NORELEASE && echo ".NORELEASE file detected, container deployment will be aborted." && exit 0
.NORELEASE file detected, container deployment will be aborted.
Running after_script

So at least when the scripts section is executed, the .NORELEASE file is there.

My question is: where am I doing wrong here? I see two possible reasons:

  1. The way I’m using the exists - when : never rule is wrong and I misunderstood what was meant by the phrase: “The job is not added to the pipeline: - If a rule matches and has when: never.”
  2. The .NORELEASE file is available in the scripts section, but for some reason I don’t understand it is not yet available when the rules are evaluated.

Forgive me if this question is possibly obvious to an experienced user, but unfortunately I am far from being one. So thank you for any advice.

Regards,
Martin