Automate issue escalation with ScriptRunner Escalation Services. Use a JQL query to modify issues based on elapsed time, and enable actions (such as transitions) to occur after a specified time has passed. For example, if a task has been opened but not assigned for seven days, you can set up an escalation service to automatically give the issue a priority status, or send an email to notify the team.
From ScriptRunner, navigate to the Jobs tab and click Create Job→Escalation Service.
In Note enter a description for the job, for example, Escalate to urgent.
Under User, enter the user the job will run as. If the job is set to leave a comment, send an email, or transition an issue, it does so as this user.
This user must have the correct permissions to execute the action (for example, transition the issue). Results of the JQL may differ depending on the permissions of the selected user.
Create a user called Automation (or similar) and give it administrator rights in every project. Then set Automation as the User when setting up an escalation service.
In the Interval/Cron Expression field, enter how often the job should run. The interval can be in minutes, entered as an integer, or a cron expression. The example shown runs every day at 6 am.
Jobs set to run at intervals run automatically upon start-up of Jira. To avoid this, use non-interval cron expressions specifying the time the job should run (as seen in the example above).
For more information on cron expressions, see Constructing Cron Expressions for a Filter Subscription.
In JQL Query, enter a query to select the issues you wish to escalate. For example, issues in a specific project that have the status To Do but have not been updated for over five days.
Test the query in the Issue Navigator first. For more information on JQL queries, see Advanced Searching.
Select an action in the Action field. This field is optional if Additional Issue Actions are specified.
Under Transition Options optionally select which options the transition should skip:
Skip Permissions: Skip any permissions issues which may stop the issue transitioning.
Skip Validators: Do not validate fields during an issue transition.
Skip Conditions: Ignore all conditions on an issue, allowing transition despite the conditions not being met.
Add custom actions into the Additional Issue Actions script field to run additional code as part of the escalation, such as, add a comment to the issue, or set a custom field.
Select Show Snippets to see examples of commonly used scripts.
Click Add to save the escalation service; the script will run on the interval specified. Optionally, click Run Now to run the script and view which issues were affected.
Clicking Run Now does not save the escalation service. Click Add to save.
Close Issues Waiting for Customers
You can use an escalation service to close issues that have been waiting for customers for over a year.
Add a short description for Note, such as Close issues waiting for customers.
Select a user to run the script as.
Enter an interval to run as in the Interval/Cron Expression field. In this example, we want the code to run every 60 minutes.
Enter the following JQL query to close issues with the Waiting for Customers status that have been open over a year:groovy
status = "Waiting for Customers" and updated < -365d
Select Close Issue under Action.
Optionally, select which Transition Options to skip.
Optionally, define a comment to post when the issue is closed.
Click Add to save the escalation service; the script runs on the interval specified.