Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×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!
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:-
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.