Over a million developers have joined DZone.

Configure Bitbucket Webhook to Trigger Jenkins Builds on AWS EC2

DZone 's Guide to

Configure Bitbucket Webhook to Trigger Jenkins Builds on AWS EC2

In this tutorial, learn how to trigger Jenkins builds on an AWS EC2 machine with each code commit in your BitBucket repository.

· Cloud Zone ·
Free Resource

This article represents the steps required to configure BitBucket Webhooks 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 on the Jenkins server running on a AWS EC2 machine. This forms the starting point of a 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.
  • Deploy the build artifacts in different environments including QA, UAT, and production.

Please feel free to comment/suggest if I missed one or more important points.

Following are the steps which need to be taken to configure the push-based trigger of a Jenkins build:

  • Configure Inbound Rule on Jenkins Server on AWS EC2: One needs to add the inbound rule on the Jenkins box on AWS EC2 to follow this IP: This is required to allow requests coming from BitBucket to reach the Jenkins server on AWS EC2. This is the BitBucket cloud IP outbound address (for hooks like POST), while the inbound IP address for BitBucket is The IP ( can be figured out by pinging bitbucket.org. The outbound IP address can be found on this page.
  • Configure Webhook in BitBucket: One needs to add the following URL while creating the WebHook in BitBucket: http://jenkins_server_uri/bitbucket-hook/.
  • Configure SCM in Jenkins Project: He next step is to configure Git as a source code management tool within the Jenkins project by clicking on the Configure link on the project’s dashboard. Following is a sample of input parameters:
    • Repository_URL: https://<bitbucket_user>@bitbucket.org/<bitbucket_user>/<bitbucket_project_name>.git
    • Credentials: Create a credential by providing a BitBucket username and password.
  • Setup Build Triggers in Jenkins Project: Finally, one would need to setup build triggers for the Jenkins project by clicking on the Configure link on project’s dashboard. Check the option “Build when a change is pushed to BitBucket.”
cloud ,aws ec2 ,jenkins ,bitbucket ,continuous delivery

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}