Why do otherwise-excellent and smart engineers end up doing the kind of dumb polling in Jenkins that would keep them up at night if it was their code? Mainly because historically, it's been substantially harder to get properly-triggered job execution going in Jenkins. But things are getting better. The Jenkins GitHub Plugin does a terrific job of simplifying triggering, thanks to its convention-over-configuration approach - once you've nominated where your GitHub repo is, getting triggering is as simple as checking a box. Lovely.
Now, finally, it seems BitBucket have almost caught up in this regard. Naturally, as they offer (free) private repositories, there is a little bit more configuration required on the SCM side, but I can confirm that in May 2016, it works. There seem to have been a lot of changes going on under the hood at BitBucket, and the reliability of their triggering has suffered from week-to-week at times, but hopefully things will be solid now.
The 2016 Way to trigger Jenkins from BitBucket
- Firstly, there is now no need to configure a special user for triggering purposes
- Install the Jenkins BitBucket plugin. For your reference, I have 1.1.5
- In jobs that you want to be triggered, note there is a new "BitBucket" option under Build Triggers. You want this. If it was checked, uncheck the "polling" option and feel clean
- That's the Jenkins side done. Now flip to your BitBucket repo, and head to the Settings
- Under Integrations -> Webhooks add a new one, and fill it out something like this:
- Make sure you've included that trailing slash, and then you're done! Push some code to test