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?
Community moderators have prevented the ability to post new answers.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you. Now that I see the frame the pieces are falling into place inside it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The REST resources are very nice, but the hard limit of 25 results makes them less for in-depth investigation or pruning.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.