Using conditional includes (exists rules) from an included template does not work.
I have a common CI template that projects consume. It sets up basic build jobs, runner parameters, &c. Now I am trying to use conditional includes based on the presence of a file -- for instance, to add gradle caching to the build job if we detect the project uses gradle based on the presence of a gradle.properties file.
Example:
my-project/.gitlab-ci.yml
include:
- project: ci-templates
file:
- common.yml
ci-templates/common.yml
...
include:
# enable gradle caching if this is a gradle project
- local: cache-gradle.yml
rules:
- exists:
- gradle/wrapper/gradle-wrapper.properties
foo:
script: ["echo foo works"]
rules:
- exists:
- gradle/wrapper/gradle-wrapper.properties
in the above, cache-gradle.yml
is never including, despite gradle/wrapper/gradle-wrapper.properties
existing in the project.
What's super frustrating is that the foo
job does run, and it shares the same rules! Why does the include exists
rule behave differently than the job exists
rule?
Is there a way we can conditionally include behaviuor using exists
from our common template? I saw !75250 (closed) and thought @mwoolf 's idea of referencing a project to include could help but it appears stalled.