Configure Bitbucket Webhook to Trigger Jenkins Builds on AWS EC2

This article represents steps required to configure BitBucket Webhook to trigger Jenkins Builds on AWS EC2 based on code committed in the repository. This essentially means that a code commit in the BitBucket code repository would trigger a build in Jenkins server running on AWS EC2 machine. This forms the starting point of continuous delivery pipeline. The jenkins build, when triggered as a result of code push, could perform tasks such as some of the following:
  • Run the build,
  • Run tests
  • Publish build artifacts in artifactory
  • Deploying the build artifacts in different environments including QA, UAT and production.
Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos.
Following are the steps which need to be taken to configure push-based trigger of Jenkins Build:
  • Configure Inbound Rule on Jenkins Server on AWS EC2: One needs to add the inbound rule on Jenkins box on AWS EC2 for following IP: 104.192.143.192/28. This is required to allow requests coming from BitBucket to reach to Jenkins server on AWS EC2. This is BitBucket cloud IP outbound address (for hooks like POST) when inbound IP address for BitBucket is 104.192.143.1. The IP (104.192.143.1) can be figued out by pinging bitbucket.org. The outbound IP address can be found from this page: https://confluence.atlassian.com/bitbucket/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall-343343385.html
  • Configure Webhook in BitBucket: One needs to add following URL while creating WebHook in BitBucket: http://jenkins_server_uri/bitbucket-hook/.
  • Configure SCM in Jenkins Project: Next step is to configure Git as Source code management tool within Jenkins Project by clicking on Configure link on project’s dashboard. Following is a sample of input parameter:
    • Repository_URL: https://<bitbucket_user>@bitbucket.org/<bitbucket_user>/<bitbucket_project_name>.git
    • Credentials: Create a credential by providing bitbucket username and password
  • Setup Build Triggers in Jenkins Project: Finally, one would require to setup build triggers for the Jenkins project by clicking on Configure link on project’s dashboard. Check the option “Build when a change is pushed to BitBucket”
Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking.

Recent Posts

Retrieval Augmented Generation (RAG) & LLM: Examples

Last updated: 25th Jan, 2025 Have you ever wondered how to seamlessly integrate the vast…

1 week ago

How to Setup MEAN App with LangChain.js

Hey there! As I venture into building agentic MEAN apps with LangChain.js, I wanted to…

2 weeks ago

Build AI Chatbots for SAAS Using LLMs, RAG, Multi-Agent Frameworks

Software-as-a-Service (SaaS) providers have long relied on traditional chatbot solutions like AWS Lex and Google…

2 weeks ago

Creating a RAG Application Using LangGraph: Example Code

Retrieval-Augmented Generation (RAG) is an innovative generative AI method that combines retrieval-based search with large…

3 weeks ago

Building a RAG Application with LangChain: Example Code

The combination of Retrieval-Augmented Generation (RAG) and powerful language models enables the development of sophisticated…

3 weeks ago

Building an OpenAI Chatbot with LangChain

Have you ever wondered how to use OpenAI APIs to create custom chatbots? With advancements…

3 weeks ago