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.
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
- For 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.
Since the version 1.1.7 of the Bitbucket plugin works against Bitbucket server. For this plugin to work against Bitbucket server you must:
- Install Post Webhooks for Bitbucket at Bitbucket side [the plugin is free]
- At repository level, delete the webhook in case it exists
- Create a Post-WebHook, which is different from WebHook and enable on push.
After this, you are all set-up
The current supported dsl is as follows:
freeStyleJob('test-job') {
triggers{
bitbucketPush()
}
}
Changelog
- Added possibility to process trigger from bitbucket server default webhooks PR-63
- Update job-dsl dependency to 1.66. See PR-58
- Address Bitbucket API change:
JENKINS-57787
- Getting issue details... STATUS
- Add Jenkins ci integration
- JENKINS-28877 : Add integration for Bitbucket server
- fix JENKINS-44309 Add support for Symbol
- fix JENKINS-32372 Inject the Payload into the build through $BITBUCKET_PAYLOAD
- Add JENKINS-31185 hg support
- Add Job DSL extension
- fix JENKINS-26234 CSRF support
- fix JENKINS-29096 Advice users when they don't use the right hook url - last `/`
- fix JENKINS-30985 Jobs with the same git repository defined several times in the scm should be triggered only once
- fix JENKINS-28882 Workflow support for BitBucket trigger
- Allow Webhooks 2.0
- fix JENKINS-24999 Build triggered by SCM change without activating trigger in the job configuration
- fix JENKINS-26413 BitBucket trigger doesn't need to Initialize LogFile
- fix JENKINS-26489 Action report for the bitbucket polling log on web UI
- fix JENKINS-26805 Job is not triggered after merging a branch
- initial implementation