Skip to content

Instantly share code, notes, and snippets.

@epishan
Last active March 7, 2021 09:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epishan/a3d59ebc292961daf95e1e77e5573470 to your computer and use it in GitHub Desktop.
Save epishan/a3d59ebc292961daf95e1e77e5573470 to your computer and use it in GitHub Desktop.
[JIRA] Remove inactive (unassigned) Workflow Schemes
import com.atlassian.jira.component.ComponentAccessor
def schemeManager = ComponentAccessor.workflowSchemeManager
def sb = new StringBuffer()
def schemes = schemeManager.getAssignableSchemes()
if(schemes != null) {
schemes.each {
if (schemeManager.isActive(it)) {
sb.append("|||||| Skipping active wf scheme: ${it.name} \n")
} else {
try {
schemeManager.deleteWorkflowScheme(it);
sb.append("|||||| REMOVED wf scheme: ${it.name} \n")
} catch (RuntimeException e) { // EDIT --- Should be Exception, RuntimeException
sb.append("|||||| FAILED to remove wf scheme: ${it.name} \n")
}
}
}
}
return sb.toString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment