Groovy condition for post-functions
This page is about JEP for Jira DC. Using Cloud? Click here.
Enhancer Plugin for Jira post-functions include an optional Groovy Condition field. This field lets you write a Groovy script that controls whether the post-function executes during a workflow transition. If the script returns true (or if the field is left empty), the post-function runs as normal. If the script returns any other value, the post-function is skipped.
How it works
The Groovy Condition is evaluated each time the workflow transition fires, before the post-function logic runs.
The script must return
truefor the post-function to execute.If the condition is left empty, the post-function always executes (backward-compatible behavior).
If the condition returns
falseor any non-truevalue, the post-function is silently ignored — the transition still completes, but that post-function does not run.
How to configure a Groovy condition
Open the workflow and locate the transition containing your post-function.
Click Edit on the post-function you want to add a condition to (or add a new post-function).
In the Add Parameters To Function dialog, locate the Groovy Condition field at the top of the form.
Enter your Groovy script in the code editor.
Use the Try groovy script link below the editor to test your script before saving.
Click Add (or Update) to save the post-function configuration.
Tip: You can add a Groovy condition to any post-function, including Smart Assignment, Assign Issue to User in Custom Field, Notify Overdue Transition, and all others.
Script requirements
The script must return a boolean
trueto allow the post-function to execute.Any return value other than
true(includingnull,false, or an exception) causes the post-function to be skipped.The condition does not block the workflow transition itself — it only controls whether the individual post-function fires.
Note: Confirm available binding variables with your Jira administrator. Common variables in Groovy-based workflow extensions include issue, transientVars, and log, but the exact context depends on your JEP version and Jira platform version.
Examples
The following examples show common patterns for Groovy conditions.
Run the post-function only for a specific issue type
return issue.issueType.name == "Bug"The post-function only executes when the issue is of type "Bug."
Run the post-function only for high-priority issues
return issue.priority.name in ["Highest", "High"]The post-function only executes when the issue priority is Highest or High.
Run the post-function only when a custom field has a value
def cf = issue.getCustomFieldValue("customfield_10100")
return cf != nullThe post-function only executes when the specified custom field is not empty.
These examples use common Groovy patterns. Test your scripts using the Try groovy script link in the configuration dialog before deploying to production workflows.
