Jira Cleanup with CLI

Let Bob ('s CLI) do the work

Bob Swift Atlassian Apps on Twitter: "Come stop by Booth #1019. I'd love to  meet you while we are all here at Summit. We've got a new app, Drag and  Drop Automation

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.) 

Screens Cleanup

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.

Find Unused Issue Type Screen Schemes

acli --action getIssueTypeScreenSchemeList --options "deleteEnabled"

Delete Unused Issue Type Screen Schemes

acli --action runFromIssueTypeScreenSchemeList \
--common "--action deleteIssueTypeScreenScheme --id @schemeId@" \
--options "deleteEnabled" --continue

Find Unused Screen Schemes

acli --action getScreenSchemeList --options "deleteEnabled"

Delete Unused Screen Schemes

acli --action runFromScreenSchemeList --common "--action deleteScreenScheme --id @schemeId@" \
--options "deleteEnabled" --continue

Find Unused Screens

acli --action getScreenList --options "deleteEnabled"

Delete Unused Screens

acli --action runFromScreenList --common "--action deleteScreen --id @screenId@" \ 
--options "deleteEnabled" --continue

Field Configuration Cleanup

Find Unused Field Configuration Schemes

acli --action getFieldConfigurationSchemeList --options "deleteEnabled"

Delete Unused Field Configuration Schemes

acli --action runFromFieldConfigurationSchemeList --options "deleteEnabled" \
--common "--action deleteFieldConfigurationScheme --id @schemeId@" --continue

Find Unused Field Configurations

acli --action getFieldConfigurationList --options "deleteEnabled"

Delete Unused Field Configuration Schemes

acli --action runFromFieldConfigurationList --options "deleteEnabled" \
--common "--action deleteFieldConfiguration --id @fieldConfigurationId@" --continue

Issue Type Scheme Cleanup

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:

Find Issue Type Schemes with no associated projects

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.

Delete Issue Type Schemes with no associated projects

acli --simulate --action runFromCSV --file deleteableissuetypeschemes.csv \
--common "-a deleteIssueTypeScheme"

Workflow Cleanup

Find Unused Workflow Schemes

acli --action getWorkflowSchemeList --options "deleteEnabled"

Delete Unused Workflow Schemes

acli --action runFromWorkflowSchemeList --common \
"--action deleteWorkflowScheme --id @schemeId@" \
--options "deleteEnabled" --continue

Find Inactive Workflows

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.

Delete Inactive Workflows

acli --action runFromCSV --file deleteableworkflows.csv \
--common "-a deleteWorkflow" --continue

Resources:

6 comments

Bob Swift _Appfire_ July 13, 2021

Nice job Darryl :)

Like # people like this
Michael Kuhl _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 14, 2021

Hi @Darryl Lee - This is a great article!  Here's a way to skip the step of using Excel, etc to filter issue type schemes which have empty projects:  You an add --select "Projects:.+"  --options negative to filter the result set to those without any value in the projects column.
[Edited to add "--options" to find rows with empty project columns]

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 14, 2021

@Michael Kuhl _Appfire_ Oh man, that is awesome!

Man, it would be really good if there was some examples of this. I'm going to try this and update my original article!

Oh also, I tried to use this with runFromIssueTypeSchemeList and bummer, got this:

Parameter error: The select parameter is not available for run actions. An alternative is to use the select parameter on a get...List action and then runFromCsv to process the file.

Man... I guess it's still a a bit of a two-step process.

Will run actions ever support the select parameter?

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 15, 2021

Oh, thanks to the tip from @Michael Kuhl _Appfire_, I ended up deleting this from my original article, but wanted to call it out:

Back in Dec 2020@Manisha Kharga _Appfire_ suggested that the CLI command getIssueTypeSchemeList could output a list of all Issue Type Schemes, along with associated Projects, and then you could use Excel, etc. to filter on that column (where it is blank), and then run another command to delete those specific schemes.

Unfortunately the feature to include Projects didn't actually work in v9.6.0, but Manisha helped get a bug filed and Appfire got it working in v9.7.0 of CLI.

 

Michael Kuhl _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2021

Hey @Darryl Lee  re: "Will run actions ever support the select parameter?"
I noticed that myself and am looking into it.

Like Kristján Mathiesen likes this
Kristján Geir Mathiesen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 29, 2023

This is such an awesome, kick butt article! Takk, @Darryl Lee !

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events