Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket Pipeline Pull Request Merged

Mike Reeves September 28, 2020

Hello. I am trying to implement a auto `package.json` versioning feature for my team. So the way it would work is if there is an open pull request with the source branch with the name `bugfix/**` it will update the project version patch number. But i only want to do that when a pull request is merged so i know what the source branch is.

 

If I use the branches pipeline i dont know information about what branch was just merged so i can use that branch as a variable to my  auto `package.json` versioning script.

 

Is there a way to achieve this feature?

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 28, 2020

Hi Michael,

I'm afraid that it is not possible to run a Pipelines build when a pull request is merged. It is possible to run it when a pull request is created (in this case it also runs when the source branch gets updated), however the build will still run on the merge commit.

Here is how it works: if you have in your yml file a definition like the following

pipelines:
pull-requests:
'bugfix/**':
- step:
script:
- <commands here>

Then a build is going to run every time you open a pull request with source branch bugfix/**.

When the build is triggered, a Docker container will start. The repo will be cloned in this Docker container. The merge will happen (in the clone that exists in the Docker container, not in the Bitbucket repo) and then the script will run on this merge commit.

If you have such a build, you can get the source branch with the variable $BITBUCKET_BRANCH.

We also have a feature request for running builds when a pull request is merged:

If you'd be interested in this, I would suggest to add your vote and also your feedback in that public ticket, for our product managers to take into account.

If you have any questions, please feel free to let me know.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events