Is there any way to copy start date and release date of releases from one project to other project?

satyanarayana_singamsetti
Contributor
January 12, 2025

Hi,

 

I would like to have groovy script to copy only start dates and target dates of the releases for one set of release from one project to other project?

Releases are already available in both the projects but only in one project releases are added with start date and target date, I would like to copy those dates from that project to other projects.

Thanks in advance.

 

Regards,

Satya

3 answers

1 accepted

1 vote
Answer accepted
Kawan Diogo
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 24, 2025

Hi @satyanarayana_singamsetti 

 

You can use the follow script to copy the Start Date and Release Date from one Version to Another version in other project.

 

Both Versions needed have the same name to work

The script consider the follows scenarios: Both date set, Just Start Date set and Just Release Date set

 

Be sure to test this script in your sandbox envirolment before try in production

Let me know if this script helps you.

 

This script just run in the Script Console

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.project.Project

import com.atlassian.jira.project.version.VersionManager

// Define source and target project keys

def sourceProjectKey = "SOURCE_PROJECT_KEY"

def targetProjectKey = "TARGET_PROJECT_KEY"

// Fetch the Version Manager

def versionManager = ComponentAccessor.getVersionManager()

// Get the source and target projects

def projectManager = ComponentAccessor.getProjectManager()

def sourceProject = projectManager.getProjectByCurrentKey(sourceProjectKey)

def targetProject = projectManager.getProjectByCurrentKey(targetProjectKey)

if (!sourceProject || !targetProject) {

    return "One or both of the projects could not be found. Please check the project keys."

}

// Fetch versions from the source and target projects

def sourceVersions = versionManager.getVersions(sourceProject.id)

def targetVersions = versionManager.getVersions(targetProject.id)

// Map target versions by name for easy lookup

def targetVersionMap = targetVersions.collectEntries { [it.name.toLowerCase(), it] } // Use lowercase for case-insensitive matching

sourceVersions.each { sourceVersion ->

    def targetVersion = targetVersions.findByName(sourceVersion.name.toString())

    if (targetVersion) {

    def originstartDate = sourceVersion.startDate

    def originReleaseDate = sourceVersion.releaseDate

        if(originstartDate && originReleaseDate) {

            versionManager.editVersionStartReleaseDate(targetVersion, sourceVersion.startDate, sourceVersion.releaseDate)

        } else if (originstartDate && !originReleaseDate) {

            versionManager.editVersionStartDate(targetVersion, sourceVersion.startDate)

        } else if (originReleaseDate && !originstartDate) {

            versionManager.editVersionReleaseDate(targetVersion, sourceVersion.releaseDate)

        }

    } else {

       

    }

}

return "Version dates updated successfully from '${sourceProjectKey}' to '${targetProjectKey}'."

0 votes
Sahir Maharaj
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2025

Hello @satyanarayana_singamsetti

You can achieve this by using a Groovy script with ScriptRunner for Jira.

The script should identify the releases in the source project and replicate their start and target dates to the corresponding releases in the destination project.

I recommend to ensure that both projects share the same release structure to avoid mismatched or incomplete data transfers.

0 votes
Richard Bariny January 13, 2025

use this:
VersionManager 

 

 

of example I create versions among project:

import com.atlassian.jira.project.version.VersionManager

versionManager = ComponentAccessor.getOSGiComponentInstanceOfType(VersionManager.class)

versionManager.createVersion(versionName, startDate, releaseDate, versionDescription, project.id, null, released)

you can rewrite it to update existing version object :) 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.12.15
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events