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?
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.