Skip to content

Instantly share code, notes, and snippets.

@zionyx
Last active January 27, 2023 20:16
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save zionyx/378ba519239bf040b2a6310b68d2740d to your computer and use it in GitHub Desktop.
Save zionyx/378ba519239bf040b2a6310b68d2740d to your computer and use it in GitHub Desktop.
JavaScript to delete all inactive workflows in JIRA

@jetersen developed this awesome javascript to delete all deletable, inactive workflows in JIRA.

Steps:

  1. As admin, go to https://jira/secure/admin/workflows/ListWorkflows.jspa
  2. Open developer console in your browser, copy paste the js below and run it.

⚠️ Note

It may crash your browser, but not JIRA.

Tested on our instance:

  • Removed 125++ inactive workflows
  • Via Google Chrome 74.0.3729.131
  • On JIRA 7.10.2
deleteElements = document.querySelectorAll(
"#inactive-workflows-table td a[data-operation='delete']"
);
options = {
method: "post",
headers: {
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
}
};
deleteElements.forEach(element => {
href = element.href;
if (href) {
href = href.toString() + "&confirmedDelete=true";
const [url, data] = href.split("?");
const workflowName = data.split("&")[2];
options.body = data;
fetch(url, options)
.then(response => {
if (response) {
console.log(`${workflowName} removed: ${response.status}`);
}
})
.catch(error => {
console.log(`FAILED to remove ${workflowName}`);
});
}
});
@StevenDover
Copy link

Awesome, thanks for this!

@beliaev-maksim
Copy link

excellent, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment