Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Best way to get all issues for large project

Anonymouslemming September 21, 2015

Hi all,

As part of trying to resolve https://answers.atlassian.com/questions/28870803, I am trying to get a list of all issues in a project in a plugin. This will then be used by the client to delete all issues.

The first step is to get all issues, but I see that getProjectIssues is deprecated at https://developer.atlassian.com/static/javadoc/jira/6.4.1/reference/com/atlassian/jira/issue/IssueManager.html#getProjectIssues(org.ofbiz.core.entity.GenericValue)

That page mentions that I should be using a search provider instead, but does not link to what that is or an example of that.

What I'm trying to do is get all issues for a project, identify which are subtasks and delete those, then delete all remaining tasks, then delete the project. 

Any input into the best way to get all issues for large projects (20,000+ issues) would be greatly appreciated!

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Tomasz Stec
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 22, 2015

Hi,

Try JQL... process all results at once or implement your own way of handling numerous results using for instance PageFilter:

 

SearchProvider searchProvider = ComponentAccessor.getComponentOfType(SearchProvider.class);
List<Issue> fetchedIssues;
JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();   builder.where().issueType().eq("Sub-Task").and().project(projectId);        
        try {
            final SearchResults results = searchProvider.searchOverrideSecurity(builder.buildQuery(), user, PagerFilter.getUnlimitedFilter() , null);
// if you have huge amount of issues try assemble something using PageFilter.newPageAlignedFilter(0, 100)
// then process it page by page.
            fetchedIssues = results.getIssues();
        } catch (SearchException e1) {
            e1.printStackTrace();
        }
Anonymouslemming September 22, 2015

Thanks - looks good. That'll be a lot of iterations for 2,000 issues, but at least it keeps me under the barrier for large search results in JQL. Thanks again,

1 vote
Jeff Louwerse
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 22, 2015

I do the same thing since I have had the internal delete project fail on me way too many times and have then had to go though and clean it up. 

 

If you want a pure REST solution, use JQL.

/rest/api/2/search?jql=project=ZAC&maxResults=2000&fields=key

 

Personally I use good old SQL (oracle example below) so I am not limited to JIRA timeouts, max results or anything jira. 

SELECT ID 
FROM JIRAISSUE JI, PROJECT P 
WHERE JI.PROJECT = P.ID and P.PKEY = '<YOUR KEY HERE>'

 

Also note that you don't have to delete subtasks before deleting an issue; Just add "?deleteSubtasks=true" to your REST URL

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 22, 2015

You can use JIRA Command Line Interface (CLI).

  1. runFromIssueList using a project or a JQL selection - see How to use runFromIssueList
  2. deleteIssue will handle the delete

 

 

Anonymouslemming September 22, 2015

Unfortunately, Jira CLI is not suitable in our environment for a number of reasons.

TAGS
AUG Leaders

Atlassian Community Events