Skip to content

Instantly share code, notes, and snippets.

@lowenthal-jason
Last active May 25, 2016 18:09
Show Gist options
  • Save lowenthal-jason/5bd4fbc3ea3b2ffee4c25ff391ff0582 to your computer and use it in GitHub Desktop.
Save lowenthal-jason/5bd4fbc3ea3b2ffee4c25ff391ff0582 to your computer and use it in GitHub Desktop.
Bamboo Bulk Deletion of Branches Using jQuery
'use strict';
// Look up all of the branches that contain with 'develop-'
jQuery("a:contains('develop-')").map(function (a) {
var a = this;
// Trim off all of the excess URL cruft to get back just the plan key
return a.href.substring(a.href.indexOf('browse/') + 7, a.href.lastIndexOf('/'));
}).each(function (i, planKey) {
// For each plan key, use the bamboo action chain to delete it using a POST through jQuery ajax.
setTimeout(function () {
jQuery.ajax({
url: 'http://<bamboo-url>/chain/admin/deleteChain!doDelete.action',
method: 'POST',
data: {
buildKey: planKey,
save: 'Confirm'
},
dataType: 'text'
})
}, 1);
});

Usage Of This Script

  1. You must authenticate to your own bamboo server in order to use this. Specifically, the page you must have open with your favorite developer tools will look like
    http://<bamboo-url>/chain/admin/config/configureBranches.action?buildKey=<build-key>
  2. Once you're on this page, you can copy and paste this script into the chrome developer tools, replacing <bamboo-url> with the main URL of your bamboo instance.
  3. Make sure to change the 'develop-' to a string you want to match in bulk, because if you don't have any branches that contain develop- this won't do anything
  4. This only works on active branches. If you want to delete disabled branches instead, change 'develop-' to '.branches > .disabled a'

Referenced Gist

  1. https://gist.github.com/bjyoungblood/5e092d256327d3c4fee2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment