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

How to identify the default branch for a given build key?

I'm working on a CI system that uses the current git branch to look up a build key and start a build in Bamboo.

So far, I'm using the /plan/{projectKey}-{buildKey}/branch endpoint to get all the branches and their keys to look up the key for the branch I'm trying to build. The problem is that the default branch doesn't appear in this list.

For example, if I have project key PK and build key BK, I call /plan/PK-BK/branch and get something like this back (leaving out a bunch of keys):

"branches": {
"branch": [{
"shortName": "my-feature-branch",
"key": "PK-BK123"
}, {
"shortName": "second-feature-branch",
"key": "PK-BK234"

If my CI server is trying to build my-feature-branch or second-feature-branch, this works fine.

But there's nothing I can find that maps the default branch name - the one I see if I just navigate to /browse/PK-BK in the UI - to the PK-BK build key. Nor have I found anything that goes the other way: knowing that PK-BK is the default, look up what branch name that is. I can't hard code the branch name ("if the current branch is develop, use the root build key") because I want this to work in multiple repos that might have different default branches.

Is there something in the API that can give me this info, or is there a better strategy entirely for mapping from git branch to build key?

0 answers

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...

162 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