I want to build a monorepo CI/CD based on Gitlab, I think I’m getting stuck at variable expansion inside the if clause. Is there a work around, or could this be a Feature Request for future implementation?
.deploy-serverless-aws:
stage: deploy
before_script:
- cd services/$WORKDIR/
- sls plugin install -n serverless-python-requirements
- python3 -m pip install pytest
- python3 -m pip install -r requirements.txt
- python3 -m pytest -sq --disable-warnings
script:
- serverless deploy --stage $ENV --region ap-southeast-1
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
changes:
- services/$WORKDIR/
- .gitlab-ci.yml
deploy-app1:
extends: .deploy-serverless-aws
variables:
WORKDIR: app1
To be clear, I can move the rules to deploy-app1 job and remove the variable and it works, I just think it would be more elegant and avoid duplication if the variable can be expanded before evaluating the changes condition.