Bitbucket Server and Jenkins integration
This plugin makes it easier to connect up your Jenkins instance with Bitbucket Server
Configure the connection in a few simple steps, the integration will then take care of creating webhooks to trigger builds and post the build status back to Bitbucket
Currently development is in alpha-stage so the plugin is not fully functional yet.
This plugin adds a Bitbucket Server SCM that can be selected when configuring a Job. When configuring a job using the Bitbucket Server SCM, the plugin will make it easier for you to configure your repository. This plugin also adds a Bitbucket Server trigger. This will create a webhook against Bitbucket Server which will trigger the job on relevant pushes.
Adding a Bitbucket Server
Each Bitbucket Server instance has to be added and configured at system configuration level. Once it is configured, it can be
Here are the steps to set up a Bitbucket Server instance
- Manage Jenkins > Configure System > Add Bitbucket Server
- Add a server name
- Add a server url
- Create a new project admin token by selecting the 'Bitbucket Admin token' type
- Create a username with password credential and select that for credentials
- Click save
Configuring a job
Using the Bitbucket Server SCM when configuring your job will make it easier to select the repository that is to be cloned, and using the Bitbucket Server trigger will automatically create a webhook against Bitbucket.
Here is an example for creating a new Bitbucket Server job:
- Click 'Create new job'
- Name the job and select 'Freestyle Project' then click Next
- In 'Source code management' select Bitbucket Server
- Select the Bitbucket Server Trigger
- Add a build step
- Click save
The plugin is still in the early stages of development so it does not yet support all of the features described here. Additional features will also be made available.
This plugin uses Apache Maven for development and releases.
Please follow the rules in
checkstyle.xml. You can run the checks using
mvn checkstyle:check. We also recommend
setting up a pre-commit hook to ensure you don't commit changes that violate the rules. A pre-commit hook already exists
etc/git-hooks and can be set up configuring the git hooks path:
git config core.hooksPath etc/git-hooks
or by linking the pre-commit hook directly:
ln -s -f ../../etc/git-hooks/pre-commit .git/hooks/pre-commit
To build the plugin simply run
Running Jenkins with the plugin enabled
There are several ways to do this, you can spin up your Jenkins instance using
java -jar jenkins.war in a directory
that has the downloaded war-file. This enables running and testing in a real Jenkins instance.
A quick way during development is to run
mvn hpi:run this will download and start the appropriate Jenkins version.
The instance is then available on http://localhost:8080/jenkins logs end up in the
To start Jenkins in debug mode run:
This will start Jenkins (and Maven) in debug mode, listening on port
8000 it will wait for a debugger to attach before
proceeding with loading Jenkins and the plugin.
Just as under the run section above, Jenkins will be available on http://localhost:8080/jenkins
with logs in the invoking console.
Run Bitbucket Server using AMPS with the following command:
atlas-run-standalone --product bitbucket --version 6.5.0
This will start Bitbucket Server on http://localhost:7990/bitbucket.
Unit tests are run with the Surefire plugin using
mvn verify. They can be skipped using
Integration tests are run under the
it profile with the Failsafe plugin using
mvn verify -Pit.
The integration tests will start Bitbucket Server on http://localhost:7990/bitbucket and stop it after the tests are complete.