How can we find the unused workflow, workflow schemes and screens, Screen schemes etc and delete it?

Deepa Tantry June 27, 2017

Please let me know if we have any way to find the workflows/screens etc that are not used in any projects so that those can be deleted. I know the manual way to achieve this. However, since we have many schemes which cannot be done manually, can you please let me know if this can be achieved via some script(Groovy/script lisetner, etc)

Script to find the Unused Workflows, Workflow schemes, Screens, Screen schemes, issue type screen schemes

Script to delete the Unused Workflows, Workflow schemes, Screens, Screen schemes, issue type screen schemes.

Current Jira version is 7.2.9

Your help is highly appreciated!

Thanks in advance.

Deepa

2 answers

0 votes
Avin Singhal June 19, 2018

For inactive workflow you can use  below script

Line commented will delete the inactive workflow, please uncomment if you want to delete

Workflow deletion

import com.atlassian.jira.component.ComponentAccessor

def workflowManager = ComponentAccessor.workflowManager
def schemeManager = ComponentAccessor.workflowSchemeManager

def sb = new StringBuffer()

workflowManager.workflows.each {
if(!it.systemWorkflow) {
def schemes = schemeManager.getSchemesForWorkflow(it)
if (schemes.size() == 0) {
sb.append("Deleting workflow: ${it.name}\n")
//workflowManager.deleteWorkflow(it)
}
}
}
return sb.toString()

Ahsan September 1, 2019

@Avin Singhal 

Is there any script to do the same with unused Field Configuration Schemes, Field Configurations and Fields?

Also, with Unused Issue Types Schemes and Issue Types.

Thanks in advance. 

Ahsan September 1, 2019

@Avin Singhal 

Thank you very much.

Is there any script to delete unused Field Configuration Schemes, Field Configurations and Fields?

Also, Unused Issue Types Schemes and Issue Types.

Thanks in advance. 

Avin Singhal September 2, 2019

@Ahsan 

 

Inactive IssueType Screen Schemes Deletion scripts:

import com.atlassian.jira.component.ComponentAccessor

 

def schemeManager = ComponentAccessor.issueTypeScreenSchemeManager

 

def sb = new StringBuffer()

 

sb.append("Deleted issue type screen schemes with no associated projects:<br/><br/>\n")
schemeManager.issueTypeScreenSchemes.each {
try{
if(it.projects.size() == 0) {
sb.append("${it.name}\n")
//schemeManager.removeIssueTypeScreenScheme(it);
}
}
catch(Exception e) {
//noop
sb.append("Error: " + e + "\n");
}
}

 

return sb.toString()

Like # people like this
Avin Singhal September 2, 2019

@Ahsan  

Inactive Screen Schemes Deletion scripts:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.screen.FieldScreenSchemeManager

def fssm = ComponentAccessor.getComponent(FieldScreenSchemeManager.class)
def itssm = ComponentAccessor.issueTypeScreenSchemeManager

def sb = new StringBuffer()

sb.append("Deleted screen schemes with no associated issue type screen schemes:<br/><br/>\n")
fssm.fieldScreenSchemes.each {
try{
if(itssm.getIssueTypeScreenSchemes(it).size() == 0) {
// fssm.removeFieldScreenScheme(it);
sb.append("${it.name}\n");
}
}
catch(Exception e) {
//noop
//sb.append("Error: " + e + "\n");
}
}

return sb.toString()

Like # people like this
Avin Singhal September 2, 2019

@Ahsan   Please you can enhance the above script.

Dont forgot to vote if you like it

You can also try Jira Cleaner plugin we are using now which tell us about all the entities not in used , I can say this plugin is very handy for cleanup

Like # people like this
0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 27, 2017

>since we have many schemes which cannot be done manually

All schemes can be done "manually".  I don't understand what you mean here.

Deepa Tantry June 27, 2017

Thanks for your relpy Nic..
Manually deleting 500+ workflows and screens that are unused is a very tedius process. I wanted to know the other options to achieve this.

Can you please help with this.

 

-Deepa

Avin Singhal September 2, 2019

@Deepa Tantry   Please try Jira Cleaner plugin it very handy for cleanup

Suggest an answer

Log in or Sign up to answer