If you are using a Jenkins v2.138.2 or later, you may have some problems with the older Bitbucket plugin. This uses the JSONObject, already blacklisted by the JEP-200, causing an exception UnsupportedOperationException: Refusing to marshal net.sf.json.JSONObject for security reasons
In case you are using Bitbucket Cloud, configure your Bitbucket repository adding a webhook in the settings page. In the URL field (see image, point A) add your JENKINS_URL followed by "/bitbucket-hook/" (for example "https://my-jenkins.on-my-planet-far-away.com/bitbucket-hook/") Credentials for the webhook endpoint are not required, the trailing slash is mandatory. For more infos please consult the resource https://confluence.atlassian.com/bitbucket/manage-webhooks-735643732.html.
If you are using Bitbucket Server, follow the following steps:
- First install on the Bitbucket Server the Post Webhooks for Bitbucket plugin (it's free).
- After that, create from the repository settings a post-webHook and configure it as described for the Bitbucket Cloud.