How to integrate Bitbucket Server with Jenkins Pipelines

We want to automate project build using a Parametrised Jenkins Pipeline of the source code stored in Bitbucket Server.
September 18, 2020
Productivity
Use-Case
Technology

Objective

We want to automate project build using a Parametrised Jenkins Pipeline of the source code stored in Bitbucket Server.

Jenkins Setup

Firstly, we need to install the necessary Jenkins plugins.

Git Parameter - https://plugins.jenkins.io/git-parameter/ - 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 - https://plugins.jenkins.io/build-token-root/ - allows to use the build token for external builds.

Secondly, create a Jenkins Pipeline that checks out and builds the code.

Afterwards, add branch as a parameter.

Generate an authentication token and make sure you don’t share it.

Add create your super simple pipeline that builds the branch or just print the hello world message.

Now we are ready for the Bitbucket Server configuration.

Bitbucket Setup

Install the Bitbucket Post Webhooks plugin and navigate to the repository settings to configure the triggers.

The url should be in the following format and parameters are passed in the url.

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

Click the test connection to see if it triggers the message.

Select the triggers for the notifications., For instance, it makes sense to sell “On push“.

Push the code to your master branch and trigger the build!

Enjoy the building and welcome to our world!

Products we’re proud of

Articles you might like

Unlock Microsoft Teams
April 18, 2020
Unlock Microsoft Teams
Read more >
Bring information from GitHub into Confluence
August 14, 2020
Bring information from GitHub into Confluence
Read on how to integrate GitHub with Confluence to increase team velocity and transparency
Read more >
Atlassian packages tools to help enterprises accelerate devOps adoption
April 18, 2020
Atlassian packages tools to help enterprises accelerate devOps adoption
Read more >

New blog posts

How to integrate Bitbucket Server with Jenkins Pipelines
September 18, 2020
How to integrate Bitbucket Server with Jenkins Pipelines
We want to automate project build using a Parametrised Jenkins Pipeline of the source code stored in Bitbucket Server.
Read more >
Bring information from GitHub into Confluence
August 14, 2020
Bring information from GitHub into Confluence
Read on how to integrate GitHub with Confluence to increase team velocity and transparency
Read more >
How to simplify project portfolio management using Jira
August 14, 2020
How to simplify project portfolio management using Jira
Jira is an incredibly powerful tool, however it may appear complex if not set up correctly. That’s why we’ve taken the time to help you set up what is called Project Central.
Read more >