Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Creating a Pull Request from a Bamboo Plan

We have some plans ( both build and deploy) that do commit and pushes of branches. We would like to create a pull request automatically after a branch is pushed. Is there a quick way to do this? 

If we have to use Bitbucket APIs. Is there an example/documentation of how to use Python APIs for this purpose?


1 answer

1 accepted

2 votes
Answer accepted

Hi @Subhi Andrews

You could use a script task and call a REST API to create the pull request.

Below you can find two examples using the curl command, one for Bitbucket cloud and another for server.

Bitbucket Cloud

 curl<USER_NAME>/<REPOSITORY>/pullrequests \
    --request POST \
    --header 'Content-Type: application/json' \
    --data '{
        "title": "<PULL-REQUEST TITLE>",
        "description": "<PULL-REQUEST DESCRIPTION>",
        "source": {
            "branch": {
                "name": "<SOURCE_BRANCH>"
            "destination": {
                "branch": {
                    "name": "<DESTINATION_BRANCH>"

Reference: /repositories/{username}/{repo_slug}/pullrequests - Bitbucket API
⚠️Please make sure you create an app password with read/write permission for pull-requests.

Bitbucket server

curl <BITBUCKET_URL>/rest/api/1.0/projects/<PROJECT>/repos/<REPOSITORY-SLUG>/pull-requests \
    --request POST \
    --header 'Content-Type: application/json' \
    --data '{
    "title": "<PULL-REQUEST TITLE>",
    "description": "<PULL-REQUEST DESCRIPTION>",
    "fromRef": {
        "id": "<SOURCE BRANCH>",
        "repository": {
            "slug": "<REPOSITORY_SLUG>",
            "project": {
                "key": "<PROJECT>"
    "toRef": {
        "id": "<DESTINATION BRANCH>",
        "repository": {
            "slug": "<REPOSITORY SLUG>",
            "project": {
                "key": "<PROJECT>"

Reference: /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/archive - Bitbucket Server - REST

I hope that helps.


@Daniel Santos , Thanks. Could you also help us with APIs for merging the pull request?

We probably need to extract pull-request id from the creation of pull-request step.

Hi @Subhi Andrews

That should be the right direction.

  • Were you able to get it working?
  • Do you need it for Bitbucket cloud or server?

We were able to create Pull-Requests from Script task. Need an automatic merge from another script task or the same script task.

We use Bitbucket server

You will need to extract both the pull request ID version to merge it.

This is the call you can use:

Bitbucket server

curl -X POST <BITBUCKET_URL>/rest/api/1.0/projects/<PROJECT>/repos/<REPOSITORY_SLUG>/pull-requests/<PULL_REQUEST_ID>/merge?version=<VERSION> \
--header "Content-Type:application/json" \
--header "Accept:application/json"

Reference: /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/merge - Bitbucket Server REST API

Please keep us posted on your progres =]

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bamboo

Bamboo Data Center - Early Access Program

G’day Bamboo customers, The wait is almost over! We are in the final stages of work on the first release of Bamboo Data Center, our self-managed enterprise offering of Bamboo. This Data Center offe...

1,067 views 0 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you