快速查找Jira问题的所有Bitbucket Pull请求

时间:2017-02-14 09:29:22

标签: git bitbucket jira jira-rest-api bitbucket-api

我想找到Jira问题的所有拉取请求。显然,这是一项可能的任务,因为Jira本身会显示信息:

Screenshot Jira/Bitbucket integration

目前,我通过Bitbucket API检索所有合并和打开拉取请求的列表,并将这些匹配模式与我的问题编号匹配。这是耗时的,甚至更多,因为我必须以100的批量加载拉取请求(Bitbucket中的最大限制),并且我们将代码分布在几个存储库中。

对bitbucket进行了集成api调用:/rest/jira/1.0/issues//commits,它将显示此问题的所有提交,但是...... / pullrequests不可用。

有谁知道,Jira如何检索这些信息?

3 个答案:

答案 0 :(得分:2)

https://github.com/jira-node/node-jira-client/issues/142

  

JIRA有一个没有证件的" dev-status"当JIRA与Stash(Bitbucket Server)等其他工具集成时,通常使用的API

首先,你必须得到 jiraIssueNumericId 。 例如,您可以通过记录良好的Jira API获取问题信息来获取它。您正在寻找的领域是" id"。 https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/?_ga=2.203378385.1940451621.1522669776-298439511.1476796418#api/2/issue-getIssue

关于 Jira dev-status API的方法

  1. 获取有关问题的分支和提取请求的信息: https://{jiraHost}/rest/dev-status/latest/issue/detail?issueId={jiraIssueNumericId}&applicationType=stash&dataType=pullrequest
  2. 获取与问题相关的提交的信息: https://{jiraHost}/rest/dev-status/latest/issue/detail?issueId={jiraIssueNumericId}&applicationType=stash&dataType=repository
  3. 获取摘要: https://{jiraHost}/rest/dev-status/latest/issue/summary?issueId={jiraIssueNumericId}
  4. P.S。此API实际上在Jira的问题页面上使用。尝试单击pull-requests链接以打开弹出窗口及其列表。在“网络”选项卡中的浏览器的开发面板中,您可以找到XHR调用或这些网址。

    P.P.S。是的,我也很难找到这些信息,我不知道为什么它没有记录。

答案 1 :(得分:0)

看起来这个端点曾经在API https://developer.atlassian.com/static/rest/stash/2.6.0/stash-jira-integration-rest.html#idp21856

中记录

但我很确定它是一个内部API,所以你不应该依赖它的稳定性。当前文档未列出https://developer.atlassian.com/static/rest/bitbucket-server/4.13.0/bitbucket-rest.html

答案 2 :(得分:0)

正确的 API:

public static DataTable ConvertToDataTable<T>(IList<T> data)
{
    PropertyDescriptorCollection properties =
        TypeDescriptor.GetProperties(typeof(T));

    DataTable table = new DataTable();

    foreach (PropertyDescriptor prop in properties)
    {
        Type dataType = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType;
        if (dataType.IsArray) dataType = typeof(string);
        table.Columns.Add(prop.Name, dataType);
    }

    foreach (T item in data)
    {
        DataRow row = table.NewRow();
        foreach (PropertyDescriptor prop in properties)
        {
            object val = prop.GetValue(item);
            if (val != null && prop.PropertyType.IsArray)
            {
                var items = ((IEnumerable)val)
                    .Cast<object>()
                    .Where(o => o != null)
                    .Select(o => o.ToString());

                val = string.Join(", ", items);
            }
            row[prop.Name] = val ?? DBNull.Value;
        }
        table.Rows.Add(row);
    }
    return table;
}

其中 https://{jiraHost}/rest/dev-status/latest/issue/details?issueId={jiraIssueNumericId}&applicationType=<scm>&dataType=<option> 可以是 bitbucket、stash 或 github
<scm> 可以是分支或拉取请求