How to configure your webhook from Bitbucket with your Jenkins server

marielle.spiteri's picture
marielle.spiteri
Blog Categories: 

You have followed the documentation "How to integrate BCD with Jenkins": https://documentation.bonitasoft.com/bcd/3.3/jenkins_example

Now you want to configure your CI and register a webhook from Bitbucket to execute the pipeline on your Jenkins server.

Steps to perform on Bitbucket and Jenkins

1.You have configured your BCD scenario and plugged it to your GIT (Bitbucket) repository.

What to do in your Bitbucket account

2.Your Bitbucket account must have an "App Password" set for your Jenkins server. This password will be used instead of your main Bitbucket password, for example:

What to do in your Jenkins server

3.Then, in your Jenkins server, in this example, version 2.235.3 which is the latest LTS available today, just add the bitbucket source plugin https://plugins.jenkins.io/cloudbees-bitbucket-branch-source/

4.In your repository settings, add a webhook to "http://YOUR-SERVER:YOUR-IP/bitbucket-scmsource-hook/notify/" it must include repository push & Merge Request events.

5.The "Skip certificate verification" option depends on your HTTPS policy if you use self-signed certificates, for example:

Important note about webhooks: if your Jenkins server is hosted on AWS, you must add Bitbucket IP in your security group so that Jenkins will receive webhooks requests. Current Ip as of today (08/03/2020) are 131.103.20.165/32 and 131.103.20.166/32.

6.In the global Jenkins admin section add your credentials, and then configure a new job that will use this plugin, your credentials and scan projects based on your needs, for example:

7.This project will then be built, based on an existing Jenkinsfile located in your GIT repo base directory.

8.Important notes:

* if your Jenkins server is hosted on AWS, make sure the AWS security groups are correctly configured. Otherwise the webhook will not be able to access your Jenkins server.
* When you configure the Jenkins plugin and file, make sure the Jenkinsfile syntax and format are valid. Double-check that the naming patterns are good.

Notifications