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

wf82jlnq  于 2022-11-01  发布在  其他
关注(0)|答案(1)|浏览(304)

我为Jira Epic工作流编写了一个groovy脚本,它允许仅在关闭所有子问题时关闭Epic。
这个脚本运行得很好,现在我想让它只对特定类型的链接问题有效。“Issues in 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
   }

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

  • 谢谢-谢谢
wfauudbj

wfauudbj1#

您可以使用

it?.issueLinkType

在封闭内。
然后您可以使用

it?.issueLinkType.inward

it?.issueLinkType.outward

以获取链接类型的传入/传出名称。

相关问题