使用 REST API 1.0,我可以执行以下操作
POST /api/1.0/repositories/{owner}/{repo}/pullrequests/1/comments
这在 2.0 中相当于什么?pullrequests 资源的2.0文档指出“最后,您也可以使用此资源来管理对拉取请求的评论。” 我没有看到类似 1.0 伴侣的评论的 POST;PUT 也没有对评论做任何事情。
2.0 支持在 PR 上发表评论吗?
使用 REST API 1.0,我可以执行以下操作
POST /api/1.0/repositories/{owner}/{repo}/pullrequests/1/comments
这在 2.0 中相当于什么?pullrequests 资源的2.0文档指出“最后,您也可以使用此资源来管理对拉取请求的评论。” 我没有看到类似 1.0 伴侣的评论的 POST;PUT 也没有对评论做任何事情。
2.0 支持在 PR 上发表评论吗?
我知道自从提出这个问题以来已经有很长时间了,但是对于来这篇文章的人来说:
Bitbucket 终于添加了一种使用其 2.0 API 发表评论的方法。您查看文档以获取更多信息。
这是一个例子:
curl -X POST -d '{"content": { "raw": "your comment" }}' $URL
不幸的是,拉取请求评论目前在 2.0 中是只读的。我们绝对热衷于完成该 API,但这些努力的优先级相当低。
目前,1.0 仍然是改变 PR 评论的唯一方法。
首先,您需要使用以下命令获取拉取请求 ID:
curl -s --request GET --url '{bitbucket_url}/rest/api/1.0/projects/{project_key}/repos/{repo_key}/pull-requests?State=OPEN&at=refs/heads/'${BranchName}'&direction=OUTGOING' --header 'Content-Type: application/json' -H 'Authorization:Basic {bitbucket_authentication_token}' | sed -n 's/.*"values":\[{"id":\([0-9]*\).*/\1/p'
然后使用此命令添加注释:
curl --request POST '{bitbucket_url}/rest/api/1.0/projects/{project_key}/repos/{repo_key}/pull-requests/{pull_request_id}/comments' --header 'Content-Type: application/json' -d {"text": "Add your comment here"} -H 'Authorization:Basic {bitbucket_authentication_token}'