When using this workflow condition, configuered transition will only be available depending on the evaluation of a given Groovy script.
To add 'Component Condition' to a transition:
- Click Edit for the workflow that has the transition you wish to add the condition on.
- In the Workflow Designer, select the transition.
- Click on
Condition
in the properties panel. - Click on
Add
condition
. - Select
Groovy Script condition
from the list of conditions. - Click on
Add
to add the condition on the transition. - Fill the form shown below and press 'Add' button.
Condition name – Name of the script condition. It will be used in the conditions view.
Groovy text editor – Use this editor to write the script.
Specs
- Script condition accepts groovy scripts. Return
true
to indicate a passed condition or false
otherwise. - You can user
ComponentAccessor
to access Managers and other useful classes. - You can user
issue
to access the current Issue in condition. - You can try your script against any issue using the test button.
Script samples
Code Block |
---|
language | groovy |
---|
title | Issue must have comments |
---|
linenumbers | true |
---|
collapse | true |
---|
|
import com.atlassian.jira.issue.comments.CommentManager;
def commentManager = ComponentAccessor.getCommentManager();
return !commentManager.getComments(issue).isEmpty(); |
Code Block |
---|
language | groovy |
---|
title | Current user must have a gmail address |
---|
linenumbers | true |
---|
collapse | true |
---|
|
def reporterEmailAddress = issue.getReporter()?.getEmailAddress();
if (reporterEmailAddress != null){
log.warn("Reporter email address {}", reporterEmailAddress);
return reporterEmailAddress.endsWith("@gmail.com");
}
return false; |