1

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?

Rabi
  • 147
  • 2
  • 12

1 Answers1

3

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.

esimonov
  • 546
  • 3
  • 8
  • Thanks!, yes I'm aware of the branch strategy but in my case I want to deploy feature branches to test them in a testing env everytime there is a new feature, so the features' branch names are unknown at first and I want to write a pipeline to be general to new features without specifying their names in the pipeline script, this is why I want to use pull request upon which the image will be built from that feature branch and deployed to the testing env to test it before merging it. – Rabi May 27 '22 at 12:14
  • It's generally a good idea to adhere to some naming conventions for the branches, so that they're not completely arbitrary. See here - https://stackoverflow.com/questions/273695/what-are-some-examples-of-commonly-used-practices-for-naming-git-branches. This way, you'll manage to use glob patterns for running pipelines on feature branches. Alternatively, you can use `default` pipeline (see the same Bitbucket doc as in the answer). – esimonov May 27 '22 at 12:25
  • @Rabi you should explain your intended workflow with more detail in a new question, but I feel it should be doable only requiring reasonable branch name prefixes. – N1ngu May 27 '22 at 15:26