Automate Archiving "Released" Fix Versions
Asked by Kalyan Sattaluri:

All, I manage several projects on Jira DC edition where teams forget to archive versions after they are released and in turn use these released versions in new issues causing compliance problems, so want to automate archiving "released" versions.

I have been able to solve this problem with a work around, it works in theory but misses one use case (which I will list below) and needs to be run on a schedule more than once a day in our use case, and I was wondering if there is any easier way which I am missing.

**Solution I implemented which works:**

1. Scheduled a rule with JQL which searches for issues in released fix versions.

* fixVersion not in unreleasedVersions() AND fixversion not in archivedversions()

2. If {{issues.size}} is \>0, using {{fixversions}} smartvalue, making a call to [unresolved issues count REST API](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-versions/#api-rest-api-2-version-id-unresolvedissuecount-get) to check if it has any unresolved issues.

3. If no unresolved isssues, I [update version](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-versions/#api-rest-api-2-version-id-put) to archived, else I "un-release" the version.

*Pros*: It correctly either archives / unreleases depending in if it has unresolved issues.

*Cons*: Because it handles 1 version at a time, job needs to run frequently to catch up if a project has multiple released versions.

It cannot pick up versions which are released but have no issues in it. I know this does not make sense but we have projects who do this and this rule cannot pick them up.

**Solution I wanted to implement:**

Please NOTE: I am not on DC 9.0.2 automation, so we dont have variables / lookupissues available neither is advanced branching. We have plain vanilla automation options for conditions \& actions.

I wanted to:

1. Make a REST call to get [all project versions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-versions/#api-rest-api-2-project-projectidorkey-versions-get)

2. Loop through the response and If {{webhookResponse.body.released}} is true but {{webhookResponse.body.archived}} is false, then archive.

Problem: how do I loop through result set? When I put the above check in a if condition, I am only able to pull up the first release's value in the result set and rule stops after that (obviously.)

Is there a solution/approach I missing? Any help is appreciated or let me know if I can clarify anything else!!


Answers:
author: Bill Sheboy
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

First thing, is this for one project / team, or are many forgetting to "clean up their yard"? If it is one team this may be a training issue (until the process can be automated).

Back to your question...

I believe you have described the situation and limitations quite well! And, because Jira DC automation does not have [advanced branching yet](https://jira.atlassian.com/browse/JIRAAUTOSERVER-749), that will not help.

You could add one more rule to your set, triggered on version released, and then perform the archive with Send Web Request to the REST API function. Those three rules would cover the cases, and the frequency need would determine your schedules for the others.

Other options are:

* work with your dev teams to build your own "cleaner" app which calls the REST API and can successfully loop over versions
* investigate the Atlassian Marketplace for apps to help manage versions

Kind regards,  
Bill

comments: author: Kalyan Sattaluri
body: Wow. Thanks [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) as always!! I knew I was overthinking this thing. lol.

As you mentioned, there is a "version released" trigger and I could do the same thing very simply now that I am caught up with archiving previous versions that go forward, this is done at the same moment they release, and it will catch even the ones which have no issues.

Just additional info - We have multiple (14) projects which I help oversee in an enterprise. So this is me trying to make sure I restrict them so chances to not meet compliance is minimized in the future.

Thanks again!!