Forums

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

Need help archiving JIRA projects

debraj.neogi@tesco.com November 26, 2020

We are using the below script to auto-archive JIRA projects which have not been updated in last 2 years. 

Issue with the script is it is also archiving projects which have got no issues in it, even if the project has recently been created. Can someone highlight what's wrong please.

 

def projectsToArchive = projectManager.projects.findAll { project ->
// JQL criteria to search within projects. If it returns anything, the project DOESN'T get archived
def jqlSearch = "project in (${project.key}) AND (updated > -730d OR created > -730d)"
def parseResult = searchService.parseQuery(user, jqlSearch)

if (!parseResult.isValid()) {
log.warn("The JQL '${jqlSearch}' is not valid. Parse result: ${parseResult.errors}")
return false
}

searchService.searchCount(user, parseResult.query) == 0
}

projectsToArchive.each { project ->
def validationResult = archivedProjectService.validateArchiveProject(user, project.key)
if (validationResult.isValid()) {
archivedProjectService.archiveProject(validationResult)
log.debug("Project ${project.key} has been archived")
} else {
log.warn("Project ${project.key} could not be archived: ${validationResult.errorCollection}")
}
}

1 answer

0 votes
Muhammad Ramzan_Atlassian Certified Master_
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.
November 26, 2020

Did you execute the JQL query in issue navigator and validate what it returning there?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events