我为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
}以上代码适用于各种链接问题。有人知道如何使它只适用于特定的链接类型吗?
谢谢。
发布于 2022-07-03 11:31:50
您可以使用
it?.issueLinkType在关闭的内部。
然后你可以用
it?.issueLinkType.inward和
it?.issueLinkType.outward若要获取链接类型的内向/外向名称,请执行以下操作。
https://stackoverflow.com/questions/72730795
复制相似问题