Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,361,185
Community Members
 
Community Events
168
Community Groups

Release versions from a project

Hi There,

We have a fixversions that are created with same pattern like Release-202205, Release-202206, Release-202207 etc. none of them specified start or release dates.

Here May release = Release-202205

June release = Release-202206

July release = Release-202207

I'm trying to build a groovy script to release all the releases from last month or older(based on the pattern). 

Appreciate if you have any suggestions how to build this using ScriptRunner jobs.

 

Thanks in advance!

1 answer

1 accepted

0 votes
Answer accepted

Hi @Nag

For your requirement, you could try using ScriptRunner's Custom Scheduled Job.

Below is a sample code for your reference:-

import com.atlassian.jira.component.ComponentAccessor
import java.text.SimpleDateFormat

def versionManager = ComponentAccessor.versionManager
def dateFormat = new SimpleDateFormat('yyyyMM')

def calendar = Calendar.instance
calendar.setTime(new Date())
calendar.add(Calendar.YEAR, 0) // current year
calendar.add(Calendar.MONTH,-1) // previous month

versionManager.allVersions.each {
if (it.name.contains(dateFormat.format(calendar.time))) {
versionManager.releaseVersion(it, true)
}
}

null

Please note that the sample code provided is not 100% exact to your environment. Hence, you will need to make the required modifications.

Below is a screenshot of the configuration:- image1.png

In the sample code above, the date range is set to one month before, i.e. the previous month. 

If you intend to run this every month, I suggest that versions that are older than one month be run using the ScriptRunner console first.

Alternatively, if you want to run all of it using the Scheduled Jobs, you will need to configure multiple Scheduled Jobs according to the date range.

I hope this helps to answer your question. :)

Thank you and Kind regards,

Ram

Thanks @Ram Kumar Aravindakshan _Adaptavist_

That's very quick. the solution is working as per my question.

Sorry I missed to add I'm looking to release versions only on specific list of 6 projects.

I believe it's possible that I can define them in an array. Also appreciate if there is any explanation how it's working. 

 

It's short and simple, that helps me to learn. Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Online AMA this week: Your project management questions answered by Jira Design Lead James Rotanson

We know that great teams require amazing project management chops. It's no surprise that great teams who use Jira have strong project managers, effective workflows, and secrets that bring planning ...

204 views 1 6
Read article

Atlassian Community Events