Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Initial Setup

Austin Hacker edited this page Apr 24, 2018 · 1 revision

Setup

  1. Define a server
  2. Define a job
  3. Link your bitbucket server account to Jenkins

Define a server

Jenkins servers can be defined globally on the Administration page of Bitbucket Server or per project on the project settings page.

Jenkins administration settings

  • Base URL should be the http/https root address to you jenkins server
  • Default User and Default Token are optional and used as a fall back authentication for triggering jobs
  • Build Token Root Plugin uses an alternate alternate address for triggering builds anonymously
  • enable this only if you have this plugin installed in Jenkins

Define a job

Jenkins hook settings
Jenkins hook settings
Enable Parameterized Builds for Jenkins under the hooks settings for a repository.
You can add as many jobs as you want (within reason), they will be triggered in the order they are added.

  • Job Name is the job to build
  • Ref Type will apply your triggers to either branch operations or tag operations
  • Multibranch Pipeline should only be used to trigger jenkins multibranch pipelines
  • Triggers specifies when to trigger a build
  • Token correspondes to the authorization token on your job configuration page in Jenkins
  • Build Parameters
  • Ref Filter uses java regex syntax to only trigger a build for branches/tags that match the filter
    • the filter will only be used for branch/tag creation, branch pushes, and branch/tag deletion
    • leave blank to match all branches
  • Monitored Paths will only trigger a build if a file in the diff matches the filter
    • the filter will only be used for branch pushes and PR events
    • leave blank to match all changes
  • Required Build Permission will restrict who can trigger a Jenkins job using the repository permissions
    • This is only available on manual triggers
  • PR Destination Filter functions identically to Ref Filter but on the branch being merged into

Link your bitbucket server account to Jenkins

Jenkins user settings
On your user account page you can add your Jenkins API token. When added bitbucket server will use your Jenkins account to trigger jobs for branches you create/push, pull requests you open, or for manual builds.
If you have multiple Jenkins servers setup you can set the api token for each one.

Order of authentication:
The Jenkins user Token from the Jenkins User Settings will be used for authentation first.
If that is not set then the Token parameter in the job configuration will be used second.
If that is not set then the Default User and Default Token on the Jenkins server settings page will be used.

For Users

For Contributors

Clone this wiki locally