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

Access branch display name as a Bamboo variable?

jprice
Contributor
July 28, 2014

In git we name our feature branches "feature/whatever". When displaying branch names, Bamboo turns this into "feature-whatever". I'd like to be able to pass this "display name" into the build to use as part of a version stamp (Maven chokes when you try to pass it a slash since it wants to use the version as part of the path).

I can think of several ways to avoid the problem altogether, but I first wanted to check whether there was simply a variable I was missing that would give me the value I'm looking for.

3 answers

1 accepted

4 votes
Answer accepted
jprice
Contributor
July 28, 2014

${bamboo.shortPlanName} seems to be what I was looking for, although I don't see it listed in the documentation (https://confluence.atlassian.com/display/BAMBOO/Bamboo+variables).

Andy Shinn December 11, 2015

I'm a little disappointed this is an accepted answer. It isn't answering the actual question of "How to get the display name" as a variable.

Tim Crall
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 8, 2016

for whatever weird reason, bamboo.shortPlanName does seem to give the branch name with the "/" replaced by "-" . . . 

mikayil-abdullah July 3, 2019

${planRepository.branchName} gave the actual repository branch name, while ${bamboo.shortPlanName} yields the plan branch name that's displayed on the left-hand side under the branches section.

bamboo-planbranch.JPG

Like wat58794 likes this
Oleg Marchuk
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 21, 2020

now it's broken :(

jodyfanning May 6, 2021

Seems like none of these are correct and now the real variable is broken in 7.2.4.

If I have a branch that is something like Jody/mybranch that is part of a project called project1 with plan plan1 then I get these results

  • bamboo.planRepository.branchDisplayName = Jody/mybranch
  • bamboo.planRepository.1.branchName = Jody/mybranch
  • bamboo.planName = project1 - plan1 - Jody-mybranch
  • bamboo.shortPlanName = plan1

Now I can obviously see in the Bamboo UI that the display name in the list of branches is Jody-mybranch, and that is what it also shows in the bamboo.planName. But I cannot get that as the branchDisplayName.

And as mentioned in the original request, there are tooling that do not like the "/" in names if you use them for things like docker tags. Using the display name from Bamboo is an easy fix since it already changes the "/" to "-". But now it doesn't work.

3 votes
Ron Chan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2014

Not sure how ${bamboo.shortPlanName} gives you the branch name, that's the name of the project or build plan. But I guess if it gets what you wanted.

We obtain the branch name from ${planRepository.branchName} or ${planRepository.branch}.

jprice
Contributor
July 28, 2014

Both of those variables give the "real" branch name containing the slash (feature/whatever, not feature-whatever as displayed by Bamboo). I'm by no means suggesting that behavior is wrong, it's just not what I want in this case.

Boris Vacher
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 15, 2014

I got branch name with ${bamboo.planRepository.branchName}, not ${planRepository.branch}

0 votes
Ron Chan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2014

Understood.

Just a note, the slash "/" can be set to a dash "-" in the branch. That's configured from Stash (Branching model under repository Settings).

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events