Gitlab CI - Change branch dynamically I have a nodeJS application which I deploy with Gitlab CI.
When pushing to branch XYZ, the corresponding script runs, let's assume on stage 'dev'. That's working.
So far so good.
Is it possible to select a specific branch so that instead of branch XYZ, e.g. Branch FOO can be deployed on 'dev' without having to change the gitlab-ci.yml file every time?
Instead of hard-coding your branch name in .gitlab-ci.yml use $CI_COMMIT_REF_NAME. There are a bunch of pre-set environment variables you can use to get info about the current job.
The gitlab documentation has a list of them: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html