We’re aware of this issue and will fix it ASAP, but unfortunately this is quite a complex issue, so it might take some time, but should be fixed this week.
A bit of technical info: right now the build number is calculated by the count of builds in the database for the given repository, then stored in the build’s db entry when the build starts. Now the issue is that we now have quite a few cases when “you start builds at the same time but you delete a build right away”. E.g. when you have a webhook registered for both PR and code push GitHub/the git service sending the hook can send the two hooks virtually at the same time. Bitrise.io will register the trigger intent and start to process it, and at some point it’ll create a DB entry for it. The build trigger handling is one of the most complex parts of the backend so this might take quite a bit of time, and as the system is highly distributed (the two webhook calls will run on completely separate servers, so the processing can happen at the exact same time) this can lead to a situation when: Trigger1 saved the Build into DB, and just a bit later Trigger 2 also saved the Build into DB, but then Trigger1 gets to a check which determines that the build should not be started (e.g. based on the Trigger Map) and deletes the related build. Now Trigger2’s build will have a build number which was calculated when T1’s build DB existed, but as it was removed the next trigger will have the same number. Using a single DB entry for storing and allocating the build number would also suffer from a similar issue, just the other way around, that certain build numbers would simply be not allocated (because the number was allocated but then the related build DB entry was removed).
The only sane way for this is to calculate the build number and save into the DB as late as possible in the algorithm, which requires quite a bit of careful revisioning & time, but we’ll definitely work on it this week, and should be fixed by the end of the week (unless there’s an unexpected edge case).
Thanks for reporting!