1

我需要以编程方式创建从一个问题到另一个问题的“相关”类型的链接。我找到了一个方法

createIssueLink(Long sourceIssueId, Long destinationIssueId, Long issueLinkTypeId, Long sequence, User remoteUser) 

在 IssueLinkManager 中,但无论如何我都找不到获取 issueLinkTypeId。有人可以帮我吗?

4

2 回答 2

1

您可能想使用

    Collection linkTypes = issueLinkTypeManager.getIssueLinkTypesByName(name);

然后迭代直到找到你想要的 IssueLinkType 实例,然后是 linkType.getId()

对于远程访问,我建议使用 jira-python 库和create_issue_link方法。

在内部,该方法执行此操作:

def create_issue_link(self, type, inwardIssue, outwardIssue, comment=None):
    """
    Create a link between two issues.

    :param type: the type of link to create
    :param inwardIssue: the issue to link from
    :param outwardIssue: the issue to link to
    :param comment:  a comment to add to the issues with the link. Should be a dict containing ``body``\
    and ``visibility`` fields: ``body`` being the text of the comment and ``visibility`` being a dict containing\
    two entries: ``type`` and ``value``. ``type`` is ``role`` (or ``group`` if the JIRA server has configured\
    comment visibility for groups) and ``value`` is the name of the role (or group) to which viewing of this\
    comment will be restricted.
    """
    data = {
        'type': {
            'name': type
        },
        'inwardIssue': {
            'key': inwardIssue
        },
        'outwardIssue': {
            'key': outwardIssue
        },
        'comment': comment
    }
    url = self._get_url('issueLink')
    r = self._session.post(url, data=json.dumps(data))

〜马特

于 2012-12-11T22:28:31.013 回答
0

这应该适用于 Jira 7.x

使 2 个问题相互关联

curl -u user:password -w '<%{http_code}>' -H 'Content-Type: application/json' https://jira.instance.com/rest/api/2/issueLink -X POST --data '{"type":{"name":"Related Incident"},"inwardIssue":{"key":"ISS-123"},"outwardIssue":{"key":"SYS-456"}}'
于 2016-12-21T20:00:13.810 回答