-
Bug
-
Resolution: Unresolved
-
Major
-
None
If an SCM Event is received for a branch while Branch Indexing was running, but before that branch was processed by Branch Indexing, SCM will have scheduled a build and then Branch Indexing will schedule one too. For the same revision.
Here is an concrete example of what was observed. In that example c9d7ea05e806c55a9af7eb69e92df809b651f1a0 is the previously scanned revision and built commit. eff5a3dd839c53da07e2e9f7c52c788916ec3a68 is the newer commit revision from the push.
1) SCM event is received after a push, it schedules a build and update the revision to the new one eff5a3dd839c53da07e2e9f7c52c788916ec3a68
[Fri Nov 08 18:06:22 AEST 2024] Received Push event to branch test/branch-7 in repository test-org/zd-261124 UPDATED event from 10.30.133.138 ⇒ http://mm-1.sda.svc.cluster.local:8080/mm-1/github-webhook/ with timestamp Fri Nov 08 18:06:17 AEST 2024 18:06:22 Connecting to https://api.github.com using 211883/****** (my-github-app-credentials) Examining test-org/zd-261124 Checking branches... Getting remote branch test/branch-7... Checking branch test/branch-7 Getting remote pull requests from branch test/branch-7... ‘Jenkinsfile’ found Met criteria Changes detected: test/branch-7 (c9d7ea05e806c55a9af7eb69e92df809b651f1a0 → eff5a3dd839c53da07e2e9f7c52c788916ec3a68) Scheduled build for branch: test/branch-7
2) Branch Indexing, that was currently running, then triggers a build and replace the last revision eff5a3dd839c53da07e2e9f7c52c788916ec3a68 with the previous one c9d7ea05e806c55a9af7eb69e92df809b651f1a0. *But the triggered build is actually building eff5a3dd839c53da07e2e9f7c52c788916ec3a68...*:
Checking branch test/branch-7
‘Jenkinsfile’ found
Met criteria
Changes detected: test/branch-7 (eff5a3dd839c53da07e2e9f7c52c788916ec3a68 → c9d7ea05e806c55a9af7eb69e92df809b651f1a0)
Scheduled build for branch: test/branch-7
3) If we kick off branch indexing again, it triggers a build and that time it swap the revision back to what it should be:
Checking branch test/branch-7
‘Jenkinsfile’ found
Met criteria
Changes detected: test/branch-7 (c9d7ea05e806c55a9af7eb69e92df809b651f1a0 → eff5a3dd839c53da07e2e9f7c52c788916ec3a68)
Scheduled build for branch: test/branch-7
At that point, after 3 duplicated builds (they all build the same revision), we are in a proper state.
Reproduction Steps
The way I was able to reproduce this is by having an SCM event processed while Branch Indexing had already started but not process the branch of that event yet.
- For the purpose of the test, prepare a git repo with a handful branches (I did with 10) so that Indexing take some time.
- Create a Pipeline Multibranch with Bitbucket / GitHub Branch Source (does not matter) with Branch Discovery trait
- Setup Webhook
- Prepare a change on a branch that will be processed by Branch Indexing towards then end (if you name your branches branch-1, branch-2, …, branch-9, you will see that branch-9 is processed later, at least with GitHub Branch Source.
- Start Branch Indexing
- Push your change right after that
--> If the SCM Event is received while Branch Indexing has started but before the relevant branch was processed, SCM will have scheduled a build and then Branch Indexing too.
- Once Branch Indexing has completed, run it again
--> A third build is triggered.. You have 3 builds for the same revision