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

Is it possible for a pipeline to run only after a pull request has been approved and merged?

Adam Spain August 4, 2022

Right now, a pipeline runs as soon as a Pull Request is created. Meaning, it runs before the pull request has been approved or merged. This is not ideal - what if the pull request requires revisions? 

 

Is there a way to specify in the `bitbucket-pipelines.yml` to only deploy upon a merged pull request, rather than as soon as the PR is created? 

 

My current pipeline looks like this:

pipelines:
pull-requests: # The branch pattern under pull requests defines the source branch.
dev:
- step:
name: Deploy to Production
deployment: Production
script:
- do stuff
- deploy stuff
services:
- docker

 

 

For example, in github actions, you can do something like:

prod-push:
if: github.event.action == 'closed' && github.event.pull_request.merged == true

1 answer

0 votes
Brendon Parker August 6, 2022

Sounds like you want the pipeline to run off of the merge to main, not on the pull request. Something like: 

 

pipelines:
branches:
main:
- step:
name: Deploy to Production
deployment: Production
script:
- do stuff
- deploy stuff
services:
- docker

Suggest an answer

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

Atlassian Community Events