Jenkins configuration - Classic UI
Bitbucket Branch Source plugin
Log into your Jenkins instance.
Go to Manage Jenkins > Configure System and scroll down to Bitbucket Endpoints.
Click Add
Configure Jenkins for use with Webhook to Jenkins
and select Bitbucket Cloud from the dropdown.
Click Save.
Configure Jenkins multibranch pipeline job
Info |
---|
These instructions apply to Multibranch Pipeline jobs and Bitbucket Team Jobs. Other Jenkins jobs do not have the Branch Source configuration option available. |
A Jenkinsfile is required for multibranch jobs. A Jenkinsfile is defined in your repository and describes how your pipeline will work.
Select a job from the Dashboard page and click ⚙️ Configure.
On the Configuration page, scroll down to the Branch Sources section (for a Bitbucket Project configuration, this section is called Projects).
Click Add Source and select Bitbucket to expand the section.
Enter information in the following fields:
Server - select the Bitbucket Server endpoint you added in the Bitbucket Branch Source plugin section
Credentials -select your administrator Bitbucket credentials. If you do not have credentials configured, click Add to open the Jenkins Credentials Provider dialog and click Jenkins. From the the Kind section, click the dropdown to open the list of available options. Select the credential type you want to use, fill in the applicable information and click Add.If you use the Username/Password credentials, be sure to use the Bitbucket App Password. See App Passwords to learn more about setting up an app password in Bitbucket Cloud.
While you can use any of the authentication methods that best fits your organization’s security policy, we recommend using SSH Username with private key. Go to Configure SSH Credentials for Webhook to Jenkins for Bitbucket for instructions on how to set up SSH credentials.
Owner - enter your workspace key
Repository Name - select the name of the Bitbucket repository associated with this Jenkins job.
Git plugin
Log into your Jenkins instance.
Add or select the job you want to associate with your Bitbucket repository. We recommend choosing a Freestyle job that works best with the Git plugin.
Once you are in the job, click Configure from the left menu.
Select the Source Code Management tab and the Git option when the Configuration page opens.
In the Repository URL field, enter the URL for the Bitbucket repository you want Jenkins to integrate with. This is the same URL as the one displayed in the Repo Clone URL field located in the Instance Details for your Jenkins instance of Webhook to Jenkins.
Click Add to open the Jenkins Credentials Provider dialog and click the Kind pull down to open the list of available options. Select the credential type you want to use and click Add. While you can use any of the authentication methods that best fits your organization’s security policy, we recommend using SSH Username with private key. Go to Configure SSH Credentials for Webhook to Jenkins for Bitbucket for instructions on how to set up SSH credentials.
In the Branches to build section, click Add Branch to identify the specific branches you want to track in a repository. Enter the branch in the Branch Specifier field. Leave the field blank for all branches to be examined for changes and build. By default the field is set to
*/master
. Confirm the branch name is entered correctly. Click the Help icon next to the Branch Specifier for more formatting information.Select the Build Trigger tab.
Select Poll SCM. This is an important step, as the build won’t trigger in Jenkins if this option is not selected.
Git plugin version 4.11.4 or higher requires the notifyCommit
token. See Access token requirements for Git plugin 4.11.4+ for instructions regarding generating and using the token.
Info |
---|
You are currently in Webhook to Jenkins for Bitbucket Cloud documentation. Click Server/Data Center to move to that document. |
Aura inline button | ||||
---|---|---|---|---|
|
In this section
Table of Contents | ||||||
---|---|---|---|---|---|---|
|
Related articles
Configure SSH Credentials for Webhook to Jenkins for Bitbucket
Jenkins configuration - Blue Ocean
Blue Ocean is a Jenkins front-end that provides users with an improved experience when creating pipeline jobs. For complete information regarding Blue Ocean, refer to their documentation.
To trigger a Jenkins job through Webhook to Jenkins using Blue Ocean, confirm the following:
The Bitbucket Branch Source plugin has been installed in Jenkins. You can also use the Git plugin if you use a Multibranch Pipeline job, but the Bitbucket Branch Source plugin is recommended.
Configure the Bitbucket Endpoint in Jenkins
The Bitbucket repository contains a
Jenkinsfile
(at the end of creating a new pipeline, Jenkins looks for this file in your Bitbucket repository. If it does not find it, it will give you the option of creating a Jenkinsfile).
Log into your Jenkins instance. If you do not have the Blue Ocean dashboard open, select Open Blue Ocean from the main Dashboard page. If you need to exit Blue Ocean, click the Exit button in the top right of the page, next to the Logout button.
The plugin used determines the configuration steps required to configure Jenkins to work with Webhook to Jenkins. Bitbucket Branch source plugin is the recommended plugin; however, you can use the Git plugin with a Jenkins multibranch pipeline job. Follow one of the workflows below, depending on the plugin you use.
Bitbucket Branch Source plugin
Click New Pipeline.
Select Bitbucket Cloud from the Where do your store your code? options.
The Connect to Bitbucket section opens.
Provide your Bitbucket username and the app password in the Username and Password fields and click Connect. This provides the logged-in Jenkins account access to your Bitbucket Cloud instance. See App Passwords to learn more about setting up an app password in Bitbucket Cloud.
In the Which team does the repository belong to? section, click either:
Your Bitbucket account to create a Pipeline project for one of your Bitbucket repositories.
A team of which you are a member to create a Pipeline project for a Bitbucket repository located within this team.
In the Choose a repository section, click the repository from which to build your Pipeline project. If your list of repositories is long, filter this list using the Search option.
Click Create Pipeline.
Git plugin (use Multibranch Pipeline job)
Click New Pipeline.
Select Git from the Where do you store your code? options.
The Connect to a Git repository section opens.
Enter the Bitbucket Repository URL. If required, provide your Bitbucket username and the app password in the Username and Password fields. This provides the logged-in Jenkins account access to your repository.
Click Create Pipeline.
Blue Ocean scans your local repository for a Jenkinsfile. If it doesn’t find one, you are prompted to create one.