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
Accepted answer
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 [cPrime] and @Stefaan Quackels for your help

0 votes
Accepted answer

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. 

Hi @Alexey Matveev [cPrime],

Good job. I have enhanced it a little, not to loose any metadata of versions

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<Version> versionList = versionManager.getAllVersionsForProjects(projectList, false)

for (version in versionList) {
log.debug("Now adding version " + version + " to " + projectDestination.name)
versionManager.createVersion(version.name, version.startDate, version.releaseDate, version.description, projectDestination.id,null, version.released)
}

The existing version logic is still missing.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,299 views 12 19
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