Search code examples
jenkinsbitbucket-servermultibranch-pipeline

Jenkins Multibranch Pipeline - scan is not triggered from Bitbucket when a PullRequest is created


We have configured Jenkins multibranch pipelines to automatically build feature branches that are filed as Pull request in Bitbucket. For the Webhook creatin in Bitbucket(Server), we use Parametrized Builds for Jenkins. In Jenkins we have successfully configured this, the buildable branches are detected like a charm.

The thing is that I have to tell Jenkins to check for new branches every 2 Minutes, I'd rather have Jenkins notified when a PR is created,merged or changed. All other notifications from Bitbucket work pretty well, changes in a multibranch build lead to an automatic build, normal builds on none multibranch pipelines also work.

Does sombody know why the scan cannot be triggered from Bitbucket? I can provide Screenshots of my configuration if someone needs that... Thanks Carsten


Solution

  • You'd need to add a corresponding Webhook to each repository in Bitbucket to have builds being triggered on specific actions. We are using an extra add-on in Bitbucket (https://marketplace.atlassian.com/apps/1215474/post-webhooks-for-bitbucket?hosting=server&tab=overview) but you could even use the default Webhook implementation in Bitbucket (described here https://confluence.atlassian.com/bitbucketserver/managing-webhooks-in-bitbucket-server-938025878.html)

    The endpoint in Jenkins is defined by the Multibranch plugin. It is this one: "YOUR_JENKINS_URL/bitbucket-scmsource-hook/notify"

    See https://support.cloudbees.com/hc/en-us/articles/115000053051-How-to-Trigger-Multibranch-Jobs-from-BitBucket-Server- for a good guide.