gpt4 book ai didi

json - 如何通过 Bitbucket API 创建拉取请求?

转载 作者:行者123 更新时间:2023-12-05 05:10:47 48 4
gpt4 key购买 nike

TL;DR:我在哪里可以找到有关传递给 POST 请求以创建合并请求的内容的文档? (在JSON中放什么)


使用 Groovy 脚本,我试图自动化一些任务,包括在多个项目上提交/推送 tmp 分支。我想在脚本末尾的所有项目的 tmp 分支和 prod 分支之间自动创建拉取请求。为此,我尝试使用 BitBucket REST API。

我找到了 this documentation这给了我以下用于 POST 请求的端点:/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests。此点需要以下 JSON :

{
"title": "Talking Nerdy",
"description": "It’s a kludge, but put the tuple from the database in the cache.",
"state": "OPEN",
"open": true,
"closed": false,
"fromRef": {
"id": "refs/heads/feature-ABC-123",
"repository": {
"slug": "my-repo",
"name": null,
"project": {
"key": "PRJ"
}
}
},
"toRef": {
"id": "refs/heads/master",
"repository": {
"slug": "my-repo",
"name": null,
"project": {
"key": "PRJ"
}
}
},
"locked": false,
"reviewers": [
{
"user": {
"name": "charlie"
}
}
]
}

但是,我找不到有关如何构建此 JSON 的任何信息......我能猜到什么是 titledescription,但是什么是 stateopenclosed,等等?如何构建正确的 fromRef.id ?为什么 repo 名称设置为 null ?哪个属性是可选的?如果我将我的 BitBucket 登录名放在 reviewers[0].user.name 中,它会起作用吗?等等

我在这个主题上找到的每个答案都只是复制/粘贴相同的 JSON,每个人似乎都明白它是如何工作的,没有任何解释......我错过了什么吗?

无论如何,这是我真正的问题:我在哪里可以找到有关此 Pull Request JSON 对象的一些文档?

谢谢。


编辑:这不是 this post 的副本因为这不是同一个问题。我对权限/身份验证没有问题,我什至设法通过摆弄它来使请求工作。我只要求提供文档,因为我想了解我在做什么,以便最好地定制请求。虽然在 the other post 的答案中有一些(非常简单的)解释。 ,它实际上根本没有回答我的问题(见评论)。

最佳答案

使用文档 found here我能够从 PowerShell 脚本中成功创建具有最小 属性(因此推断什么是可选属性)的拉取请求。

我的示例使用 master 作为要合并到 的分支,foo 作为要合并 的分支, Project1Repository1 分别作为 BitBucket 项目和存储库。 uri如下(替换root、project和repository):https://bitbucket.example.com/rest/api/1.0/projects/Project1/repos/Repository1/pull -请求

发送以下 JSON(使用正确的 Content-TypeAuthorization header )创建拉取请求:

{
"title" : "This is the title of my pull request",
"description" : "This is the description of my pull request",
"fromRef" : {
"id" : "refs/heads/foo",
"repository" : "Repository1",
"project" : {
"key" : "Project1"
}
},
"toRef" : {
"id" : "refs/heads/master",
"repository" : "Repository1",
"project" : {
"key" : "Project1"
}
}
}

statereviewers 是可选的,在这个例子中被省略了。

关于json - 如何通过 Bitbucket API 创建拉取请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56258305/

48 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com