Synchronize versions between projects

How could I sycnhronize versions between 2 projects please ? Or copy them from one to another ?

 

ps : I have scriptrunner so if you want to share your script with me I would be grateful to you.

 

Camille

3 answers

3 accepted

1 vote
Tarun Sapra Community Champion Dec 21, 2017

Script runner has built in script for it (in Script listener section)

Version synchroniser
Synchronises versions across multiple projects

Out of the box it's not supported in JIRA

https://jira.atlassian.com/browse/JRASERVER-2698?focusedCommentId=1691393&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-1691393

Tarun Sapra Community Champion Dec 21, 2017

from the docs

"

Please understand the functionality of the listener before implementing it in your production environment. The listener propagates the following:

  1. version creates to all target projects, when a version is created in the source project"

Tarun Sapra Community Champion Dec 21, 2017

And if you want to use groovy script in the script console to copy the version via a script then it can be easily achieved using VersionManager

https://docs.atlassian.com/DAC/javadoc/jira/7.1.0-m01/reference/com/atlassian/jira/project/version/VersionManager.html

You can get all Versions for specific project and then create versions for desired projects.

Thank you @Tarun Sapra for your great help ! I am going to use the script listener "Version synchroniser" 

 

Thank you also @Alexey Matveev and @Stefaan Quackels for your help

You can actually also rely on a synchronizer plugin such as Exalate. This plugin would allow to keep synchronized versions (and issues under it) between two different projects.

Let me know if you need any additional help figuring this out.

0 vote
Alexey Matveev Community Champion Dec 21, 2017

In ScriptRunner your script would look something like this

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.version.Version

def projectManager = ComponentAccessor.getProjectManager()
def projectSource = projectManager.getProjectObjByKey("SOURCE_PROJECT_KEY") // change project name here
def projectDestination = projectManager.getProjectObjByKey("DESTINATION_PROJECT_KEY") // change project name here

def versionManager = ComponentAccessor.getVersionManager()
List<Project> projectList = new ArrayList<>();
projectList.add(projectSource)

Collection<String> versionList = versionManager.getAllVersionsForProjects(projectList, false).stream().map{it.getName()}.collect()

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

You need to add logic how to handle already existing versions. 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

187 views 1 17
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