There could be an opportunity for you to automatically close issues after a certain period of time in Jira. You could always use the Bulk Update mechanism to bulk transition these issues, or you could let a Groovy script execute that for you automatically (after a set period of time). Here's a script on how you can achieve this on your Jira instance.
Cover Photo by Craig Whitehead on Unsplash
Prerequisites
- Information from Jira - Jira project(s)
- Transition ID from Done to Closed
- Username that is able to execute the transition to Close
- ScriptRunner for Jira
Script to Use
The script was from a Groovy ScriptRunner bug ticket raised a few years ago. Thanks, Marcel!
The script can be viewed on this page: close-issues.groovy @ Bitbucket
Where to make changes
// Global variables to be updated before utilising the script
int daysSinceResolved = 5 ; // days to check for issue closure
int actionId = 701; // transition id from Done to Closed
String project = "TEST, JIRA"; // target project key. To include more than 1 project, include the project keys in quotes
String previousStatus = "Done"; // status to check before closing
String username = "admin"; // acting user who has the privilege to transition issues to Closed
String comment = "Automatically closing issue since it has been resolved for ${daysSinceResolved} days.";
daysSinceResolved
: number of days to check for closing issues.actionId
: the transition ID from the Done status to Closedproject
: the project key(s) to fetch the issues to closepreviousStatus
: the name of the status to check before closingusername
: the username of the user who can execute the transition from Done to Closedcomment
: the comment to add once the transition to Closed is complete
Steps to Implement the Script
- Upload the Groovy script to the
$JIRA_HOME/scripts
directory. - Ensure that the Groovy script is in
755
permissions, and owned by the user who starts JIRA:sudo chown jira:jira close-issues.groovy && chmod 755 close-issues.groovy
- In JIRA, go to Administration > Advanced > Services.
- Add a new Service, with the following information: - Name: an appropriate name for the service
- Class:
com.onresolve.jira.groovy.GroovyService
- Schedule: Days per Week (Saturday and Sunday) and set the time to execute the service
- Class:
- Click Save.
- Edit the newly created service to include the path of the Groovy script.
- Click Update.