BitBucket Jenkins doesn't automatically build

You don't need to enable Polling SCM..

You have to ensure that your Webhook (Settings->Webhooks) is pointing to your Jenkins bitbucket-hook like the following: "https://ci.yourorg.com/bitbucket-hook/".

Notice that last "/", without it, the build will not be triggered.

It's an annoying thing, as you will get a 200 status code from Jenkins when sending requests, with or without it.


After some struggling with the BitBucket plugin, I have managed to get it working. Below is the summary of things I found are necessary for builds to be triggered, but are not obvious from plugin's documentation:

  1. Make sure your webhook has repository push trigger enabled. I thought pull request created / updated would suffice (building on PR is what I wanted) but the plugin reacts only to push.
  2. Set your repository URL (in Git plugin) to https://bitbucket.org/REPOSITORY_OWNER/REPOSITORY_NAME. Plugin will not match it if it's the SSH url.
  3. You do need the SCM polling enabled. The plugin itself does not pull the changes. You can leave the schedule field empty, so repository is polled only when the plugin triggers it.

I hope this helps. If the build is still not triggered for you, try enabling logs for the following classes:

  • com.cloudbees.jenkins.plugins.BitbucketHookReceiver
  • com.cloudbees.jenkins.plugins.BitBucketTrigger
  • com.cloudbees.jenkins.plugins.BitbucketJobProbe
  • com.cloudbees.jenkins.plugins.BitbucketPayloadProcessor
  • com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource

Using Jenkins 2.53 and Bitbucket plugin 1.1.5, I had to manually trigger the build first to get the webhook to work.

What tipped me off was this line from the documentation:

If the job's SCM (git) detects that the remote repository has changes, THEN

After that the webhook work great.