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

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.

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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

178 views 1 10
Read article

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