Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Bitbucket Pull Request Builder Plugin

This Jenkins plugin builds pull requests from and will report the test results.

Current Maintainer(s):

This repo is looking for a new maintainer.

  • David Frascone - No longer has access to a jenkins system, due to a job change, and can no longer test any changes.

Build Status

Build Status


Creating a Job

  • Create a new job
  • Select and configure Git SCM
    • Add Repository URL,${repositoryOwner}/${repositoryName}.git
    • In Branch Specifier, type */${sourceBranch}
  • Under Build Triggers, check Bitbucket Pull Request Builder
  • In Cron, enter crontab for this job.
    • e.g. * * * * * will check for new pull requests every minute
  • In Bitbucket BasicAuth Username, write your bitbucket username, like
  • In Bitbucket BasicAuth Password, write your password
  • In CI Identifier, enter an unique identifier among your Jenkins jobs related to the repo
  • In CI Name, enter a human readable name for your Jenkins server
  • Write RepositoryOwner
  • Write RepositoryName
  • Save to preserve your changes

Jenkins pipeline

pipeline {
    agent any
            cron: 'H/15 * * * *',
            credentialsId: '',
            username: '',
            password: '',
            repositoryOwner: '',
            repositoryName: '',
            branchesFilter: '',
            branchesFilterBySCMIncludes: false,
            ciKey: '',
            ciName: '',
            ciSkipPhrases: '',
            checkDestinationCommit: false,
            approveIfSuccess: false,
            cancelOutdatedJobs: true,
            buildChronologically: true,
            commentTrigger: '')

Note that the projectPath parameter does not need to be set if bitbucketServer, repositoryOwner, and repositoryName is set.

You can use jenkins credentials by setting environment variables in the environment section and referring to them like for example "${env.BITBUCKET_CREDENTIALS_USR}".

After you set up your Jenkins pipeline, run the job for the first time manually (otherwise the trigger may not work!)

Merge the Pull Request's Source Branch into the Target Branch Before Building

You may want Jenkins to attempt to merge your PR before building. This may help expose inconsistencies between the source branch and target branch. Note that if the merge cannot be completed, the build will fail immediately.

  • Follow the steps above in "Creating a Job"
  • In the "Source Code Management" > "Git" > "Additional Behaviors" section, click "Add" > "Merge Before Building"
  • In "Name of Repository" put "origin" (or, if not using default name, use your remote repository's name. Note: unlike in the main part of the Git Repository config, you cannot leave this item blank for "default").
  • In "Branch to merge to" put "${targetBranch}"
  • Note that as long as you don't push these changes to your remote repository, the merge only happens in your local repository.

If you are merging into your target branch, you might want Jenkins to do a new build of the Pull Request when the target branch changes.

  • There is a checkbox that says, "Rebuild if destination branch changes?" which enables this check.

Rerun a Build

If you want to rerun a pull request build, write a comment on your pull request reading “test this please”.

Environment Variables Provided

  • sourceBranch
  • targetBranch
  • repositoryOwner
  • repositoryName
  • pullRequestId
  • destinationRepositoryOwner
  • destinationRepositoryName
  • pullRequestTitle
  • pullRequestAuthor

Contributing to Bitbucket Pull Request Builder Plugin


Do you like this plugin? feel free to donate!


BTC: 1KgwyVzefeNzJhuzqLq36E3bZi2WFjibMr

Thank you!


Copyright © 2022 S.nishio + Martin Damovsky + David Frascone


  • BSD License
  • See COPYING file


Bitbucket Pull Request Builder Plugin for Jenkins







No packages published