Modify Jira Workflow condition "No Open Reviews" maybe using scriptRunner?

I have Jira 5.2.11 integrated with Crucible 3.0.3 but I want to enforce the process that a Jira workflow transition will not be available unless there is at least one review associated/linked with the Jira issues and all linked reviews must be closed. I know about the two builtin conditions:

1/ "No Open Reviews" condition but the condition won't failed if no reviews are linked to the Jira issue.

2/ "Unreviewed Code" condition doesn't help because I allow for patch files to be used not just changesets.

I'm familiar with writing groovy scripts with scriptRunner so I just wanted to find the original Atlassian source code for this condition. I downloaded the 5.2.11 source zip file from MyAtlassian account but had no luck finding(greping) the source code.

A // Does that source zip contain all the source or do I download other associated zip files?

B // If someone else has a similar groovy script that can extract the reviews associated with a jira issue then that would be great.

Thanks Brent

1 answer

1 accepted

This widget could not be displayed.

My solution as a workflow validator:

// Validator will check that at least one review is associated with this issue
// and all this issue's associated reviews must be closed.
import com.atlassian.jira.ComponentManager;
import com.atlassian.plugin.PluginAccessor

ComponentManager componentManager = ComponentManager.getInstance();
PluginAccessor pluginAccessor = componentManager.getPluginAccessor();
Class reviewManagerClass = pluginAccessor.getClassLoader().findClass("com.atlassian.jirafisheyeplugin.domain.crucible.ReviewManager");
Class reviewListClass = pluginAccessor.getClassLoader().findClass("com.atlassian.jirafisheyeplugin.domain.crucible.ReviewList");
Class reviewClass = pluginAccessor.getClassLoader().findClass("com.atlassian.jirafisheyeplugin.domain.crucible.Review");

def reviewManager = componentManager.getOSGiComponentInstanceOfType(reviewManagerClass);
def list = reviewManager.getReviewsForIssue(issue);
if (list.hasErrors()) {
  log.error("<<BW>> Error retrieving reviews for ReviewsCompleteCondition (" + issue.getKey() + ").");
  return false;
} else if ( list.getReviews().isEmpty() ) {
  return false;
} else {
  for (def review : list.getReviews()) {
    if (review.isOpen()) {
      // all reviews must be closed
      return false;
    }
  }
}
return true;

This solution doesn't work with JIRA 7. (No JiraFisheye plugin)

Do you have any solution that would work with the JIRA Development Integration plugin? Thanks!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

223 views 3 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you