Handling mismatched issue link types

Originally asked by Juan Carvajal on 24 June 2023 (original question)


We have 2 instances, and each has it’s own set of issue link types. The intended behavior is to have Exalate check when the issue link type is passed, and if it does not exist locally it will change the issue link to a specific type.


Answer by Juan Carvajal on 24 June 2023

Each link in the array has different properties that will need to be changed to match the desired type. From the code below, you will need to change “linkList” to match the link names available in the local instance, and the properties in the “else” statement to the linktype you want to assign when a match is not found( “relates to” was used for the properties below).

if (replica.issueLinks != null) 
    {def linkList = ["blocks", "is blocked by", "clones", "is cloned by", "duplicates", "is parent of", "is child of", "relates to"]

    if (linkList.each{it == replica.issueLinks?.linkName})
    { issue.issueLinks = replica.issueLinks }

    else
    { 
    replica.issueLinks.each {
    it.linkName = "relates to"
    it.linkTypeName = "Relates"
    it.linkType = "ISSUE"
    it.isOutward = false
    it
    }
    issue.issueLinks = replica.issueLinks    
    }
}