Using `rules:exists` to check if multiple files exists *at the same time*

,

How can I use rules:exists to enable a job only if two files exist at the same time?

I have a job which is only valid if a tree contains both setup.py and sonar-project.properties. I have tried the following (all without success):

Gitlab Version: 13.2.2

First Try

rules:
  - exists:
      - setup.py
      - sonar-project.properties

Problem: Job is also added if only one of the two files exists

Second Try

rules:
  - exists:
      - setup.py
  - exists:
      - sonar-project.properties
  - when: never

Problem: Job is also added if only one of the two files exists

Third Try

rules:
  - exists:
      - "setup.py && sonar-project.properties"

Problem: Does not work at all (it was a desperate try :wink: )

Just for clarification:

  • do you try to create a pipeline template which is to be included by several projects? Then I would define it as template and let the including project extend the job when these files exist.
  • or does this condition exist in some branches of one project but not in others? Then maybe abuse something like the branch name and match that one with pattern.

Unfortunately ANDing “exists” or “changes” is not possible at the moment.

Regarding “changes” keep in mind that jobs might not be triggered if you push multiple commits to a branch and only the first one changed the file actually (I use forced pushed for some usecases).