I was trying with below script.
Hi @Vinay
Bulk archiving Jira projects using Groovy scripts is indeed a great approach for managing project lifecycles efficiently. Your script is a good starting point, but it seems to have a few areas that might need refinement to ensure compatibility and correctness, especially depending on the Jira version you're using. Here’s an improved version with some insights and best practices:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager
import org.apache.log4j.Logger
// Logger setup
def log = Logger.getLogger("com.acme.archive")
// List of project keys to archive
def projectKeys = ["TVP"] // Replace with your project keys
// Access ProjectManager
def projectManager = ComponentAccessor.getComponent(ProjectManager)
// Loop through project keys and archive
projectKeys.each { projectKey ->
def project = projectManager.getProjectObjByKey(projectKey)
if (project) {
try {
log.info("Archiving project: ${project.name} (${project.key})")
// Set project to archived
project.setArchived(true)
projectManager.updateProject(project)
log.info("Project ${project.key} archived successfully.")
} catch (Exception e) {
log.error("Failed to archive project ${project.key}: ${e.message}")
}
} else {
log.warn("Project with key ${projectKey} not found.")
}
}
log.info("Bulk archiving completed.")
setArchived(true)
should work for Jira versions that support project archiving. Ensure that you're using a Jira version where this API is valid.JiraAuthenticationContext
ensures the correct user context.projectKeys
.projectManager.updateProject(project)
may vary depending on your Jira version or might require alternative approaches in newer APIs.If you're looking to streamline bulk actions like this or have more advanced integration needs, Getint specializes in integrating Jira with other tools and automating workflows. Let us know if you'd like assistance!
Happy scripting!
Best regards,
Renata
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.