Issue
-
I want to configure Jenkins and Bitbucket Cloud to automatically trigger non-multibranch jobs on changes
Environment
-
CloudBees Jenkins Enterprise - Managed controller (CJE-MM)
-
CloudBees Jenkins Team (CJT)
Resolution
The Bitbucket Plugin provides support in Jenkins to process webhooks received from Bitbucket Cloud.
Configuration in Jenkins
Freestyle Jobs
Configure the Git SCM:

Configure the project to Build when a change is pushed to Bitbucket
:

Pipeline Jobs
1) Configure the Pipeline script from SCM
:

Or a Pipeline script
:
node { checkout([$class: 'GitSCM', branches: [[name: '*/develop']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[ credentialsId: 'dohbedoh-bitbucket-up', url: 'https://bitbucket.org/jenkinssupport/simple-project.git' ]]]) }
Configure the project to Build when a change is pushed to Bitbucket
:

IMPORTANT: Build the project once to retrieve the Git data.
Configuration in Bitbucket Server side
Go to the Settings
of a repository. Then go to the section Webhooks
and click on Add Webhook:

Give it the name you want and specify the Bitbucket Branch Source endpoint $JENKINS_URL/bitbucket-hook/
:

Ensure that the webhook is created and enabled:

From now on, Push
events to the repository notifies the Git plugin and triggers a new build.
Pull Requests
(We strongly encourage to use Pipeline Multibranch for such scenario)
There is currently no simple solution to trigger jobs on Pull Requests for Bitbucket Cloud. There is some work in progress in the Bitbucket Plugin to make this possible. This is tracked by JENKINS-23685.
Moreover as there is no refspec for repository pull requests in Bitbucket Cloud, it makes it difficult to leverage for example the push notification endpoint of the Git Plugin.
In the meantime, the workaround is to use polling solution like Bitbucket Pullrequest Builder
Troubleshooting
Please have a look at Bitbucket Webhooks Troubleshooting to troubleshoot issues with these solutions.