Hi I'm trying to use Groovy Runner to create an issue as part of a Post Function. However, before the post-function creates the issue, I'd like to run a search and check for existing issues with the same Summary or matching custom fields, and if found, link to that issue instead of creating a new issue.
I can't seem to find out how to do the jira search part of the script. I could probably do a JQL search in the GUI but I don't know how to translate that into script code. Any suggestions?
Here's a Java sample and you'll have to just port it to groovy:
final JqlQueryBuilder queryBuilder = JqlQueryBuilder.newBuilder(); final JqlClauseBuilder whereBuilder = queryBuilder.where().defaultAnd(); whereBuilder.summary().like("some summary") Query query = queryBuilder.buildQuery(); User user; SearchResults results = ComponentAccessor.getComponent(SearchProvider.class).search(query, user, PagerFilter.getUnlimitedFilter()); List<Issue> issues = results.getIssues();
You are going to have trouble bailing out of the "create" process from a post-function.
Maybe try doing it in a validator...?
There is some code for the behaviours plugin here: http://blogs.onresolve.com/2010/03/audo-duplicate-search-in-jira/- but you could get what you want out of it. Or use Boris' example.
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
EaglePicher Technologies is a leading manufacturer of battery systems for diverse industries like defense, aviation, space or medical. As they operate in highly regulated industries, keeping a clear ...
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!
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