Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

When using this workflow condition, configuered transition will only be available depending on the evaluation of a given Groovy script.


To add '

...

Groovy script condition' to a transition: 

  1. Click Edit for the workflow that has the transition you wish to add the condition on.
  2. In the Workflow Designer, select the transition.
  3. Click on Condition in the properties panel.
  4. Click on Add condition.
  5. Select Groovy Script condition from the list of conditions.
  6. Click on Add to add the condition on the transition.
  7. Fill the form shown below and press 'Add' button.

Image Added

Fields

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 user user to access the current ApplicationUser in condition.
  • You can try your script against any issue using the test button.

Script samples

This sample condition checks if the issue has at least one comment.

Code Block
languagegroovy
titleIssue must have comments
linenumberstrue
collapsetrue
import com.atlassian.jira.issue.comments.CommentManager;

def commentManager = ComponentAccessor.getCommentManager();
return !commentManager.getComments(issue).isEmpty();


This sample condition checks if the user that may transition the issue has an gmail address as their configured email address in Jira.

Code Block
languagegroovy
titleCurrent user must have a gmail address
linenumberstrue
collapsetrue
def reporterEmailAddress = issue.getReporter()?.getEmailAddress();
if (reporterEmailAddress != null){
    log.warn("Reporter email address {}", reporterEmailAddress);
    return reporterEmailAddress.endsWith("@gmail.com");
}
return false;

...