Build on the same commit SHA triggered twice

I have a workflow with 2 triggers: on push branch and on pull request. When I create PR and push to the branch, bitrise triggers 2 (same) builds.

Basically they triggers the same workflow (on the same commit SHA). Shouldn’t it trigger only one build? I would expect it to work that way – one workflow on one commit sha runs once (no matter what triggers so).

Hi @kmenzyk-rst,

Please see:

It explains how you can configure the Triggers to only build one of those.

Also explains that the two builds are not 100% the same:

An important note: although it might seem like both builds are the same, it most likely isn’t! The code push event/build builds the code of the branch, without any merging, etc. It builds the exact same state of the code what you have when you checkout that branch. The Pull Request build on the other hand builds a “pre-merged” state of the code, which is expected to be the state of the code after you merged the pull request.

Whether you want to build both or just one of these in case of a pull request is up to you and depends on your project’s requirements, but with bitrise you can decide whether you want it or not.

Let us know if you’d have any questions! :wink:

One is just the branch itself, and another is the branch merged into master (or whatever default is) because on a PR you want to make sure that the merged code will pass your tests and so on?

@viktorbenei Thanks for the explanation.

I’ve just disabled triggering builds on code push. Thereby it solved my issue.

1 Like

Thanks for reporting @kmenzyk-rst and Happy Building! :wink:

@coltonidle exactly, the “PR build” does a local merge, inside the build VM, from the PR’s source to its target, to simulate the state of the code you will get after the PR is merged into its target, and so you can run tests on that state, instead of just on the source.

I have the same issue except that I don’t have a push event in trigger map only the pull request, any suggestions ?