The Exalate team will be on holiday for the coming days - returning Jan 4
Enjoy & stay safe

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction


Since we can not use the the HTTP Client in Jira On Prem to link tickets, we are going to use the Component Accessor.


The only requirement is that in the source side (This can be any ITSM that we support), the ticket ID of it's linked counterpart gets sent. 


Then on the incoming sync in Jira we just have to implement this and we are good to go.

Right now it is a "Relates To" link, if you want to change that, please change the linkTypeId in the following code.



Code Block
languagegroovy
titleIncoming Sync Jira On Prem
linenumberstrue
//imports

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager


if(replica.relationid){

//getting Issue Manager component
def issueKeyFinder = ComponentAccessor.getComponent(IssueManager)

//sourceIssueId
def idThisIssue = issueKeyFinder.getIssueByCurrentKey(issue.key)

//destinationIssueId
def exalateId = nodeHelper.getLocalIssueFromRemoteUrn(replica?.relationid)?.key
def idIssueToBeLinked = issueKeyFinder.getIssueByCurrentKey(exalateId)


def sourceIssueId = idThisIssue.id 
def destinationIssueId = idIssueToBeLinked.id   
def linkTypeId = 10003
def sequence = 1L 
def remoteUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()



def issueLinkManager = ComponentAccessor.getComponent(IssueLinkManager)
issueLinkManager.createIssueLink(sourceIssueId, destinationIssueId, linkTypeId, sequence, remoteUser)


}

...