问题
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