Webhooks provide a way to configure Bitbucket Cloud to make requests to your server (or another external service) whenever certain events occur in Bitbucket Cloud.
In Jenkins if you don’t want to build manually, then, use Bitbucket webhook. When you do certain events in Bitbucket Cloud, it will trigger your Jenkins jobs for build.
Should follow below steps,
1. Install Bitbucket plugin
Go to plugin page and type “Bitbucket plugin” in search box, you will get the plugin. Choose that plugin and click Download now and Install after restart button.
2. After the plugin installation, go to Job configuration page.
In Build Triggers, choose “Build when a change is pushed to BitBucket”.
3. We have done the Jenkins configuration, now, we have to configure the Bitbucket.
Go to Bitbucket repository page of which repository you have configured in Jenkins job.
Then, click Settings -> Webhooks
4. Add webhook, Enter title for the webhook and give URL http://JENKINS_URL/bitbucket-hook/
Make sure the URL has slash at end of URL.
The default option of webhook triggers is Repository push. But, we can use customized events for webhook triggering. Then, save it.
We have completed the Jenkins configuration with Bitbucket webhook. Now, you can use it. You can see your triggered events request in Webhook view request page and you should get 200 status code.