Skip to content

Instantly share code, notes, and snippets.

@ponchofiesta
Last active September 16, 2021 09:58
Show Gist options
  • Save ponchofiesta/499db92149f6193f7923af577f87dfcc to your computer and use it in GitHub Desktop.
Save ponchofiesta/499db92149f6193f7923af577f87dfcc to your computer and use it in GitHub Desktop.
Delete Bamboo plan Branch
/*
This Code can delete a Bamboo plan branch via a web browser. See the minified version down below to be used as browser bookmark.
*/
(function(){
url = new URL(location.href)
params = new URLSearchParams(url.search)
if (!params.has('planKey')) {
alert('Browser is not on correct page.')
return
}
const base_link = document.querySelector('#logo > a')
const base_url = base_link.href
const branch_key = params.get('planKey')
if (!confirm(`Do you really want to delete plan branch with key '${branch_key}'?`)) {
return
}
const data = `buildKey=${branch_key}`
fetch(`${base_url}/ajax/deleteChain.action`, {
method: 'POST',
cache: 'no-cache',
headers: {
'X-Atlassian-Token': 'no-check',
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json'
},
body: data
})
.then(response => {
if (!response.ok) {
throw new Error('Delete branch failed for unknown reason.')
}
const default_plan_link = document.getElementById('breadcrumb:planConfiguration')
if (default_plan_link) {
location.href = default_plan_link.href
} else {
alert('Plan branch deleted successfully.')
}
})
.catch(error => alert('Could not delete plan branch: ' + error))
})()
/*
To delete a plan branch in Bamboo do this once:
- Create a bookmark in your browser
- Add this as address:
*/
javascript:!function(){if(url=new URL(location.href),params=new URLSearchParams(url.search),!params.has("planKey"))return void alert("Browser is not on correct page.");const e=document.querySelector("#logo > a").href,a=params.get("planKey");confirm(`Do you really want to delete plan branch with key '${a}'?`)&&fetch(`${e}/ajax/deleteChain.action`,{method:"POST",cache:"no-cache",headers:{"X-Atlassian-Token":"no-check","Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:`buildKey=${a}`}).then(e=>{if(!e.ok)throw new Error("Delete branch failed for unknown reason.");const a=document.getElementById("breadcrumb:planConfiguration");a?location.href=a.href:alert("Plan branch deleted successfully.")}).catch(e=>alert("Could not delete plan branch: "+e))}();
/*
For every plan branch you can use this bookmark:
- Open the plan configuration
- Select the plan branch you want to delete
- Click the bookmark
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment