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}")
}
}
Did you execute the JQL query in issue navigator and validate what it returning there?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.