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 votes
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 votes
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 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,811 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