Gitlab version: 14.7
I am trying to use CI/CD variables in gitlab-ci template.
Requirnemnts:
Add a certain job only when a certain condition met and changes have been made to a directory defined using CI/CD variables.
gitlab-ci file:
#CI/CD variable
PROJECT_DIRECTORY: "**/src/folder/*"
#Rules
.rules:project:build:docker-image:
rules:
- <<: *if-merge-request
changes:
- $PROJECT_DIRECTORY
- when: never
.rules:project:publish:production:
rules:
- <<: *if-push-to-production
changes:
- $PROJECT_DIRECTORY
- when: never
.rules:project:publish:staging:
rules:
- <<: *if-push-to-master
changes:
- $ROJECT_DIRECTORY
- when: never
I used the exact same gitlab ci format but without using CI/CD variables. It works as expected. but with CI/CD variables in rules:changes it’s not working.
gitlab-ci file that works:
.rules:project:build:docker-image:
rules:
- <<: *if-merge-request
changes:
- "**/src/folder/*"
- when: never
.rules:project:publish:production:
rules:
- <<: *if-push-to-production
changes:
- "**/src/folder/*"
- when: never
.rules:project:publish:staging:
rules:
- <<: *if-push-to-master
changes:
- "**/src/folder/*"
- when: never