How to use scriptrunner scripts to add bulk release versions from a csv file for multiple projects or any other option to achieve it?
Hi,
You could run a script like this in the Script Console:
import com.atlassian.jira.component.ComponentAccessordef projectManager = ComponentAccessor.getProjectManager()def project = projectManager.getProjectObjByKey("CONFIG") // change project name heredef 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:
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.
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
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 onimport com.atlassian.jira.component.ComponentAccessordef projectManager = ComponentAccessor.getProjectManager()def versionManager = ComponentAccessor.getVersionManager()["PROJECT1","PROJECT2","PROJECT3","PROJECT4" ].each { //Change project names heredef project = projectManager.getProjectObjByKey("${it}")//loop to create version listfor(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) } }}
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.
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!
Hi Joshua Yamdogo @ Adaptavist , is there a way to do it using CSV file in Scriptrunner?
Is there a way to do this without a script? or can someone point me to where I can find script runner in JIRA?
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
It looks like you're new here. Sign in or register to get started.