Skip to main content

Jenkins with Bitbucket

Atlassian maintains a Jenkins Plugin for integration with Bitbucket.

However, the plugin is not easy to configure for usage with the Bitbucket cloud service.

Alternatively, it is possible to integrate with Bitbucket by treating Bitbucket cloud like a generic GIT repository.

Creating a read-only access token.

Creating a read-only access token is more secure. The caveat is that it prevents some of the pipeline editing tools inside Jenkins from working correctly. The reason is that some tools modify the Jenkins file and then attempt to push the altered files back to the Bitbucket repository.

Create SSH credential for use by Jenkins.

ssh-key-gen -f jenkins

Uploading a public key to Bitbuck.

  1. Click on profile picture -> Personal settings

  2. Click SSH keys, click "Add key"

  3. Paste in the contents of the public key created for Jenkins. (

  4. Add the credentials to Jenkins. Please be aware that this step allows Jenkins to operate under your own account with the same permissions as your user account. In a production setting, you should create a separate Bitbuck account for Jenkins.

  5. Click on Jenkins -> "Manage Jenkins"

  6. Manage Credentials Click on the "global" domain. This can be anyone in the list shown.

  7. Click: "Add Credential" Kind Choose: "SSH Username with private key" ID: Can be left empty Description: Some useful description. e.g. Jenkins Access to Bitbucket as Bitbucket user: Fred. Username: The username used to login to Bitbucket (You can see the username by looking at the URL provided by the bitbucket "clone" tool. This tool can be found on the Bitbucket repository web page.). Private Key: (Select "Enter Directly", then paste in all contents of the private key file (jenkins).) Passphrase: empty (This assumes that the SSH keypair was created without a passphrase.) Within the configure projects sections, go to the "Pipeline" tab. Then select SCM: Git As repository URL use the URL provided by the Bitbucket Clone Tool. (SSH) It will look like this:

    Credentials, choose the credentials configured in the previous step.

Using Jenking with Docker.

To enable Jenkins to work with the docker daemon the user account that is used to run Jenkins must be added to the Docker group.