How to sync Multiple JIRA project ( on Local Instance) to JIRA project in Remote Instance with Many to One mapping of Issues?

Answer by Juan Grases on 15 May 2020

Hi!

Something that is possible with exalate is to automatic connect to a remote issue based on a custom field value representing the remote issue key, in that case, your outgoing script would look like this:

import com.atlassian.jira.component.ComponentAccessor
import com.exalate.api.replication.out.IEventSchedulerService
import com.exalate.api.trigger.ISyncInitiationService

def syncService = ComponentAccessor.getOSGiComponentInstanceOfType(ISyncInitiationService.class)

def ess = ComponentAccessor.getOSGiComponentInstanceOfType(IEventSchedulerService.class)
   
if(firstSync && syncType == "EXALATE"){
  def remoteIssueKey =  issue.customFields."Remote Issue"?.value
  if(remoteIssueKey){
    syncService.connect(
      issue.key, // specify the issue key you want
      remoteIssueKey, // specify the issue key you want
       connection.name, // set the relevant connection name
      ,false, true, true, false
    )
    ess.scheduleSyncEventForConnectedIssue(issueKey, connection)
  }
}else{
    replica.summary = issue.summary
    replica.description = issue.description
    replica.status = issue.status
    replica.attachments = issue.attachments
    replica.key = issue.key
    replica.workLogs = issue.workLogs
}

In this example, when the issue is exalated (this can be automated with a trigger) it will be connected with the remote issue based on a custom field named “Remote Issue”. Would this work for your case?


Comments:

Sai Thakur commented on 16 May 2020

This might work for us, I will implement and let you know. Thank you so much, great help.