Streamlining Jira — Automating the Cleanup of Unused Jira Configuration Using ATLAS CLI for Jira

The Starware
3 min readDec 7, 2023
Jira Automation with ATLAS CLI for Jira

As Jira evolves within an organization, certain configurations like “Issue Type Screen Schemes”, “Screens”, “Custom Fields” often become redundant. Over time, this can clutter the Jira instance, leading to inefficiencies. This article demonstrates how to automate the cleanup of these unused schemes using the ATLAS CLI for Jira.

You will need to use command line version of ATLAS CLI for Jira for this automation. Command line version of ATLAS CLI for Jira can be used for both cloud and data center versions of Jira. Please refer the user manual to learn how to set it up.

Determining which schemas are in use can be a daunting task. But you don’t need to do it. Jira will not allow you to delete a schema if it is in use. So, you can blindly try to delete it and if it is in use, Jira will not delete it. Our strategy is to get all of the schemas from Jira and try to delete each one using the ATLAS CLI for Jira. You don’t need to write a program for this, for each configuration you want to delete, you only need a one line.

Lets start with “Issue Type Screen Schemes”:

jira issue-type-screen-scheme search --all | tail -n +4 | awk '{print $1}' | xargs -I {} jira issue-type-screen-scheme delete -i {}

This command may take a while to execute depending on the number of items it needs to process and from time to time, you can see a message like this:

Error: Bad Request:The issue type screen scheme cannot be deleted because it is assigned to one or more projects.

The one liner is actually 4 commands piped into the next one in a chain.

  • The first one issue-type-screen-scheme search --all, returns a list of all “Issue Type Screen Schemes” in the Jira instance as a table with headers and a row for each item.
  • tail -n +4 command cuts the header part of the output.
  • awk '{print $1}' command cuts the first column, ID column from the output.
  • xargs -I {} jira issue-type-screen-scheme delete -i {} command takes each line from the output (at that point it only contains scheme ID in each line) and executes the jira issue-type-screen-scheme delete command for each of them.

Which means this “Issue Type Screen Schemes” can’t be deleted, because it is being used by a project.

After deleting “Issue Type Screen Schemes”, we can try to delete the unused “Screen Schemes”.

jira screen-scheme get-all --all | tail -n +3 | awk '{print $1}' | xargs -I {} jira screen-scheme delete -i {}

Strategy is the same, try to delete every one of them and let Jira to block you if you are trying to delete something in use. Again, from time to time you can get an error message saying that the item is in use.

For my case, the command took several minutes and reduced number of “Screen Schemes” from 324 to 36.

Now let's try to delete unused screen using the same strategy.

 jira screen get-all --all | tail -n +3 | awk '{print $1}' | xargs -I {} jira screen delete -i {}

For my case, it took 12 minutes to run and reduced number of screens from 716 to 134. During the operation it warned about some screens are used by “workflows or workflow drafts”. So, it may be a good idea to make a workflow cleanup before the screen cleanup.

Here some other cleanup commands:

Delete unused “Workflow Schemes”:

jira workflow-scheme get-all --all | tail -n +4 | awk '{print $1}'|xargs -I {} jira workflow-scheme delete -i {}

Delete unused “Workflows”:

 jira workflow search --all |tail -n +4 | awk '{print $1}'| xargs -I {} jira workflow delete -i {}

--

--

The Starware is a software development company specialized in add-on development on Atlassian Platform.