Add bulk release versions through script runner

Noby December 5, 2017

How to use scriptrunner scripts to add bulk release versions from a csv file for multiple projects or any other option to achieve it?

4 answers

1 accepted

2 votes
Answer accepted
Joshua Yamdogo @ Adaptavist
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.
December 7, 2017

Hi,

You could run a script like this in the Script Console:

import com.atlassian.jira.component.ComponentAccessor

def projectManager = ComponentAccessor.getProjectManager()
def project = projectManager.getProjectObjByKey("CONFIG") // change project name here

def versionManager = ComponentAccessor.getVersionManager()

def versionList = ["CONFIG_18.01.01", "CONFIG_18.01.02", "CONFIG_18.01.03", "CONFIG_18.01.04",
"CONFIG_18.01.05", "CONFIG_18.02.01"]

for (version in versionList) {
log.debug("Now adding version " + version + " to " + project.name)
versionManager.createVersion(version, new Date(), new Date() + 7, "New version description", project.id, null)
}

For each project, you just need to change the project name on line 4. For versionList on line 7, you could just copy and paste the Fix Version/s from your Excel spreadsheet. 

After running the script in my instance:

Screen Shot 2017-12-07 at 10.46.25 AM.png

Please note the parameters used for createVersion on line 11. You will need to change the start/end date according to your specifications. See more about the createVersion method here.

Noby December 7, 2017

Thanks Joshua for giving me the script snippet.

 

 

 


   

Holan Shetlar February 15, 2018

This works great, however I need to have different dates for each fixed version.  How would I alter it to include custom dates for each fixed version. 

Venkata Gunta April 15, 2020

Hi Joshua Yamdogo @ Adaptavist , is there a way to do it using CSV file in Scriptrunner?

2 votes
Noby December 7, 2017

Hi Joshua Yamdogo @ Adaptavist Thanks much.

My requirement was to create more than 400 + versions across projects so had to tweak the scripts like below. Likewise , for different patterns I did update the contents inside createVersion( ).

Now for next release (year 2019) , I only need to change 18 to 19 :)

 

// Script to create version pattern <Project>_18.01.00 ,
// <Project>_18.01.02 ... <Project>_18.12.05 and so on

import com.atlassian.jira.component.ComponentAccessor

def projectManager = ComponentAccessor.getProjectManager()
def versionManager = ComponentAccessor.getVersionManager()

["PROJECT1","PROJECT2","PROJECT3","PROJECT4" ].each {  //Change project names here
def project = projectManager.getProjectObjByKey("${it}")

//loop to create version list

for(int i=0; i<=12; i++) {
    for(int j=1; j<=5; j++) {
        String secondStr ="";
        String thirdStr ="";
        if(i <10) {
            secondStr = "0"+i;
        } else {
            secondStr = i;
        }
        if(j <10) {
            thirdStr = "0"+j;
        } else {
            thirdStr = j;
        }
        versionManager.createVersion( "${it}"+"_18."+ secondStr + "." + thirdStr,null,null, "Release Description",project.id,null)
       }
    }
}

 

0 votes
Laura Colon September 24, 2020

Is there a way to do this without a script? or can someone point me to where I can find script runner in JIRA?

Crystelle S
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.
February 24, 2021

Hi Lauren, this is so old but here is a link to the information on ScriptRunner - this is an add-on so "where i can find scriptrunner" would be predicated on whether you have it added on.

https://www.adaptavist.com/products/atlassian-apps/scriptrunner-for-jira

0 votes
Noby December 7, 2017

Hi Joshua Yamdogo @ Adaptavist .

I utilized your script and made some more tweaks as my requirement was to create more than 400 + versions across projects . So wrote a scripts like below and made couple of more scripts to suit different version patterns.

Now for next activity ( year 2019 release) I only needed to change 18 to 19 on line 28  :)

 

 



























 

 

Patrick Henningsen May 21, 2019

Joshua Yamdogo @ Adaptavist 

 

This thread is very old, but I am hoping that someone may see my question.

How to you have the Fix Version Start Date and Release Date increment with the Fix Version.

For example: We are doing Fix Versions by date. I want a 5/21/19 Fix Version to have a 5/21/19 Start Date and End Date.

I have gotten where I can have blank fields but I would like the three fields to match with the same date.

 

Thanks!

Suggest an answer

Log in or Sign up to answer