It is useful (vital for me) to tell the current branch of plan that is running. I used to use this variable: bamboo.repository.branch.name. But documentation says it is to be deprecated; and anyway, it does not always works. I mean, in some plans, it works fine, in others, it always contains value "master" no matter which branch is running, auto triggered or manually.
I also tried those variables:
bamboo.planRepository.position.branchName
bamboo.planRepository.position.branch
bamboo.planRepository.position.branch
But they always return "master" no matter which plan branch is running.
Ref: https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html
Why do I need to know what branch is running?
When the plan is triggered by a git commit, it should run with source code under the same git branch that contains this commit. It will not make sense, if a plan always run git branch master code, when commits are all happen under feature branches right? Also different branch can have different roles, like release branch will do deployment but other branch doesn't. In your plan config, you need do different things manually according to what branch is being run.
Does this make sense? What is the reliable way to get the current plan branch?