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

Bamboo variable for branch name

Stefan Reuter July 7, 2012

With the new branch support in Bamboo 4.1 a plan can have multiple branches. Looking at https://confluence.atlassian.com/display/BAMBOO/Using+global%2C+plan+or+build-specific+variables however it seems there is no variable that contains the branch name.

Is there a way to access the branch name via variables? I am using the Tomcat Deploy Taks and would like to deploy the application to a different application context depending on the branch name.

7 answers

1 accepted

1 vote
Answer accepted
PiotrA
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 7, 2012

I think there is no one-for-all variable to access the branch name in 4.1 - I think that feature is scheduled for 4.2, but I'm not 100% sure.

However, if you're using for example GitRepository (as your default repository in Bamboo plan), then I think you could utilize GitRepository-specific variable for branch:

https://github.com/atlassian/bamboo-git-plugin/blob/master/src/main/java/com/atlassian/bamboo/plugins/git/GitRepository.java#L709

What repository type are you using?

Stefan Reuter July 7, 2012

Cool thanks, ${bamboo.repository.git.branch} works fine though it doesn't seem to be documented.

Joey Mink July 9, 2012

I'm trying to use this ${bamboo.repository.git.branch} variable in 4.0, but it doesn't seem to work. Are my findings accurate?

1 vote
Joey Mink July 9, 2012

I'm trying to use this ${bamboo.repository.git.branch} variable in 4.0, but it doesn't seem to work. Are my findings accurate?

0 votes
Latha Sama June 25, 2013

Thanks for the info , I am trying to add this ${bamboo.repository.git.branch} in notificationCommontext.ftl . But not working, Can you guys please guide me where to add this variable ?

I want to see branch name in thw notification header in the email. Is it possible in bamboo ?

Thanks in advance

PiotrA
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.
June 25, 2013

Hello Latha,

Hm... I think this is quite different use-case - Bamboo variables aren't auto-expanded in the notification ftls. I think you should raise your problem as a separate question on answers.atlassian.com - here it might become lost.

0 votes
ArmenA
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.
September 4, 2012

Radoslaw,

You are right, my bad. I found this improvement request (https://jira.atlassian.com/browse/BAM-11660) that was implemented in 4.2.

Please let me know if you have any further questions or concerns.

Cheers,
Armen

0 votes
ArmenA
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.
September 4, 2012

The configuration of checking out from SVN repository is different (you just use the branch name in the URL: http://blog.evanweaver.com/2007/08/15/svn-branching-best-practices-in-practice/) from that for Git, and the plan branching feature is not implemented for SVN yet. You can work around it by defining a custom plan variable and use that to get the SVN branch name in your tasks.

Cheers,
Armen

Radek Antoniuk
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.
September 4, 2012

Actually SVN branching is already implemented in version 4.2.

http://blogs.atlassian.com/2012/08/bamboo-4-2-git-branches-jira-issues/

0 votes
ArmenA
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.
September 3, 2012

Hi Radoslaw,

You are right that Bamboo creates new directory for each Bamboo branch and adds an integer to the name starting from 0. However, the best way would be using ${bamboo.repository.git.branch} variable. I tried it in Bamboo version 4.2, and it worked just fine. I have created a new task (https://jira.atlassian.com/browse/BAM-12129) to update the documentation (https://confluence.atlassian.com/display/BAMBOO/Using+global%2C+plan+or+build-specific+variables). If you are using an older version, try to upgrade your Bamboo instance as there are also many improvements and bug fixed in 4.2 related to Bamboo branches.

Cheers,
Armen

Radek Antoniuk
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.
September 3, 2012

Everything would be perfect, but I am using SVN not GIT :-) Will the same bamboo.repository.svn.branch work?

0 votes
Radek Antoniuk
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 18, 2012

Looking at the Artifacts path, bamboo is putting the wars inside $plankey-$planX-$buildNumber

where X looks like the branch number (but not id, just integer counting from 0). Is that correct?

Do branches have their own Plan Key ? or anything else that can be pulled from Bamboo to distinct which branch is being built inside maven pom file?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events