0

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?

1

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

0

each step actually can run on each branch except you limit it with 'only' options. it will be more flexible to you. Please see this documentation section. https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-basic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.