Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get list of archived issues using groovy script in jira

Rechu Derick October 27, 2021

Iam able to fetch list of archived projects.but I need a script to list all archived issues

1 answer

0 votes
Damian Wodzinski
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.
October 27, 2021

Hi,

Access to the archieved projects, and loop throug issues. During each loop, list the key or the summary, depending on what you need.

def issues;
def issueManager = ComponentAccessor.getIssueManager();
String Name = "Project = ${ProjectName}";
def jqlSearch = Name;
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch);
if (parseResult.isValid()) {
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
// Transform issues from DocumentIssueImpl to the "pure" form IssueImpl (some methods don't work with DocumentIssueImps)
issues = searchResult.issues.collect {
issueManager.getIssueObject(it.id)
}
} else {
log.error("Invalid JQL: " + jqlSearch);
}
for(Issue in issues)
{
println Issue.getKey()
}

Something like that, but I would merge this code with yours. ${ProjectName} would be a variable, that you get from your script.
Also inside for loop, you can save Summary, or the key into Array and then list it.

Rechu Derick October 27, 2021

Thanks for the reply. But in my case, project is not archived. Only issue is archived. In that case how can I get?

Damian Wodzinski
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.
October 27, 2021

There is a method to do that:

ArchivedIssueSearchService.getArchivedIssuesMatchingTypesInProjects(List<Long> projectIds, List<String> issueTypeIds)


 Parameters:

projectIds - unique identifiers for the projects whose issues we'd like to inspect

issueTypeIds - unique identifiers for the issue types that we're looking for instances of in the projects.

Returns:

the list of archived issues in the given projects that are of the types specified by issueTypeIds

Rechu Derick October 28, 2021

Thank you. If you don't mind, can you share a sample script plz?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events