JIRA-某些链接类型的Epic验证器

发布于 2025-02-09 19:18:56 字数 1744 浏览 0 评论 0原文

我为JIRA EPIC Workflow编写了一个Groovy脚本,该脚本只有在所有儿童问题均已关闭时才能关闭史诗。

该脚本效果很好,现在我想使其仅适用于特定类型的链接问题。 “史诗般的问题”

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
   }

上面的代码适用于各种链接的问题。 有人知道如何使其仅适用于特定链接类型吗?

谢谢。

I wrote a groovy script for Jira Epic workflow that enables to close the Epic only if all the child issues are closed.

The script works great, and now I want to make it valid only for a specific type of linked issue. "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
   }

The code above works for all kinds of linked issues.
Does anyone know how to make it works only for a specific link type?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

亢潮 2025-02-16 19:18:56

您可以

it?.issueLinkType

在封闭式内使用。

然后,您可以使用

it?.issueLinkType.inward

it?.issueLinkType.outward

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

You can use

it?.issueLinkType

inside the Closure.

Then you can use

it?.issueLinkType.inward

and

it?.issueLinkType.outward

to get the inward/outward name of the link type.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文