I want to sync parent and related links from ADO to Jira
Hi
Here is the ADO Outgoing sync script:
replica.parentId = workItem.parentId
def res = httpClient.get("/_apis/wit/workitems/${workItem.key}?\$expand=relations&api-version=6.0",false)
if (res.relations != null)
replica.relations = res.relations
Jira Incoming sync script:
//for parent link
if (replica.parentId) {
def localParent = syncHelper.getLocalIssueKeyFromRemoteId(replica.parentId.toLong())
if (localParent) {
issue.customFields."Epic Link".value = localParent.urn
}
}
// for related link
replica.relations.each {
relation ->
// We check on the Related attribute from ADO and link it wiht Relates in Jira
if (relation.attributes.name == "Relates"){
def a = syncHelper.getLocalIssueKeyFromRemoteId(relation.url.tokenize('/')[7])//?.urn
def foundLink = false
def res1=""
if(issue.issueLinks.size()==0){
foundLink = false
}else{
issue.issueLinks.each {
issueLink ->
issueLink.properties.each
{
property, value ->
res1=res1+ "$property: $value"+"---"
}
// Check if both conditions are met
if (issueLink?.otherIssueId == a?.id && issueLink.linkTypeName == 'Relates') {
foundLink = true
return
}
}
}
if (foundLink){
log.error("Skipping to add link as it is already there, links of jira issue:"+res1)
}
else{
def res = httpClient.put("/rest/api/2/issue/${issue.key}", """
{
"update":{
"issuelinks":[
{
"add":{
"type":{
"name":"Relates"
},
"outwardIssue":{
"key":"${a.urn}"
}
}
}
]
}
}
""")
}
}
}
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.