This page provides an overview of how to use API to archive your projects and issues in Jira. Project archiving is available in Jira Data Center 7.10, or later. Issue archiving was relased in Jira Data Center 8.1.
You can archive any project or issue in Jira if you're no longer working on it. This helps you clean your instance of unused content and also improve performance. After you archive a project, it will be removed from the list of projects, project pickers, and search results. Both you and your users won't be able to access the project itself, but you will be able to view all issues from an archived project if they're mentioned or linked in other projects. These issues will be read-only.
All data related to an archived project will remain in the database, and you can restore the project whenever you need it again.
Here are some examples of how to archive and restore your projects or issues with REST API. For more info about these API calls, see Jira REST API docs:
curl -X PUT https://jira-instance1.net/rest/api/2/issue/PROJ-1/archive
curl -d '["KEY-1", "KEY-2"]' -H "Content-Type: application/json" -X POST https://jira-instance1.net/rest/api/2/issue/archive
curl -X PUT https://jira-instance1.net/rest/api/2/issue/PROJ-1/restore
curl -X PUT https://jira-instance1.net/rest/api/2/project/PROJ/archive
After restoring a project, you need to re-index it to make it appear again in the search results. You can do it in Jira by going to Project settings > Re-index.
curl -X PUT https://jira-instance1.net/rest/api/2/project/PROJ/restore
Here are some examples of how to archive and restore your projects with JAVA API. For more info about these API calls, see Jira JAVA API documentation:
1 2ValidationResult validationResult = archivedIssueService.validateArchiveIssue(authContext.getLoggedInUser(), issue.getKey()); if (validationResult.isValid()) { archivedIssueService.archiveIssue(validationResult); }
ComponentAccessor.getProjectManager().getArchivedProjects();
curl -X PUT https://jira-instance1.net/rest/api/2/project/PROJ-1/restore
1 2ValidationResult validationResult = archivedProjectService.validateArchiveProject(authContext.getLoggedInUser(), project.getKey()); if (validationResult.isValid()) { archivedProjectService.archiveProject(validationResult); }
After restoring a project, you need to re-index it to make it appear again in the search results. You can do it in Jira by going to Project settings > Re-index.
1 2ValidationResult validationResult = archivedProjectService.validateRestoreProject(authContext.getLoggedInUser(), project.getKey()); if (validationResult.isValid()) { archivedProjectService.restoreProject(validationResult); }
You can use the ProjectArchivedEvent and ProjectRestoredEvent event listeners to notify your plugins whenever a project is archived or restored. Here's an example implementation:
1 2public class ArchivedProjectEventListener { private static final Logger log = LoggerFactory.getLogger(ArchivedProjectEventListener.class); @EventListener public void onProjectArchived(ProjectArchivedEvent event) { // Removing the data related to event.getProjectId() // e.g. cache, or plugin data. log.info("A project has been archived."); } }
We recommend that your plugins remove any non-critical data related to archived projects. An example of that is removing data from the index, which Jira does automatically when archiving a project. This data is preserved in the database and can be easily restored later, and there's no need to store it in Jira.
Rate this page: