Bitbucket Pipelines trigger for code merged

Etunyi Ashime
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 20, 2024

Is there any possibility for me to set up a bitbucket pipeline which is triggered only when there is PR merged to a given specified branch ?
I noticed most PR events are when they are created or when there is a commit

2 answers

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 23, 2024

Hi @Etunyi Ashime,

A pull-requests pipeline indeed gets triggered only when a PR is created or the source branch of the PR gets updated. Even though this type of pipeline doesn't get triggered upon merge, it will run on the merged code. In the Build Setup of each step, the repo will get cloned, the PR's destination branch will get merged into the PR's source branch in that clone, and then the commands of that step's script will be executed.

If you want to trigger a pipeline when the PR is merged to a specific branch, you could set up a branch pipeline for this branch:

This pipeline will also run when new commits are pushed directly to the specified branch as well as when a PR is merged into the branch. Using branch restrictions, you could prevent users from pushing directly to the branch without a PR, so then new commits to the branch will only be possible via a PR:

Kind regards,
Theodora

0 votes
Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2024

Hi @Etunyi Ashime

Not using just standard Bitbucket pipelines start conditions, however you can use Flowie's smart pipelines plugin which gives you greater control on when pipelines are triggered. You can define an event and/or a condition to trigger a pipeline. In your case, it would be PR merged event with a branch condition.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events