Sync the epic and epic link in visual mode

Originally asked by SDGTLS on 10 September 2021 (original question)


We need to sync also the epic link in the visual mode but there is no given option for that, so we need to have a script for the visual mode. Any ideas?


Answer by Wesley Adams on 31 October 2021

Serhiy Onyshchenko Thanks for providing the helpful script for this question! Would your script work for when issues are moved from one epic to another? If not, could you provide an additional or altered script that would cover this scenario?

Also, I have if I do not pass over any info regarding fixversions is that part of your code going to cause issues or should I just leave it in there regardless? If my remote instance is Jira Data Center (local being Jira Cloud) do I need to do any pre-work around uploading external scripts or would this all work out of the box in visual mode?


Comments:

Serhiy Onyshchenko commented on 04 November 2021

It does handle issue link change.
If your remote instance is Jira on-prem, no pre-work is necessary. Though some internal API things may be different. Please, let me know how it went.

Wesley Adams commented on 07 November 2021

It worked! Thanks Serhiy Onyshchenko !

Answer by SDGTLS on 13 September 2021

Great! it works wounderful!


Answer by Serhiy Onyshchenko on 11 September 2021

Hello, SDGTLS .
Please try adding an
Epic Name <> Epic Name
Mapping and then the following script after it:

if (executionInstanceName == "SCRUMB") { // SCRUM -> SCRUMB
    // assign fix versions from SCRUM to SCRUMB
    issue.fixVersions = replica
      .fixVersions
      // ensure that all the fixVersions are available on SCRUMB
      .collect { v -> nodeHelper.createVersion(issue, v.name, v.description) }
      
    if(replica."Epic Link"){
       def await = { f -> scala.concurrent.Await$.MODULE$.result(f, scala.concurrent.duration.Duration$.MODULE$.Inf()) }
        def orNull = { opt -> opt.isDefined() ? opt.get() : null }
        
        //getTwinTraceByRelationAndRemoteIssueUrnFuture(connection: IConnection, remoteIssueUrn: String, entityType: String): Future[Option[ITwinTrace]]
        def localEpicTt = orNull(await(syncHelper.twinTraceRepository.getTwinTraceByRelationAndRemoteIssueUrnFuture(connection, replica."Epic Link".getAsString(), 'issue')))
        def localEpic = localEpicTt?.localReplica?.issueKey
        //debug.error("localEpicTt=`${localEpicTt}` replica.'Epic Link'=`${replica."Epic Link"}`")
        if(localEpic){
            issue."Epic Link" = localEpic.urn
        }
    } else if (issue."Epic Link") {
        issue."Epic Link" = null
    }
}

Here’s the video showing how it works:

Happy Exalating!