Esnare Maussa
Esnare Maussa

Reputation: 61

Create a Pull Request on Bitbucket from the command line

Is there a git command to create a Pull Request directly on Bitbucket when pushing a Branch?

Or any other way to create Pull Request on Bitbucket directly from the command line or PHP

Upvotes: 5

Views: 6748

Answers (2)

Mehdi Chaouch
Mehdi Chaouch

Reputation: 455

You can use Bitbucket pull requests API via curl as it:

curl https://api.bitbucket.org/2.0/repositories/my-username/my-repository/pullrequests \
-u my-username:my-password \
--request POST \
--header 'Content-Type: application/json' \
--data '{
    "title": "My Title",
    "source": {
        "branch": {
            "name": "staging"
        }
    }
}'

Upvotes: 0

VonC
VonC

Reputation: 1324278

You could use the BitBucket API and POST the right command, as in this thread:

POST /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests

That is:

curl -u user:myPW -H "Content-Type: application/jso https://bitbucket.server.com/rest/api/1.0/projects/myProject/repos/myRepo/pull-requests -X POST --data @req.json

with data:

{"title":"test","description":"test","fromRef":{"id":"refs/heads/test-branch","repository":{"slug":"test-repo","name":null,"project":{"key":"myProject"}}},"toRef":{"id":"refs/heads/master","repository":{"slug":"myRepo","name":null,"project":{"key":"MyProj"}}}}

Upvotes: 4

Related Questions