Integrating Jenkins with Bitbucket: Step-by-Step Guide

Introduction

This guide walks you through the process of seamlessly integrating Jenkins with Bitbucket using App Passwords. This integration empowers Jenkins to interact with your Bitbucket repositories, facilitating continuous integration and delivery.

Prerequisites

Ensure you have the following:

  • Access to a Bitbucket account with the necessary permissions.

  • Jenkins server installed and running.

Setting Up Bitbucket App Password

  1. Log in to Bitbucket:

    • Navigate to Bitbucket and log in to your account.
  2. Access Personal Bitbucket Settings:

    • Click on your profile picture in the bottom-left corner.

    • Choose "Bitbucket settings" from the dropdown menu.

  3. Generate App Password:

    • In the left sidebar, click on "Access management."

    • Under "Access tokens," select "App passwords."

    • Click on "Create app password."

    • Provide a label and choose permissions.

    • Click "Create" and securely store the generated App password.

Jenkins Configuration

  1. Access Jenkins Dashboard:

    • Open the Jenkins server dashboard in your web browser.
  2. Create a New Jenkins Job:

    • Click on "New Item" to create a job.

    • Enter a name and choose the job type (e.g., Freestyle project).

  3. Configure Source Code Management (SCM):

    • In job configuration, find "Source Code Management."

    • Select "Git" as SCM.

    • Add Bitbucket repository URL.

  4. Add Bitbucket Credentials:

    • Under "Credentials," click "Add."

    • Choose "Username with password" as the kind.

    • Paste the App password in the "Password" field.

    • Provide a unique ID and click "Add" to save.

  5. Configure Jenkins Job:

    • Scroll down to "Build Triggers" to configure triggers.

    • Set up build steps, post-build actions, and other settings.

  6. Save and Apply Changes:

    • Click "Apply" and then "Save" to save the configuration.

Testing the Integration

  1. Run Jenkins Job:

    • Manually trigger the job or wait for configured triggers.
  2. Check Build Status:

    • Monitor the Jenkins job console output for errors.

    • Verify the correct display of the build status.

Congratulations! You've successfully integrated Jenkins with Bitbucket using App Passwords. Your Jenkins job now seamlessly interacts with your Bitbucket repository for continuous integration and delivery.