Jira -特定链接类型的Epic验证器



我为Jira Epic工作流编写了一个groovy脚本,该脚本允许仅在所有子问题关闭时关闭Epic。

脚本工作得很好,现在我想使它仅对特定类型的链接问题有效。

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkManager
import com.opensymphony.workflow.InvalidInputException

// Allow logging for debug and tracking purposes
import org.apache.log4j.Level
import org.apache.log4j.Logger

// Script code for easy log identification
String scriptCode = "Check all issues in Epics are Done -"

// Setup the log and leave a message to show what we're doing
Logger logger = log
logger.setLevel( Level.ERROR )
logger.debug( "$scriptCode Triggered by $issue.key" )
def passesCondition = true
if (issue.issueType.name == 'Epic')
{
IssueLinkManager issueLinkManager = ComponentAccessor.issueLinkManager
def found = issueLinkManager.getOutwardLinks(issue.id).any
{
it?.destinationObject?.getStatus().getName() != 'Done' &&
it?.destinationObject?.getIssueType().getName()  != 'Epic'
}    
logger.debug( "$scriptCode Found =  $found " )
if (found) {
logger.debug( "$scriptCode return false" )
passesCondition = false
invalidInputException = new InvalidInputException("Please make sure all linked issues are in 'Done' status")
} else {
logger.debug( "$scriptCode return true" )
passesCondition = true
}
}
// Always allow all other issue types to execute this transition
else
{
logger.debug( "$scriptCode Not Epic return true")
passesCondition = true
}

以上代码适用于所有类型的关联问题。有人知道如何使它只适用于特定的链接类型吗?

谢谢。

可以使用

it?.issueLinkType

在闭包内。

那么你可以使用

it?.issueLinkType.inward

it?.issueLinkType.outward

获取链接类型的内向/外向名称。

最新更新