Automatically archive old projects
Problem
Leaving old projects in Jira can actually negatively impact search performance, cause users to mistakenly view the wrong issue, and contribute to an overabundance of objects such as custom fields, workflows, and schemes in the Jira admin configurations.
Solution
Create a SIL script that is scheduled to run periodically that will check the modified date of all the issues in the project. If no issues have been modified in the past six months the project will be archived.
Script
//loop through all projects
for(string pkey in allProjects()) {
JProject proj = admProjectProperties(pkey); //get more info about the project
string projectDisplayName = proj.name + " (" + proj.key + ")"; //make it look pretty
//number of issues in that project have been modified in the last 6 months
int issueCount = countIssues("project = " + pkey + " AND updated > startOfDay(-180)");
//if no issues have been updated in the last 6 months
if(issueCount < 1) {
//display message
runnerLog("<span style='font-style: italic; color: red'>Archiving</span> project <strong>" + projectDisplayName + "</strong> because it has not been updated in the last six months.", true);
admArchiveProject(pkey); //archive entire project
} else {
//number of issues in that project have been modified in the last 3 months
issueCount = countIssues("project = " + pkey + " AND updated > startOfDay(-90)");
//if no issues have been updated in the last 3 months
if(issueCount < 1) {
//create message to display
string msg = "Project <strong>" + projectDisplayName + "</strong> has not been updated in the past 3 months. " +
"Sending <span style='font-style: italic; color: green'>notification</span> to " + userFullName(proj.lead);
runnerLog(msg, true); //display message
//create the email body
string body = projectDisplayName + " has not be updated in the past 3 month. If no updates are made within the next couple of months " +
"then this project is at risk for getting automatically archived!";
sendEmail(userEmailAddress(proj.lead), {}, projectDisplayName + "is getting dusty", body); //send email
}
}
}