Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Release versions from a project

Nag August 26, 2022

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

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Ram Kumar Aravindakshan _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.
August 29, 2022

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

Nag August 29, 2022

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!

TAGS
AUG Leaders

Atlassian Community Events