Auto close resolved tickets which are older than seven days.

Rahul R July 18, 2011

Hi,

Can anybody please help me in writing the jelly script/ or any other method for closing only resolved tickets which are older than 7 days. I have got the following info

http://confluence.atlassian.com/display/JIRA/Jelly+Escalation

But this seesm to be for closing all incative tickets. I don't want that to happen in my environment. I want a script which can be run as a service from JIRA which closes only the tickets which has a status as "Resolved" and which are older than 7 days.

3 answers

2 votes
Rahul R July 19, 2011

I think I found the solution myself. For future reference. Here is what we have to do.

Create a user which is part of all of your groups as "jira-housekeeper".

Search issues which are in resolved state and more than 7 days old in JIRA for a project. Save the result as a filter. Find the filter id (by viewing the page source where you have the saved filters and by searching for "filterId") .

and use the following script.

=======================================

<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log" >
<jira:Login username="jira-housekeeper" password="88888">

<log:warn>Running Close issues service</log:warn>

<!-- Properties for the script -->

<core:set var="comment">This issue has not been updated for 10 business days and will be Closed.

If this issue has not been completed please reopen this issue.

Thank you,
DQA TEam</core:set>
<core:set var="workflowStep" value="Close Issue" />
<core:set var="workflowUser" value="jira-housekeeper" />
<!-- Run the SearchRequestFilter -->
<jira:RunSearchRequest filterid="11571" var="issues" />
<core:forEach var="issue" items="${issues}">
<jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" comment="${comment}" workflowAction="${workflowStep}"/>
</core:forEach>
</jira:Login>
</JiraJelly>

============================================

How to for running this script from JIRA.

To run a Jelly script once:

  1. Log in as a user with the 'JIRA System Administrators' global permission.
  2. Bring up the administration page by clicking either the 'Administration' link on the top bar or the title of the Administration box on the dashboard.
  3. Under the 'Options & Settings' sub-menu in the left-hand navigation column, click the 'Jelly Runner' link.
  4. Paste your Jelly script into the text area.

To run a Jelly script periodically:
Configure a service with the following class: <tt>com.atlassian.jira.jelly.service.JellyService</tt>.

VenugopalY March 3, 2013

Hi I treid and its works for me. Thank you verymuch. This meets our requirements.

2 votes
Colin Goudie
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 19, 2011

I'm sure I answered this somewhere on answers but can't find it. So here is a small paste from a script I have used before

<jira:Login username="USERNAME" password="PASSWORD">
<!-- Value below is the filter id -->
<core:set var="insufficientInformationNotRespondedFilter" value="10571" />

<!-- Run the SearchRequestFilter -->
<jira:RunSearchRequest filterid="${FILTER_WHICH_DETERMINES_WHAT_ISSUES_TO_CLOSE}" var="issues" />

<core:forEach var="issue" items="${issues}">
<core:set var="workflowStep" value="51" /> <!-- Closed due to no response id -->
<core:set var="resolutionStep" value="5" /> <!-- Resolution id -->

<log:warn>Closing inactive issue ${issue.key}</log:warn>

<jira:TransitionWorkflow key="${issue.key}" user="${issue.assignee}" assignee="${issue.assignee}" workflowAction="${workflowStep}" comment="${message}" resolution="${resolutionStep}"/>
</core:forEach>
</jira:Login>
2 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 18, 2011

All you need to do is change the filter and actions that "jelly escalation" uses. If you look at it closely, you'll see it works by saying "read filter X and do Y to all issues on it". Change the filter to one that says "resolved, last change more than 7 days ago" and the action to "close" and it'll do the job.

Rahul R July 19, 2011

I am a bit new to jelly scripting. Can you please expalin it further more. like how can I do this for a particular project?

Suggest an answer

Log in or Sign up to answer