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
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}'."
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.