Public | Automated Build

Last pushed: 2 years ago
Short Description
A proxy that forwards Bitbucket webhook calls to trigger Jenkins parameterized builds.
Full Description

Jenkins Bitbucket Webhook Proxy

A proxy that transforms Bitbucket webhook calls to a format that can trigger Jenkins parameterized builds.


  1. Bitbucket's webhook can only post JSON requests
  2. Change details (e.g. commit author, commit SHA, etc) of Bitbucket's webhook calls is located in the request body
  3. Jenkins' remotely triggered jobs (via webhook) cannot inspect the request body
  4. We need commit details from webhook to be available as build parameters in Jenkins jobs
    • so we can checkout and build only those specific commits


1. Run the proxy

There are two methods to run it.

Running the script with Python

It requires Python 2.7 and preferably isolated environment (e.g. virtualenv).

git clone webhook-proxy
cd webhook-proxy
pip install -r requirements.txt

Running with Docker

docker run -p 5000:5000 -i -t akhy/jenkins-bitbucket-webhook-proxy

2. Setting up Bitbucket and Jenkins

Jenkins side

  1. Open up your job configuration
  2. Check "This build is parameterized" and add a string parameter named "GIT_HASH". This parameter will be provided by our proxy app from Bitbucket webhook.
  3. In build triggers section check Trigger builds remotely and enter any random authentication token. This token will be used in the next Bitbucket configuration.
  4. Make sure in source code management section, you choose Git. Set branches to build to ${GIT_HASH}

Bitbucket side

Create a webhook with repository push trigger and this URL template:


  • myproxy.tld:5000 is where your proxy is listening
  • jenkins query param is your Jenkins URL
  • job query param is the Jenkins job's name (see the URL when you're editing the job)
  • token query param is the token you have set in the Jenkins job before

Note: Currently the proxy can only handle repository push trigger.


  • Handle more Bitbucket webhook triggers
  • Tests
Docker Pull Command