As I mentioned in my article Tidying Up Jira, the Bob Swift's CLI is incredibly useful for doing cleanup of configuration objects in Jira that are not used.
I'm talking about screens or workflows that nobody uses, issue type schemes that were discarded but never deleted, etc.
A former client was very insistent that we clean these up on a weekly basis, and it bugged me having to manually delete one or two of these schemes, etc. all the time. So I started looking for ways to automate the process, and CLI was perfect.
By the time I worked with a different client who had tons of unused objects, I was very happy I had saved all of the commands I figured out for the previous client. And so I'm happily sharing those commands with you. (Note: most of these were developed and tested with ACLI client versions 9.6.0 and 9.7.0. Most recently I had to update to 9.8.1 because of what looked like changes in the Cloud. Especially if you're on Cloud, you're going to want to be on the latest version.)
The Find commands below let you preview which schemes/screens will get deleted (it only will delete schemes/screens that are “Deleteable” in the UI (options=deleteEnabled).
After confirming, you can use the Delete commands to automatically delete them.
You can use regex to exclude certain unused schemes/screens we want to keep around. (Example shown in Screens.)
You can also run the delete commands with a --simulate flag to see what it will do.
acli --action getIssueTypeScreenSchemeList --options "deleteEnabled"
acli --action runFromIssueTypeScreenSchemeList \
--common "--action deleteIssueTypeScreenScheme --id @schemeId@" \
--options "deleteEnabled" --continue
acli --action getScreenSchemeList --options "deleteEnabled"
acli --action runFromScreenSchemeList --common "--action deleteScreenScheme --id @schemeId@" \
--options "deleteEnabled" --continue
acli --action getScreenList --options "deleteEnabled"
acli --action runFromScreenList --common "--action deleteScreen --id @screenId@" \
--options "deleteEnabled" --continue
acli --action getFieldConfigurationSchemeList --options "deleteEnabled"
acli --action runFromFieldConfigurationSchemeList --options "deleteEnabled" \
--common "--action deleteFieldConfigurationScheme --id @schemeId@" --continue
acli --action getFieldConfigurationList --options "deleteEnabled"
acli --action runFromFieldConfigurationList --options "deleteEnabled" \
--common "--action deleteFieldConfiguration --id @fieldConfigurationId@" --continue
In the UI, Jira displays which Issue Type Schemes are associated with "No projects" (and thus are good candidates to clean up). But it turns out that Jira will let you delete that are associated with projects, warning you that "This project will revert to using the default global issue type scheme."
So you only want to delete Issue Type Schemes that are not associated with any projects, and thanks to a tip from @Michael Kuhl {Appfire}, I've learned how to use the select command to produce a list of these unassociated schemes, which you then can use with runFromCSV to delete them.
Here's how to use the command:
acli dev --action getIssueTypeSchemeList --outputFormat 999 \
--select "Projects:.+" --options negative \
--file deleteableissuetypeschemes.csv
So review that list -- maybe do a sanity check against the UI to make sure the list is accurate (schemes on the list should show "No Projects"). If it looks good, then you can proceed to delete them.
acli --simulate --action runFromCSV --file deleteableissuetypeschemes.csv \
--common "-a deleteIssueTypeScheme"
acli --action getWorkflowSchemeList --options "deleteEnabled"
acli --action runFromWorkflowSchemeList --common \
"--action deleteWorkflowScheme --id @schemeId@" \
--options "deleteEnabled" --continue
The CLI command getWorkflowList when used with is able to display a column named "Delete Enabled", which also works with the select option:
acli --action getWorkflowList --outputFormat 999 \
--select "Delete Enabled:Yes" --file deleteableworkflows.csv
Again, validate the list, and you can proceed to delete.
Note: On my test server, I see a workflow named: "Builds Workflow (Read-only System Workflow)", which does not show as deleteable, but CLI lists it as "Delete Enabled". I tried deleting it using the CLI below, but it fails with "Client error: Unknown error occurred. Workflow not deleted." So that's why I had to add continue.
I will file a bug with Bob about this, but you can either remove any "Read-only" workflows from your list, or just not panic when the error shows up.
acli --action runFromCSV --file deleteableworkflows.csv \
--common "-a deleteWorkflow" --continue
Darryl Lee
Sr. Systems Engineer
Roku, Inc.
San Jose, CA
186 accepted answers
10 comments