Skip to main content
Skip table of contents

How to integrate Bitbucket Server with Jenkins Pipelines?

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:

Follow this short instruction on installing new plugins in Jenkins:

  1. Log in to Jenkins and on the dashboard click on Manage Jenkins in the left sidebar.

  2. Click on Plugins to open the Plugin Manager.

  3. Move to the Available section. Here you can search for necessary plugins using the search bar or browse through the available plugins.

  4. 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

  1. On the Jenkins dashboard, click on New Item in the left sidebar to create a new job.

  2. Give a name to the Job that you are creating.

  3. Select the Freestyle Project (or any other pipeline type) and click on OK.

  4. Add the branch as a Git parameter:

    1. Chose the option This project is parameterized. Click on Add Parameter and select Git Parameter in the drop-down.

    2. Specify the Name, Parameter type and Default value of the Git parameter (as it is shown in the screenshot below).

  5. Move to Source Code Management to provide access to the Bitbucket repository:

    1. Select Git option.

    2. Enter the Repository URL and Credentials of your Bitbucket account. We recommend using URL from the Clone section on the Bitbucket side.

  6. On the Build Triggers section select the option Trigger builds remotely (e.g., from scripts) and create an Authentication Token.

  7. Click on Save button to save the Pipeline Job Configuration.

Now you are ready for the Bitbucket сonfiguration.

Configuration

Navigate to the repository-level configurations of Bitbucket Post Webhook app and create a new webhook:

  1. Move to the Bitbucket repository you wish to set up Post Webhooks for Bitbucket app.

  2. Navigate to the Repository settings by clicking on the “gear” button on the left sidebar.

  3. On the Workflow section find our application Post Webhooks.

  4. Click on Add webhook in the left corner.

  5. Create a new configuration and specify all the necessary parameters. Use Test Connection button to verify the connectivity between Bitbucket and Jenkins.

  6. To complete webhook creation click on Save button.

Below you can find a short definition of the parameters you have to specify.

Parameter

Definition

Title

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

URL

a link to the Jenkins Pipeline Job by pattern:

JENKINS_URL/buildByToken/buildWithParameters?token=TOKEN_NAME&job=JOB_NAME&Branch=BRANCH_NAME

For example, http://jenkins.mwf-test.com:8080/buildByToken/buildWithParameters?token=super-secret-access-token-123&job=Pipeline-01&Branch=master

Skip SSL Certificate Validation

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.

Status

Active checkbox should be enabled if this configuration is going to be used.

Repository events

Pull request events

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.

Demo Video

https://www.youtube.com/watch?v=JUYwmQYB3QE

Repository Level Configurations

How to set up Azure DevOps Pipeline triggering from Bitbucket Server?

How to enable notifications from Bitbucket in Microsoft Teams?

How to choose an authentication type?

Updated:

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.