Skip to content

Instantly share code, notes, and snippets.

@kavichu
Created April 4, 2016 18:05
Show Gist options
  • Save kavichu/41c8fe6a17b409b463e3a1eb0b797e48 to your computer and use it in GitHub Desktop.
Save kavichu/41c8fe6a17b409b463e3a1eb0b797e48 to your computer and use it in GitHub Desktop.
JIRA Workflow Properties using ScriptRunner plugin
/*
Autor: Luis Valdes
Fecha: 27/01/2016
*/
import com.atlassian.jira.workflow.WorkflowManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
workflowManager = ComponentAccessor.getWorkflowManager()
issueManager = ComponentAccessor.getIssueManager()
workflow = workflowManager.getWorkflow("WORKFLOW_NAME")
actions = workflow.getAllActions()
postFunctions = workflowManager.getPostFunctionsForWorkflow(workflow)
title = { str ->
str.center(str.length() + 2).center(80, "*") + "<br>"
}
result = ""
actions.each { action ->
// postFunctions tiene un array de functions para cada action
functions = postFunctions[action]
validators = action.getValidators()
result += title("Post-Functions -> ${action.getName()}")
functions.each { func ->
result += "${func.getArgs()} / ${func.getName()} / ${func.getType()} <br>"
}
result += title("Validators -> ${action.getName()}")
validators.each { val ->
result += "${val.getArgs()} / ${val.getName()} / ${val.getType()} <br>"
}
// Si la accion no posee restricciones, el metodo retorna null
restrictionDescriptor = action.getRestriction()
if(restrictionDescriptor){
conditionsDescriptor = restrictionDescriptor.getConditionsDescriptor()
conditions = conditionsDescriptor.getConditions()
result += title("Conditions -> ${action.getName()}")
conditions.each { cond ->
result += "${cond.getArgs()} / ${cond.getName()} / ${cond.getType()} <br>"
}
}
}
result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment