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

Is there a way to list Bamboo branch plans and their source repositories?

Todd Ellner April 1, 2015

We have many code branches and many corresponding Bamboo branch plans. We need to prune them from time to time as their associated STASH repository branch is removed. The Plan Branch Terminator for STASH seems like a fine solution going forward. We have to attack our backlog from the other direction. Doing this by hand through admin/config/editChainBranchDetails.action is impractical. A look through the Bamboo 5.7.2 database schema was ... cryptic. 

Is there any RESTful or other Bamboo API which will list branch plans (all branch plans, all branch plans in a particular project, etc.) along with their associated source repositories?

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 6, 2015

Hello Todd,

The response of a REST call will always contains information about size of whole collection (size attribute) as well as the start-index and max-result.

The number of resources in returned lists is limited to 25, even if you specify max-result to be greater than 25.

# [USERNAME], i.e.: myuser
# [BAMBOO-BASE-URL], i.e.: http://my.bamboo.instance
# [PROJECT-KEY], i.e.: PROJ
# [PLAN-KEY], i.e.: PLAN
# [X], starting from index given 
# [Y], max results
curl -u [USERNAME] -p -H "Content-Type: application/json" -X GET "[BAMBOO-BASE-URL]/rest/api/latest/plan/[PROJECT-KEY]-[PLAN-KEY]/branch?start-index=[X]&max-result=[Y]"

Please, refer to Bamboo REST Resources documentation for further information.

Kind regards,
Rafael P. Sperafico
Atlassian Support

Todd Ellner April 6, 2015

So I would have to start with the first index (would that be zero or one?) and loop through 25 at a time until "size" was reached. That's doable less a corner case or two where size changed during the process.

Todd Ellner April 6, 2015

Thank you. Now that I see the frame the pieces are falling into place inside it.

2 votes
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 2, 2015

Hello Todd,

Thank you for your question.

Bamboo provides two REST API calls for branches:

  • /plan/{projectKey}-{buildKey}/branch
     Provide list of branches for specified plan. Plan might be top level plan (projectKey-planKey) or job plan (projectKey-planKey-jobKey). You can use "enabledOnly" param to filter out disabled branches.

     

    # [USERNAME], i.e.: myuser
    # [BAMBOO-BASE-URL], i.e.: http://my.bamboo.instance
    # [PROJECT-KEY], i.e.: PROJ
    # [PLAN-KEY], i.e.: PLAN
    curl -u [USERNAME] -p -H "Content-Type: application/json" -X GET [BAMBOO-BASE-URL]/rest/api/latest/plan/[PROJECT-KEY]-[PLAN-KEY]/branch
  • /plan/{projectKey}-{buildKey}/vcsBranches
    Provide list of vcs branch names for branches that exist on the default repository of this plan

    # [USERNAME], i.e.: myuser
    # [BAMBOO-BASE-URL], i.e.: http://my.bamboo.instance
    # [PROJECT-KEY], i.e.: PROJ
    # [PLAN-KEY], i.e.: PLAN
    
    curl -u [USERNAME] -p -H "Content-Type: application/json" -X GET [BAMBOO-BASE-URL]/rest/api/latest/plan/[PROJECT-KEY]-[PLAN-KEY]/vcsBranches

In case you are running Bamboo under HTTPS protocol, please run the cURL command as per following:

curl -D- -u [USERNAME] ...

In the above call, you will be prompted to type in the password to the [USERNAME] given, in this case the password for user "myuser". Alternatively, you could call as per following avoiding to be prompted for password:

curl -u [USERNAME]:[PASSWORD] -H "Content-Type: application/json" ...

Please, refer to Bamboo v5.7.x REST API documentation for further information.

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

0 votes
Todd Ellner April 3, 2015

The REST resources are very nice, but the hard limit of 25 results makes them less for in-depth investigation or pruning. 

TAGS
AUG Leaders

Atlassian Community Events