Get the release from the branch name

Hello! I want to run my CI/CD only on MR to release branches (for example, “release/1.0.0)”. My question is it possible to get the version from the branch name (1.0.0) and set to to env variable? I would like to use it in my flow and update a version of my app automatically.

Thank you.

Hi @sshvaika the branch name is stored on the environment variable $SEMAPHORE_GIT_BRANCH. If your branch name contains the version string, you could extract it from this variable.


All the environment variables are listed here: Environment variables - Semaphore

If you have a separate deployment pipeline, you can autostart it with a promotion with a condition like this:

result = 'passed' and branch =~ '^release/'

That way you only start the deployment jobs on branches starting with “release”.

Does this help? Let me know if you have any questions