Execute a ScriptRunner Script

ScriptRunner provides an action for Automation for Jira that lets you run your own code.

Due to incompatibly changing APIs in Automation for Jira, we provide two actions. One is deprecated, although there are no plans to remove it, and you do not need to migrate to the newer version unless you need access to something only available in the more recent version.

Both actions provide a way to run a "custom script," but you can call other ScriptRunner functions programmatically.

Binding Variables

Binding variableDescription
issueThe issue object that triggered the event
currentUserThe ApplicationUser defined as the actor for the rule
initiatorThe ApplicationUser that initiated the event
inputsThe ComponentInputs. This could be used for example to retrieve the sprint if the trigger is Sprint Created Event.
ruleContextThe current RuleContext. This can be used to evaluate smart values.

Additionally, two utility functions are available for writing information and error messages to the Automation for Jira audit log. They are addMessage(String message) and addError(String errorMessage). For example:

addMessage("My message") addError("My error message")

The above example produces the following:

Outcome of binding variables example.

Smart Values

You can evaluate smart values using ruleContext.renderSmartValues(String), for example:

log.warn ("Initiator of the action was... " + ruleContext.renderSmartValues('{{initiator}}'))

Deprecated version

Binding Variables

Binding variableDescription
issueThe issue object that triggered the event
currentUserThe ApplicationUser defined as the actor for the rule
errorCollectionAn ErrorCollection - use it to record error conditions, eg errorCollection.addErrorMessage("Something went wrong").
executionContextUse this if you need to retrieve any information about the rule that is currently firing.



Related content

On this page