How to check if an issue with a certain summary already exists

Hi,

I am using Jira server 7.3.1 and scriptrunner to auto create issues and I am using the 'clones and issues and links' script.  What i am trying to do, is the following:

1. check if an issue with a certain summary already exists,

2. and if so i want the script to do nothing

3. and if not i want the script to create an issue with a specific summary and epic name.

I have been able to make item 3 above to work (alone) but cant get item 1 and 2 to work.

See code below:

 def taskName = "- Repositories checked and updated" def summaryResult= sourceIssue.summary +" - In-test Phase " + taskName     if (issue.getSummary()== summaryResult){     return false } else {     issue.summary= sourceIssue.summary +" - In-test Phase " + taskName                def cf1 = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Epic Name'}                issue.setCustomFieldValue(cf1, sourceIssue.key + taskName) } 

 Appreciate your assistance in advance

1 answer

0 vote

In the condition section of the post-function you can check 

 

!issue.summary.contains("<certain summary already exists>")
 

 

Now, if the issues doesn't contain the <certain summary already exists> text then it will clone the issue. You can choose the type and project for issues in the post-function configuration and these will be executed only when the above condition of issues *not* containing the summary is met.

Then for the cloned issue

You can also choose summary 

issue.summary = 'Cloned issue'

 

and a custom field as well (Epic name) 

def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Epic Name'}
issue.setCustomFieldValue(cf, 'my value')
 

 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

523 views 1 18
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