This integration enables the triggering of the Jenkins pipeline automatically whenever some changes are pushed to the Bitbucket Server repository, allowing you to build, test, and deploy seamlessly.
Plugins for Jenkins Server
Firstly, you need to install the necessary plugins on your Jenkins Server:
Git Parameter Plug-In (adds Git parameters to the Jenkins pipelines, you can use it to specify the branch to check in or any other things used in the Jenkins pipeline).
Build Authorization Token Root Plugin (allows using the build token for external builds).
Follow this short instruction on installing new plugins in Jenkins:
Log in to Jenkins and on the dashboard click on Manage Jenkins in the left sidebar.
Click on Plugins to open the Plugin Manager.
Move to the Available section. Here you can search for necessary plugins using the search bar or browse through the available plugins.
After the plugin installation is complete, Jenkins may prompt you to restart the server for the changes to take effect.
Create a Jenkins Pipeline Job
On the Jenkins dashboard, click on New Item in the left sidebar to create a new job.
Give a name to the Job that you are creating.
Select the Freestyle Project (or any other pipeline type) and click on OK.
Add the branch as a Git parameter:
Chose the option This project is parameterized. Click on Add Parameter and select Git Parameter in the drop-down.
Default valueof the Git parameter (as it is shown in the screenshot below).
Move to Source Code Management to provide access to the Bitbucket repository:
Select Git option.
Credentialsof your Bitbucket account. We recommend using
URLfrom Clone section on the Bitbucket side.
On the Build Triggers section select the option Trigger builds remotely (e.g., from scripts) and create an
Click on Save button to save the Pipeline Job Configuration.
Now you are ready for the Bitbucket сonfiguration.
Navigate to the repository-level configurations of Bitbucket Post Webhook app and create a new webhook:
Move to the Bitbucket repository you wish to set up Post Webhooks for Bitbucket app.
Navigate to the Repository settings by clicking on the “gear” button on the left sidebar.
On the Workflow section find our application Post Webhooks.
Click on Add webhook in the left corner.
Create a new configuration and specify all the necessary parameters. Use Test Connection button to verify the connectivity between Bitbucket and Jenkins.
To complete webhook creation click on Save button.
Below you can find a short definition of the parameters you have to specify.
the name of the configuration
Our advice is to name something meaningful to you and your team so that it can be understood later easier
a link to the Jenkins Pipeline Job by pattern:
this parameter instructs the app to skip the validation of SSL certificates, allowing the connection to be established even if the certificate cannot be verified.
allows you to specify the types of events that should trigger the pipeline.
The rest parameters are optional to provide flexibility and customization options to tailor the webhook integration according to your specific needs.