We are seeding Bitbucket repositories in Jenkins using Bitbucket Team/Project type of jobs and you can find our job DSL file attached.
We ran into an issue where user triggered builds on master branches get rebuilt upon branch indexing (e.g. when someone triggers the multibranch pipeline scan). Note that in this scenario the Jenkins hook in Bitbucket repo was not configured correctly so the new commit did not automatically trigger a build when, for example, a pull request was merged to the master branch.
Steps to reproduce (this is without having a Jenkins hook properly configured in Bitbucket so we can mimic users triggering jobs):
- Kick off a master branch build so it's up-to-date and successful (building latest commit in master: f264be47)
- Create a pull request from testbranch to master with new changes
- Scan multibranch pipeline -> Jenkins detects the pull request and kicks off a build
- Merge pull request -> nothing happens due to no hook
- Manually kick off a master branch build (building pull request merge commit in master: 835d8b37)
- Scan multibranch pipeline
No changes detected: master (still at 835d8b37)
Changes detected: master (f264be47 → 835d8b37)
Scheduled build for branch: master
The same steps produced the following result when testbranch-1 was merged into testbranch-2 (essentially between two non-named branches):
Changes detected: testbranch-2 (null → 39fb6587)
No automatic build triggered for testbranch-2