How do I sync links from Jira "relates to" to ADO "Related"

Originally asked by Tomás O’Flaherty on 05 May 2022 (original question)


I have many links that I want to maintain between Jira issues and their synced ADO counterparts.

One is the “implements”/“implemented by” link in Jira which translates to “Parent”/“Child” in ADO for us. This I can do on the ADO side via the ‘syncHelper.getLocalIssueKeyFromRemoteId’ call and the ‘workItem.parentId =’ assignment

Another is “relates to”/“related by” link in Jira which translates to “Related”/“Related” in ADO for us. The problem is I dont know how to set this in ADO.

  • Does ADO support sending something like replica.issuelinks = workItem.Links?

  • Can I set a link in ADO via something like this workItem.Links += createLink(FromWorkItem, ToWorkItem, LinkType)?

    • For instance with something like following which I don’t think anything like it exists right now
    for(int i = 0; i < numberOfRelatesLinks; i++)
    {
        fromWorkItem = RelatesLinks[i][0]
        toWorkItem = currentIssue
        linkType = RelatesLinks[i][1]
        workItemLinkArray += nodeHelper.getLink(fromWorkItem, toWorkItem, linkType)
    }
    workItem.Links = workItemLinkArray
    

Comments:

Tomás O'Flaherty commented on 06 May 2022

As an update
I am able to use some Jira packages to create links. These are

import com.atlassian.jira.issue.link.IssueLinkManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.security.JiraAuthenticationContext

This allows me to use

def otherIssue = "ABC-1"
def issue1 = ComponentAccessor.issueManager.getIssueByCurrentKey(issue.key)
def issue2 = ComponentAccessor.issueManager.getIssueByCurrentKey(otherIssue)
def user = authContext.getLoggedInUser();
issueLinkManager.createIssueLink( issue1.getId(), issue2.getId(), Long.parseLong(LinkType), Long.valueOf(1), user)

However the following fails when I want to set the otherIssue

def parentId = replica.parentId 
def localParent = syncHelper.getLocalIssueKeyFromRemoteId(replica.parentId.toLong())

This comes from the doco

https://docs.idalko.com/exalate/display/ED/getLocalIssueKeyFromRemoteId

On the sync helper page its associated with both Jira and ADO but it wont work on the Jira incoming sync (but does work on the ADO incoming sync)

https://docs.idalko.com/exalate/display/ED/syncHelper

Answer by Serhiy Onyshchenko on 22 May 2022

Hello, Tomás O’Flaherty , well done looking at the methods there.
Might I ask you to share the error you are getting when using this method on ADO?
In case, if it doesn’t generate any error, is the linked issue synced with the same connection?
Regards, Serhiy.