Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,467,691
Community Members
 
Community Events
177
Community Groups

How to determine what branch of plan is running?

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?

1 answer

1 vote

Hi Murphy,

The variable bamboo.repository.branch.name is deprecated but the variables bellow (which you already cited) should do the same job.

bamboo.planRepository.<position>.branchName
bamboo.planRepository.<position>.branch

Please keep in mind that those variables will depend on the repository type used and their order, where there is more than one. The <position> part should be changed accordingly to: 1 (for the first repository in the list), 2 (for the second), and so on).

e.g.
bamboo.planRepository.1.branch

Some questions that might help us moving forward:

  • Can you share the Bamboo version you have?
  • May I also ask you what is the repository type was configured when it returned master for branches?
  • Have you checked the repository branch configured for the branch returning master?

I've run some tests with Bamboo 6.6.2 using Bitbucket repo and all my tests returned the branch as expected.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events