Skip to content

Instantly share code, notes, and snippets.

@epishan
Created June 12, 2017 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epishan/9e90efdf3cbb26cb44d99790b120f835 to your computer and use it in GitHub Desktop.
Save epishan/9e90efdf3cbb26cb44d99790b120f835 to your computer and use it in GitHub Desktop.
JIRA: Delete inactive workflow without linked schema
import com.atlassian.jira.component.ComponentAccessor
def workflowManager = ComponentAccessor.workflowManager
def schemeManager = ComponentAccessor.workflowSchemeManager
def sb = new StringBuffer()
// get 2 weeks ago date
today = new java.sql.Timestamp(new Date().getTime() - 120960000)
workflowManager.workflows.each {
def schemes = schemeManager.getSchemesForWorkflow(it)
if(schemes.size() == 0) {
def upd_date=it.getUpdatedDate()
if( upd_date < today ) {
sb.append("Deleting workflow: ${it.name} \n")
try {
workflowManager.deleteWorkflow(it);
} catch (RuntimeException e) { // EDIT --- Should be Exception, RuntimeException
return false
}
} else {
sb.append("SKIPPING ${upd_date} is after ${today} \n")
}
}
}
return sb.toString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment