Create Pull Request Automatically

Is it possible to create automatic Pull Request in bitbucket server after a sprint is closed in Jira server

1 answer

0 vote
Tarun Sapra Community Champion Nov 10, 2017

You can use webhook in JIRA to do a post REST call onto the BitBucket server. The webhook call can be set to be triggered only on the "sprint closed" event.

Tarun Sapra Community Champion Nov 10, 2017

Sample here

This API can also be invoked via a user-centric URL when addressing repositories in personal projects.

Create a new pull request between two branches. The branches may be in the same repository, or different ones. When using different repositories, they must still be in the same {@link Repository#getHierarchyId() hierarchy}.

The authenticated user must have REPO_READ permission for the "from" and "to"repositories to call this resource.

Example request representations:

  • application/json [collapse]

     

    EXAMPLE
    {
        "title": "Talking Nerdy",
        "description": "It’s a kludge, but put the tuple from the database in the cache.",
        "state": "OPEN",
        "open": true,
        "closed": false,
        "fromRef": {
            "id": "refs/heads/feature-ABC-123",
            "repository": {
                "slug": "my-repo",
                "name": null,
                "project": {
                    "key": "PRJ"
                }
            }
        },
        "toRef": {
            "id": "refs/heads/master",
            "repository": {
                "slug": "my-repo",
                "name": null,
                "project": {
                    "key": "PRJ"
                }
            }
        },
        "locked": false,
        "reviewers": [
            {
                "user": {
                    "name": "charlie"
                }
            }
        ]
    }

i tried curl -u user:pwd -H "Content-Type: application/json" https://localhost:7990/rest/api/1.0/projects/TES/repos/myrepo/pull-requests -X POST --data '{"title":"test","description":"test","fromRef":{"id":"refs/heads/master","repository":{"slug":"test-repo","name":null,"project":{"key":"myProject"}}},"toRef":{"id":"refs/heads/dev","repository":{"slug":"myrepo","name":null,"project":{"key":"TES"}}}}'
 

 

But it doesn't work

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,755 views 1 5
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you