On my Jenkins I configured:
Source Code Management
Git repository: https://bitbucket.org/username/project.git
credentials: username/password
Builder Triggers
Build when a change is pushed to BitBucket
On my BitBucket Webhooks:
http://Jenkins.URL:8080/bitbucket-hook
I tried pushing a small change to a .txt file, but the Jenken doesn't build automatically. If I manually click "build now", it shows success.
What could be the problem?
In the bitbucket repository, the project is simple. I just have a text file to test. I think as long as I made any change to the text file, it should trigger a Jenkins build.
Edit:
In the System Log of Jenkins, it shows "Polling has not run yet.". But in Bitbucket Webhook request log, I can see all the requests.
Follow the steps as mentioned below to trigger a Jenkins job automatically based on GitHub's webhook configurations: Step 1: Go to the Configuration page of the respective job and under the build trigger section, check the "GitHub hook trigger for GITScm polling" checkbox and click on the Save button.
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:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With