Excerpt |
---|
Post functions are provided with an option to control their execution. You need to input a Nunjucks template in the |
...
To add a condition to control the execution of the post-function :
Select the check box
Run this post-function only if a condition is verified
.Type a Nunjucks template that returns either
true
or
false
.
Note that any non-empty string that is not false
will be considered as true
and will thus let the post-function run.
...
Expected value in the Nunjucks template
The value should be either a boolean value (true
or false
) or more generally any text that will be interpreted as either "truthy" or "falsy".
Text: Any text will be interpreted as "truthy" (the equivalent of true
) except false
, an empty string, a string consisting only of whitespaces. For example, the following text will be considered as "truthy":
true
1
A string
[Object object]
[]
Boolean logic operators: You can use traditional boolean logic operators, such as or
, and
and not
, to combine conditions. You can also use parentheses to group expressions. For example:
{{ 1 == 1 or 1==2 }}
{{ issue.key == 'TEST-1' and issue.fields.subject == 'Do it' }}
{{ true and (false or true) }}
{{ not 1==1 }}
{{ issue.fields.description is null }}
returnstrue
if the issue has no description{{ issue.fields.assignee is not null }}
returnstrue
if the issue has an Assignee
Examples of Nunjucks expressions returning a "truthy" value:
{{issue.fields.assignee}}
if the issue is assigned{{issue.fields.assignee.accountId == "accountId:557058:8952dfd1-85c4-493f-87d8-d383b987e05c"}}
if the issue is assigned to the user whose accountId is "557058:8952dfd1-85c4-493f-87d8-d383b987e05c"{{issue.fields.description is not null}}
if the issue's description is not empty{{issue.fields.assignee and issue.fields.status.name == "In Progress"}}
if the issue is assigned and in the “In Progress” status
Sample use cases for Conditional execution
A tester creates an issue. The created issue should be automatically assigned to the Product Owner, only if the issue is a BUG.
Expand | |||
---|---|---|---|
| |||
Panel |
|
Automatically escalate Automatically escalate an issue if it is being raised with a "Blocker" priority.
Expand | |||
---|---|---|---|
| |||
Panel |
|
Automatically transition the Epic when all Stories are resolved.
Expand | ||||
---|---|---|---|---|
| panel||||
|
...
Copy value from a Single Version Picker select list to the Fix Version(s) field if the resolution provided while closing the issue is "Fixed".
Expand | ||||
---|---|---|---|---|
| panel||||
|
...
Assign a Bug to a Product Manager only when its priority is Critical
Expand | |||
---|---|---|---|
| |||
Panel |
|
Transition an issue to In Progress status when the issue is either of High priority or the reporter of the issue belongs to Service Desk Customers Project role
Expand | ||||
---|---|---|---|---|
| panel||||
|
Link issues that belong to the project with key “BACKEND” and created before 5 days
Expand | ||||
---|---|---|---|---|
| ||||
|