Very easy, try to enter in the “Groovy Script Console” and execute this code.

import com.atlassian.jira.component.ComponentAccessor

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

def sb = new StringBuffer()

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

return sb.toString()

source extracted from here

Advertisements
Posted by:.

2 replies on “How to delete all Inactive/Drafts Workflows in JIRA in one shot with Groovy Scriptrunner

  1. There’s an error
    The workflow is assigned to workflow schemes

    com.atlassian.jira.workflow.WorkflowException: The workflow is assigned to workflow schemes
    at com.atlassian.jira.workflow.OSWorkflowManager.deleteWorkflow(OSWorkflowManager.java:456)
    at com.atlassian.jira.workflow.WorkflowManager$deleteWorkflow.call(Unknown Source)
    at Script79$_run_closure1.doCall(Script79.groovy:12)
    at Script79.run(Script79.groovy:8)

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s