33 lines
970 B
Groovy
33 lines
970 B
Groovy
package utils
|
|
|
|
class LinkedIssueTransitions {
|
|
|
|
static String findSingleLinkedTargetKey(Map issueJson,
|
|
String linkTypeName,
|
|
String targetProjectKey) {
|
|
def links = (issueJson?.fields?.issuelinks ?: []) as List
|
|
if (!links) return null
|
|
|
|
String prefix = "${targetProjectKey}-"
|
|
def targets = [] as List<String>
|
|
|
|
links.each { l ->
|
|
def inwardName = l?.type?.inward?.toString()
|
|
def outwardName = l?.type?.outward?.toString()
|
|
|
|
if (inwardName == linkTypeName && l?.inwardIssue?.key) {
|
|
def k = l.inwardIssue.key.toString()
|
|
if (k.startsWith(prefix)) targets << k
|
|
}
|
|
if (outwardName == linkTypeName && l?.outwardIssue?.key) {
|
|
def k = l.outwardIssue.key.toString()
|
|
if (k.startsWith(prefix)) targets << k
|
|
}
|
|
}
|
|
|
|
targets = targets.unique()
|
|
if (targets.size() != 1) return null
|
|
|
|
return targets[0]
|
|
}
|
|
} |