Is there a Jenkins Plugin for creating a PR to BitBucket repo?

Viewed 93

I have a repository on BitBucket, and I'm using a Jenkins pipeline script to build AMIs using packer.

Once the AMI is built successfully, I need to make changes to the code in the repository and raise a PR.

What is the simplest way to create a PR from Jenkins to a BitBucket repository?

1 Answers

From a Jenkins sh/bat step, you can use curl to call the BitBucket API and create a pull request

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