Get Workflow Steps
Get the current action name
In a workflow function, to get the ID of the action (which is normally what you want rather than the name), use:
transientVars["actionId"]
To get the action name you can use:
import com.atlassian.jira.component.ComponentAccessor
def workflow = ComponentAccessor.getWorkflowManager().getWorkflow(issue)
def wfd = workflow.getDescriptor()
def actionName = wfd.getAction(transientVars["actionId"] as int).getName()
log.debug("Current action name: $actionName")
Get the previous and destination steps
Getting the current and destination steps depends on whether your function is placed above or below the functions to update the issue in the database and reindex.
The following code:
myIssue.statusObject.name
will return the current status - so if your script function is before the built-in functions to update the issue it will return the "previous" status, if it is after it will return the destination status.
To get the destination step use:
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.spi.Step
def step = transientVars["createdStep"] as Step
def stepId = step.getStepId()
def status = ComponentAccessor.getConstantsManager().getStatusObject(stepId as String)
log.debug(status.name)