It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bulk Delete Issues Using ScriptRunner

Hi,

I was wondering if anyone knew how to bulk delete issue using scriptrunner?

I dont know if 'issueManager.deleteIssueNoEvent(issue)' is part of it?

Thanks

Rob

1 answer

Are you looking for something like this?

import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.MutableIssue

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)
def issueManager = ComponentAccessor.getIssueManager()
def userManager = ComponentAccessor.getUserManager()

def query = jqlQueryParser.parseQuery("YOUR JQL")
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())

results.getIssues().each {documentIssue ->

       deleteIssueNoEvent(documentIssue )

}

I haven't tested this code exactly, maybe you find some error.

Hope this helps

Hi,

I get an error back.....

groovy.lang.MissingPropertyException: No such property: user for class: Script4 at Script4.run(Script4.groovy:14)

Dont know what this means tbh?

Thanks

Rob

This is working despite the warning in deleteIssueNoEvent

import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.Issue

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)
def issueManager = ComponentAccessor.getIssueManager()
def userManager = ComponentAccessor.getUserManager()

ApplicationUser user = userManager.getUserByName("YOUR USER NAME")

def query = jqlQueryParser.parseQuery("YOUR JQL")
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())

results.getIssues().each {documentIssue ->

Issue issue = issueManager.getIssueObject(documentIssue.id)
issueManager.deleteIssueNoEvent(issue)

}

 

No sorry still not working...

 

2019-10-22 13:20:09,210 WARN [common.UserScriptEndpoint]: Script console script failed: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.search.providers.LuceneSearchProvider.search() is applicable for argument types: (com.atlassian.query.QueryImpl, com.atlassian.jira.user.DelegatingApplicationUser, com.atlassian.jira.web.bean.PagerFilter) values: [{project = "WNM"}, N455065(n455065), com.atlassian.jira.web.bean.PagerFilter@4becb593[start=0,end=2147483647,max=2147483647]] Possible solutions: search(com.atlassian.jira.issue.search.SearchQuery, com.atlassian.jira.web.bean.PagerFilter), search(com.atlassian.jira.issue.search.SearchQuery, com.atlassian.jira.web.bean.PagerFilter, java.util.Set), search(com.atlassian.jira.issue.search.SearchQuery, org.apache.lucene.search.Collector), each(groovy.lang.Closure) at Script16.run(Script16.groovy:16)

which version is your jira.

looking for info, it seems that in Jira 8.x.x 

searchProvider.search

has changed and now takes only query and pager as parameters.

https://docs.atlassian.com/software/jira/docs/api/8.1.0/com/atlassian/jira/issue/search/SearchProvider.html

I'm running jira 7.x and  searchprovider.search takes query, user and pager as parameters.

https://docs.atlassian.com/software/jira/docs/api/6.4.1/com/atlassian/jira/issue/search/SearchProvider.html

I can't make any test, but i think it should work for you if this is the problem just changing 

def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())

with

def results = searchProvider.search(query,PagerFilter.getUnlimitedFilter())

Anyway, i'm getting out of my control zone so I may be wrong.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

375 views 1 3
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you