Hello,
I don’t know if what I encountered is a bug or is me just not using it properly.
Problem to solve
I have been using rules:if:exists
to run a specific job if any files exists in a specific directory (subdirectories included). In other words, run a specific job if the parent directory exists.
This is how I’ve been using it so far:
job:
rules:
- if: '$SOMEVARIABLE == "TRUE"'
exists:
- directory/**
However, if I don’t have any file in directory
but I have one in directory/sub
the job doesn’t trigger.
I have to add a rules: directory/**/**
to include subdirectories and make it work.
I thought that **
was used to wildcard recursively and that directory/**
was matching any file in directory and in directory’s subdirectories.
I don’t know if it’s intended to work that way or not. I’ve searched the gitlab forum, without any luck. I’ve also read the documentation about rules:if:exists
and it doesn’t describe my case where I’m not searching for any file in particular but rather for a directory existence.
How to achieve my goal in a better way? Or is it a bug and the wildcard isn’t working as intended?
Versions
GitLab Self-hosted Runners: 17.4.1
GitLab Free 17.6.1