How to create a pull request in a Bitbucket using api 1.0

浪子不回头ぞ 提交于 2021-01-27 17:48:47

问题


I am trying to create an automation pipeline and in that, I want to create a pull request in bitbucket from my jenkins job. I found some document where I can create a pull request using rest api. But that is for api 2.0. I have old bitbucket and I am not sure which api version I have to use.

Thanks,


回答1:


You can create a pull request in Bitbucket using the REST API 1.0 doing the following:

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"
            }
        }
    ]
}


来源:https://stackoverflow.com/questions/46310751/how-to-create-a-pull-request-in-a-bitbucket-using-api-1-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!