About

Bitbucket plugin is designed to offer integration between Bitbucket and Jenkins.

It exposes a single URI endpoint that you can add as a WebHook within each Bitbucket project you wish to integrate with. This single endpoint receives a full data payload from Bitbucket upon push (see their documentation), triggering compatible jobs to build based on changed repository/branch.

Since 1.1.5 Bitbucket automatically injects the payload received by Bitbucket into the build. You can catch the payload to process it accordingly through the environmental variable $BITBUCKET_PAYLOAD.

Bitbucket Cloud usage

Configure your Bitbucket repository with a Webhook, using URL JENKINS_URL/bitbucket-hook/ (no need for credentials but do remember the trailing slash).

The older-style HTTP POSTs from Bitbucket are also supported but deprecated.

On each push, the plugin:

Scans Jenkins for all jobs with "Build when a change is pushed to Bitbucket" option enabled

Each each job matched:

If the job's SCM (git) URL "loosely matches" that of the git repository listed inside the Bitbucket-provided payload, AND

If the job's SCM (git) detects that the remote repository has changes, THEN

A full build of the job will be queued

The "loose matching" is based on the host name and paths of the projects matching.

Bitbucket server usage

Since the version 1.1.7 of the Bitbucket plugin works against Bitbucket server. For this plugin to work against Bitbucket server you must: