On my Jenkins I configured:
Source Code Management
Git repository: https://bitbucket.org/username/project.git
credentials: username/
As @Adrian mentioned, you still need to select "Poll SCM". It's a little unintuitive, but when the BitBucket webhook sends a request to Jenkins, Jenkins will poll for changes on all jobs that reference the BitBucket repo where the change was made. You can set a long time interval for the poll, e.g. @monthly, as you don't need Jenkins' scheduling to trigger polling; the web hook will take care of that as soon as a change is made.
This needs your Jenkisserver to have the bitbucket plugin. Check it by going to https://yourjenkinsserver.com/bitbucket-hook/ - it will crash, but you will know you installed it.
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.
Had the same issue on Jenkins 2.138.1 with Bitbucket plugin and the problem was that I had to enable "Source Code Management" -> git, otherwise it won't do anything although the webhook appeared on Jenkins's log (/var/log/jenkins/jenkins.log).
I second the statements here that say we do not need POLL SCM option with "Build when a change is pushed to BitBucket" but we need to make sure that webhook created in Bit bucket is correct.
Settings I used in BitBucket are: Repository Settings -> Webhooks
1. Title: <Anything>
2. URL: https://jenkins_server_ip:8443/bitbucket-hook/
3. Status: (Tick) Active
4. SSL / TLS: (Tick) Skip certificate verification (Not ticking this was causing no auto-trigger in my case)
5. Request History: (Untick) Enable request history collection
6. Triggers : (Tick) Repository push
Hope this helps!
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:
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.https://bitbucket.org/REPOSITORY_OWNER/REPOSITORY_NAME
. Plugin will not match it if it's the SSH url.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