如何使用api 1.0在Bitbucket中创建拉取请求

时间:2017-09-19 22:46:10

标签: rest jenkins bitbucket bitbucket-api

我正在尝试创建一个自动化管道,在那里,我想从我的jenkins工作中创建一个bitbucket中的pull请求。我找到了一些文档,我可以使用rest api创建一个pull请求。但那是api 2.0。我有旧bitbucket,我不知道我必须使用哪个api版本。

谢谢,

1 个答案:

答案 0 :(得分:1)

您可以使用REST API 1.0在Bitbucket中创建拉取请求,执行以下操作:

curl -s --user USER:PASS --request PUT --data @- --header Content-Type:application/json https://BITBUCKET-SERVER/rest/api/1.0/projects/TO-PROJECT/repos/TO-REPOSITORY/pull-requests << EOF
{
    "title": "SOME-TITTLE",
    "description": "SOME-DESCRIPTION",
    "state": "OPEN",
    "open": true,
    "closed": false,
    "fromRef": {
        "id": "refs/heads/FROM-BRANCH",
        "repository": {
            "slug": "FROM-REPO",
            "name": null,
            "project": {
                "key": "FROM-PROJECT"
            }
        }
    },
    "toRef": {
        "id": "refs/heads/TO-BRANCH",
        "repository": {
            "slug": "TO-REPO",
            "name": null,
            "project": {
                "key": "TO-PROJECT"
            }
        }
    },
    "locked": false,
    "reviewers": [
        {
            "user": {
                "name": "REVIEWER"
            }
        }
    ]
}