Hi,
I’m trying to setup a dynamic gitlab-ci file that includes the needed gitlab-ci file based on a project variable.
Unfortunately I can’t seem to get this to work, i’ve read the documentation and searched the forum but unfortunately I can’t find any solutions.
Essentially I wanted to do something like the snippet below but I noticed I couldn’t use variables in the file method ( Returns “Invalid config: File does not exist”. ).
include:
- project: 'tools/gitlab-ci'
file: '/gitlab-ci-$GITLABFILE.yml'
only:
- $GITLABFILE
include:
- project: 'tools/gitlab-ci'
file: '/gitlab-ci.yml'
only:
- $GITLABFILE == null
Since I couldn’t use a variable in the file method i tried the below config but unfortunately it always loads the last file and ignores the only keyword.
include:
- project: 'tools/gitlab-ci'
file: '/gitlab-ci.yml'
except:
variables:
- $GITLABFILE
- project: 'tools/gitlab-ci'
file: '/gitlab-ci-legacy.yml'
only:
variables:
- $GITLABFILE == 'legacy'
- project: 'tools/gitlab-ci'
file: '/gitlab-ci-legacy-nobuild.yml'
only:
variables:
- $GITLABFILE == 'legacy-nobuild'
What is the appropriate way of achieving a dynamic gitlab-ci is it even possible ?
Any help and/or suggestions are appreciated.