Can I merge two branches via API call without pull request


#1

Obviously I can go through the website and do a compare branches or tags to see the differences in branches, from there I can click the merge button to merge the two branches. Am I able to do this via the rest API?

I see this using pullrequests:

http://example.com/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/merge [POST, GET]

However we do not use pull requests for this so I am looking to just merge branches via the rest API.

Thanks for the help.


#2

Hey @travisw,

Quick question: are you using Bitbucket Cloud or Server?


#3

We are using Bitbucket Server


#4

Hey @travisw,
Merging a git branch via the REST API is indeed not possible.

But there might be a solution out there for you,
You said that you don’t use the Pullrequests so what if we do only use it via the REST API?

So we could create a pullrequest with branch A and B via the REST API, and merge this pullrequest. You need to make sure no approvers are needed or builds (this is done in the settings). Merge the pullrequest hence merging Branch A into Branch B.
And if you want to you possibly delete the pullrequest afterwards.
Here are the docs related to PR’s
Here are some docs about the PR REST api
https://docs.atlassian.com/bitbucket-server/rest/5.10.0/bitbucket-rest.html#idm532061891456