Backend: Support variables in rules:exists
Update 2023-10-18:
There is a known issue with using variable expansion in rules:exists
when using folders (addressed in #417251 (closed)).
The recommended workaround is to break the subfolders out of the original variable, as shown in the example below:
variables:
DIR: "folder"
FILE: "flag"
FULL_PATH: ".folder/flag"
a:
rules:
- exists:
- $FULL_PATH. # this doesn't work job a is not added to the pipeline
image: alpine:latest
script:
- echo hi
b:
rules:
- exists:
- $DIR/$FILE. # this works job b is added to the pipeline
image: alpine:latest
script:
- echo hi
Orignial Description
This is a companion to #34272 (comment 423079375) in order to support rules:exits
Release notes
The longer your gitlab-ci.yml
scripts are, the more difficult they are to maintain and scale. By adding support for environment variables in the rules: exists
keyword, you can now use variables for paths or filenames without making your CI file overly verbose. Variables help you reduce your configuration file's overall length when running the same CI jobs to test changes in different file sets.
Problem to solve
I have some CI jobs which run the same steps on different files. GitLab does not currently evaluate variables in rules:exists
.
Example
rule_exist_job:
stage: rule-exist
script: echo "it works!"
rules:
exists:
- $EXIST_PATH
Proposal
Support variable use in the rules:exists
clause