自动获取拉取请求主题

12
我有兴趣创建基于Pull Request描述的自动发布说明,例如屏幕上显示的“添加法律解决方案索赔报告功能”。

然而,我对Pull Requests不是很熟悉,并且我不确定“description”是否只在Bitbucket上实现。我的问题是:如何从Pull Request自动检索这个描述?我已经检查了提交的消息,但是在那里找不到它。

enter image description here


这听起来像是Bitbucket的一个插件可以实现的事情。 - Adam
您应该能够通过REST API获取描述:https://docs.atlassian.com/bitbucket-server/rest/5.9.0/bitbucket-rest.html - Will Bickford
我给你的答案没有解决你的问题吗? - Danilo Souza Morães
1个回答

阿里云服务器只需要99元/年,新老用户同享,点击查看详情
3
今天,Bitbucket有两个主要服务:Bitbucket ServerBitbucket Cloud。如果您没有下载Bitbucket服务器,您很可能正在使用Bitbucket Cloud。要连接到Bitbucket Cloud API,您可以使用Atlassian Connect构建一个应用程序来连接到Bitbucket,或者您可以使用rest apis(引用它们所有端点的参考文献:https://developer.atlassian.com/bitbucket/api/2/reference/)。 这是您将调用的API,以获取给定<username><repository name>中所有拉取请求的所有信息:
curl -u <username>:<password> https://api.bitbucket.org/2.0/repositories/<username>/<repository name>/pullrequests
如果您已经安装了jq,您可以将上述API的输出导入到它中以仅检索描述,就像您在问题中请求的那样。以下命令将列出<username><repository name>中所有拉取请求的所有描述:
curl -u <username>:<password> https://api.bitbucket.org/2.0/repositories/<username>/<repository name>/pullrequests | jq ".values[] | .summary.raw"
这是我在我的Bitbucket存储库上运行请求上述API时获得的输出:
{
    "pagelen": 10,
    "values": [
        {
            "description": "this is just a description for testing the pull request api endpoint",
            "links": {
                "decline": {
                    "href": "https://api.bitbucket.org/2.0/repositories/dhulke/ojspkp/pullrequests/1/decline"
                },
                "commits": {
                    "href": "https://api.bitbucket.org/2.0/repositories/dhulke/ojspkp/pullrequests/1/commits"
                },
                "self": {
                    "href": "https://api.bitbucket.org/2.0/repositories/dhulke/ojspkp/pullrequests/1"
                },
                "comments": {
                    "href": "https://api.bitbucket.org/2.0/repositories/dhulke/ojspkp/pullrequests/1/comments"
                },
                "merge": {
                    "href": "https://api.bitbucket.org/2.0/repositories/dhulke/ojspkp/pullrequests/1/merge"
                },
                "html": {
                    "href": "https://bitbucket.org/dhulke/ojspkp/pull-requests/1"
                },
                "activity": {
                    "href": "https://api.bitbucket.org/2.0/repositories/dhulke/ojspkp/pullrequests/1/activity"
                },
                "diff": {
                    "href": "https://api.bitbucket.org/2.0/repositories/dhulke/ojspkp/pullrequests/1/diff"
                },
                "approve": {
                    "href": "https://api.bitbucket.org/2.0/repositories/dhulke/ojspkp/pullrequests/1/approve"
                },
                "statuses": {
                    "href": "https://api.bitbucket.org/2.0/repositories/dhulke/ojspkp/pullrequests/1/statuses"
                }
            },
            "title": "adding a to test a pull request",
            "close_source_branch": false,
            "type": "pullrequest",
            "id": 1,
            "destination": {
                "commit": {
                    "hash": "6188a5897db9",
                    "type": "commit",
                    "links": {
                        "self": {
                            "href": "https://api.bitbucket.org/2.0/repositories/dhulke/ojspkp/commit/6188a5897db9"
                        },
                        "html": {
                            "href": "https://bitbucket.org/dhulke/ojspkp/commits/6188a5897db9"
                        }
                    }
                },
                "repository": {
                    "links": {
                        "self": {
                            "href": "https://api.bitbucket.org/2.0/repositories/dhulke/ojspkp"
                        },
                        "html": {
                            "href": "https://bitbucket.org/dhulke/ojspkp"
                        },
                        "avatar": {
                            "href": "https://bytebucket.org/ravatar/%7B605ba8e3-7b25-4093-9c72-f847da4b2464%7D?ts=default"
                        }
                    },
                    "type": "repository",
                    "name": "OJSPKP",
                    "full_name": "dhulke/ojspkp",
                    "uuid": "{605ba8e3-7b25-4093-9c72-f847da4b2464}"
                },
                "branch": {
                    "name": "master"
                }
            },
            "created_on": "2018-09-15T23:17:25.931924+00:00",
            "summary": {
                "raw": "this is just a description for testing the pull request api endpoint",
                "markup": "markdown",
                "html": "<p>this is just a description for testing the pull request api endpoint</p>",
                "type": "rendered"
            },
            "source": {
                "commit": {
                    "hash": "b02656e67546",
                    "type": "commit",
                    "links": {
                        "self": {
                            "href": "https://api.bitbucket.org/2.0/repositories/dhulke/ojspkp/commit/b02656e67546"
                        },
                        "html": {
                            "href": "https://bitbucket.org/dhulke/ojspkp/commits/b02656e67546"
                        }
                    }
                },
                "repository": {
                    "links": {
                        "self": {
                            "href": "https://api.bitbucket.org/2.0/repositories/dhulke/ojspkp"
                        },
                        "html": {
                            "href": "https://bitbucket.org/dhulke/ojspkp"
                        },
                        "avatar": {
                            "href": "https://bytebucket.org/ravatar/%7B605ba8e3-7b25-4093-9c72-f847da4b2464%7D?ts=default"
                        }
                    },
                    "type": "repository",
                    "name": "OJSPKP",
                    "full_name": "dhulke/ojspkp",
                    "uuid": "{605ba8e3-7b25-4093-9c72-f847da4b2464}"
                },
                "branch": {
                    "name": "teste"
                }
            },
            "comment_count": 0,
            "state": "OPEN",
            "task_count": 0,
            "reason": "",
            "updated_on": "2018-09-15T23:17:25.963178+00:00",
            "author": {
                "username": "dhulke",
                "display_name": "Danilo Moraes",
                "account_id": "557058:ab26766f-757e-4687-88ff-099bd94b0895",
                "links": {
                    "self": {
                        "href": "https://api.bitbucket.org/2.0/users/dhulke"
                    },
                    "html": {
                        "href": "https://bitbucket.org/dhulke/"
                    },
                    "avatar": {
                        "href": "https://bitbucket.org/account/dhulke/avatar/"
                    }
                },
                "type": "user",
                "uuid": "{1b22ad2c-9f1c-48f4-b9dc-958e8eddd3e8}"
            },
            "merge_commit": null,
            "closed_by": null
        }
    ],
    "page": 1,
    "size": 1
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,