Conditional execution/validation using a Groovy expression

The Post functions and Validators provided by the JMWE add-on have a Conditional execution/Conditional Validation section to control the execution of the post-function/validator respectively. You need to provide a Groovy script in the editor based on whose result, the post-function/validator will either be executed or skipped.

On this page:

Conditional execution of a post-function

Conditional validation

Expected Value for a condition

The value should be either a boolean value (true or false), or more generally any value that will be interpreted as either "truthy" or "falsy". Click on the Expected Value tab of the Groovy editor to know the expected value. You can also quickly test your written script against any issue using the script tester tool. For example:

Groovy expressions returning a "truthy" value: 

  • 1 == 1 or any boolean expression that is true
  • issue.get("assignee") if the issue is assigned
  • issue.getAsString("assignee") == "jdoe" if the issue is assigned to user "jdoe"
  • issue.get("description") if the issue's description is not empty

Groovy expressions returning a "falsy" value: 

Any value will be interpreted as "falsy" (the equivalent of false) except: true, a non-empty string, a non-empty Collection, a non-empty Map, a non-empty array, a number different from zero (0)

For example, false, 0, "", []

Below are a few use cases that detail the usage of these functionalities.

Use cases

Conditional execution

(lightbulb)  Automatically escalate an issue if it is being raised with a "Blocker" priority.

(lightbulb) Auto-assign a created issue to the Product owner, only if the issue is a Bug

(lightbulb) Add a comment on the Epic when its user stories of a client-side project are resolved.

Conditional validation

(lightbulb) Allow the members of the Managers project role to omit the comment

(lightbulb) Force the user to provide a Fix Version/s on resolving a bug, only when the resolution is "Fixed"