I did everything as told and got some experiences:

  1. Webhooks are not working (Jenkins ver. 2.164.3 and Bitbucket cloud). Instead, I had to rely on periodic ‘Scan Multibranch Pipeline Triggers’.
  2. Jenkins builds for PRs can be made using the wrong commits.

The second one comes as a real surprise!

I have the branch jenkins-test-3 forked from master and jenkins-test-4 forked from master.

Before pull-request from jenkins-test-4 to jenkins-test-3 there were commits:

Pull request from jenkins-test-4 to jenkins-test-3 made its own commit 95a42f5… In Bitbucket UI we see the build is passed in CI, but what is in Jenkins log:

Branch indexing
Loading trusted files from base branch jenkins-test-3 at c013c792c09f81b7a178c0fa77343e65e3c02871 rather than 95a42f534118ee8584ab34ef0dd6195f6078e6ee

And yes, it really built c013c79… for that PR.

It’s Bitbucket Branch Source Plugin who manage to get a source code from the repository and choose which one to build.