Wiki

Clone wiki

runner / Conditions

#Custom Workflow Functions Customise and extend your workflows using complex scripts to support or enforce your business processes. ##Binding For Conditions, the plugin will provide the current $issue, $currentUser, $transientVars, $args, $propertySetand $log, the plugin expects a boolean value to be returned indicating if condition is met:

// ....
return true;

##Conditions Conditions control whether a transition should be executed by the user. As examples, conditions can be used to:

  • allow only the reporter to execute a transition.
  • allow only users with a certain permission to execute a transition.
  • allow execution only if code has, or has not, been committed against this issue.

If a condition fails, the user will not see the transition button on the 'View issue' page, and so will not be able to execute the transition.

Conditions cannot validate input parameters gathered from the user on the transition's screen – you need a validator to do this.

###Examples * GROOVY

All BUG Sub-tasks resolved

passesCondition = true
def subTasks = $issue.getSubTaskObjects()

subTasks.each {
    if (it.issueTypeObject.name == "BUG" && ! it.resolutionObject)
        passesCondition = false
}

All Sub-tasks assigned to me

Check that all subtasks are assigned to the current user

import com.opensymphony.workflow.WorkflowContext

def subTasks = $issue.getSubTaskObjects()

String currentUser = ((WorkflowContext) $transientVars.get("context")).getCaller()
passesCondition = subTasks.every { it.assigneeId == currentUser }
  • PHP

A Condition to hide a transition from user in UI, but allow it to be transitioned by other scripts via API.

$ingui = false;
foreach(java_stack_trace() as $element )
{
    if ($element->className == "com.atlassian.jira.rest.v2.issue.OpsbarBeanBuilder")
        $ingui = true;
}
return !$ingui;

Updated