Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

check if build is using plan branch

Hey there, I am looking for a way to check if the running build is executed on branch or plan level.  Preferably in powershell script.  Task at hand is to use a plan branch name if build is using a plan branch otherwise it should use the planKey as a folder in output directory.    Since the bamboo.shortPlanName always exists even when the build is using the plan, just checking if the variable is null or empty is not enough.

1 answer

0 votes
Jimmy Seddon Community Leader Dec 04, 2019

Hi @redline18,

You are correct that the bamboo.shortPlanName always exists, but we also know that when it's running as the "main" build instead of a branch, the name is the same name as the build plan where as when it's running as a branch it is the name of the branch. 

So as long as you don't create or use branch names with the same name as your build plan you should be able to do a string comparison to ensure that the bamboo.shortPlanName isn't the same as your plan name.

I hope that helps!


Thanks for the explanation Jimmy, I do think that there should be some kind of boolean variable for that.  Sometimes giving a plan branch same display name as the plan itself is unavoidable if someone outside of devops decides to do that.  It doesn't solve the issue completely because it still vulnerable to the scenario I mentioned earlier.  There is gotta be a better way to determine.  I am surprised bamboo doesn't have a variable for that.  Another solution is to enforce a unique name.


I have found this bit of ps code that supposed to flag if bamboo build is using plan branch or not but I cannot seem to find much information about how this code actually works.


[string]$BambooType = "planbranch",
[string]$RetentionDays = "-7",

Jimmy Seddon Community Leader Dec 05, 2019

Yeah I'm not sure how that is determining if it's a plan branch or not I'm not aware of anything that exposes that to the end user.  However, doing a quick search, this might help you our as well:

If you look at the provided answer, you could instead check against the name of the linked repository branch.  You know for a fact what the branch name is that is set as the main branch for the linked repository which will be the master branch for that plan, nothing can change that, if that name doesn't match the 

Then you know you are running on a plan branch.


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bamboo

Bamboo Data Center 8.1 is now available

G’day Bamboo customers, Bamboo DC 8.1 is now available with it the following features and programs: SAML 2.0, OpenID Connect, and Crowd SSO In order to help admins with a simplified user manage...

166 views 0 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you