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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Need help archiving JIRA projects

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

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
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,022 views 8 28
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you