We have 2 environments (development, production). Per default we deploy to production but if the branch name or the commit message start with dev we deploy to development environment.
I create variables (app_url and app_url_dev) via gitlab GUI : (Project => Settings => CI/CD => Variables)
I use gitlab rule to change the app_url variable of deployement. The script deploy.py (and many other scripts) are using app_url variable.
The gitlab-ci code is:
Tags:
stage: Deploy code
rules:
# - if: $CI_COMMIT_REF_NAME == "main" && $CI_COMMIT_MESSAGE =~ /^dev/
- if: $CI_COMMIT_REF_NAME == "main" && $CI_COMMIT_BRANCH =~ /^dev/
variables:
app_url: $app_url_dev
script:
- Python deploy.py
The problem is that i never get the value of app_url_dev in app_url. I tried other combinaison but i always get the production url and not the dev one:
app_url: ${app_url_dev}
app_url: app_url_dev
But i get always the app_url and not the app_url_dev. Anyone can help please ?