Pipeline requirements:
- We have branches for our development-staging (dev), staging, and production (release) environments.
- For every pull request, we want to run build and test steps before it gets merged into the target branch, to ensure that we don't merge broken code.
- Once a PR is merged into an environment branch, the branch is built, tested, and deployed.
The problem:
When I open a PR to merge master into staging (or staging into release), two pipelines are triggered: one for the PR and one for master branch. This triggers the deploy step for the master branch unnecessarily.
The documentation mentions this, but doesn't give any direction on how to prevent the two pipelines from running.
Is there a way to check if it's a pull request inside the master pipeline definition and cancel the pipeline if it is?
Here's the relevant part of my `bitbucket-pipelines.yml` file:
pipelines:
pull-requests:
'**':
- step: *build-test
branches:
master:
- step: *build-test
- step:
<<: *docker
deployment: Dev
staging:
- step: *build-test
- step:
<<: *docker
deployment: Staging
release:
- step: *build-test
tags:
v*:
- step: *build-test
- step:
<<: *docker
deployment: Production
trigger: manual