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

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

Bitbucket Pipeline Pull Request Merged

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

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

- step:
- <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,

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Trello

Taco Tuesday: Your favorite Trello blog takeaway

Hello friends! From the community that brought you Welcome Wednesday, Throwback Thursday and Friday Fun, welcome to Taco Tuesday, a weekly discussion about all things Trello. The best part? One Tac...

58 views 4 3
Join discussion

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