1

我正在尝试为 JIRA v5.x 编写转换后功能。它应该检查是否已经有一个与问题链接的 Confluence 页面,如果没有,则创建并链接该页面。我正在使用一个 groovy 脚本和可以访问 JAVA API 的 scriptrunner 插件来开发它。

虽然创建汇合页面相当容易,但我正在为远程问题链接而苦苦挣扎。

  • 如何创建新的远程问题链接?
  • 如何确定某个问题的链接是否已存在?

这就是我尝试创建链接的方式:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.bc.issue.link.RemoteIssueLinkService
import com.atlassian.jira.issue.link.RemoteIssueLinkBuilder

//I use a wrapper class for the moment so I can run via scriptrunner and debug it in IDEA
class myWrapper {

    def doStuff() {

        //get the issue, this would already be available in an post action
        def issueService = ComponentManager.getInstance().getIssueService();
        def authContext = ComponentManager.getInstance().getJiraAuthenticationContext()

        def issueResult = issueService.getIssue(authContext.getUser(), "DEV-1");
        def issue = issueResult.getIssue()

        //build link
        def linkBuilder = new RemoteIssueLinkBuilder()
        linkBuilder.issueId(issue.id)
        linkBuilder.applicationName("myconluence")
        linkBuilder.applicationType("com.atlassian.confluence")
        linkBuilder.relationship("Wiki Page")
        linkBuilder.title("testpage")
        linkBuilder.url("http://localhost:8090/display/LIN/testpage")
        linkBuilder.build()

        def validationResult = RemoteIssueLinkService.validateCreate(authContext.getUser(), linkBuilder)

    }
}

(new myWrapper()).doStuff()

当我运行代码时,出现以下异常:

javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.bc.issue.link.RemoteIssueLinkService.validateCreate() is applicable for argument types: (com.atlassian.crowd.embedded.ofbiz.OfBizUser, com.atlassian.jira.issue.link.RemoteIssueLinkBuilder) values: [admin:1, com.atlassian.jira.issue.link.RemoteIssueLinkBuilder@180ca9]

对我来说,看起来我没有正确获得RemoteIssueLinkService,但我不知道我必须做些什么来解决这个问题。

4

1 回答 1

2

我在atlassian 论坛上问过同样的问题。这是我从 Jamie Echlin 那里收到的工作答案,以供将来参考


它不是静态方法,因此您需要先获取该类的实例:

def remoteIssueLinkService = ComponentManager.getComponentInstanceOfType(RemoteIssueLinkService.class)

remoteIssueLinkService.validateCreate(...)

于 2012-11-08T21:55:39.647 回答