Add bulk release versions through script runner Edited

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

3 answers

1 accepted

0 votes

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.

Thanks Joshua for giving me the script snippet.

 

 

 


   

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. 

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)
       }
    }
}

 

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  :)

 

 



























 

 

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,760 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot