Why bitbucket pipeline merges pull request before it runs?

Viewed 677

In their documentation regarding pull request pipelines, bitbucket says:

Pull requests: a special pipeline that only runs on pull requests initiated from within your repository. It merges the destination branch into your working branch before it runs. If the merge fails, the pipeline stops.

So I'm wondering, why merging before running the pipeline? Why not just running against the coming branch without merging? Could the reason be detecting merge conflicts early on in the pipeline before the real merge?

1 Answers

If you want to run a pipeline against the coming branch, this is very doable by using Branch workflows. PR merge trigger is just a slightly different idea, as the result of a PR merge is not necessarily the same as the coming branch. For example, merge conflicts can be introduced, which will make your pipeline fail.

There's one thing that documentation is not quite clear about, so I'll clarify it: all this pre-pipeline merging only occurs inside your build environment. Git history of your repository is absolutely safe, and Bitbucket Pipelines won't introduce any changes to it on your behalf.

Finally, you can run a PR merge pipeline manually from the Pipelines UI, without actually merging a PR (see the same link). This way, you can make sure that the merge result build is passing without actually doing a merge.

Related