Find plugins

Stash Pullrequest Builder
1.7.0Minimum Jenkins requirement: 1.625.3ID: stash-pullrequest-builder

This plugin builds pull requests from an Atlassian Stash instance and will report the test results.

Stash Pull Request Builder Plugin

This Jenkins plugin builds pull requests from an Atlassian Stash server and will report the test results as a comment. This plugin was inspired by the GitHub & BitBucket pull request builder plugins.


Parameter variables

The plugin makes available to the job the following parameter variables:

* ${sourceBranch}
* ${targetBranch}
* ${sourceRepositoryOwner}
* ${sourceRepositoryName}
* ${pullRequestId}
* ${destinationRepositoryOwner}
* ${destinationRepositoryName}
* ${pullRequestTitle}
* ${sourceCommitHash}

Creating a Job
Source Code Management

Select Git then configure:

  • Repository URL:

  • Advanced -> Refspec:

  • Branch Specifier:


    Build Triggers

Select Stash Pull Request Builder then configure:

  • Cron: must be specified. eg: every 2 minute H/2 * * * *
  • Stash Host: the http or https URL of the Stash host (NOT ssh). eg: https://example.com
  • Stash Credentials: Select or Add the login username/password for the Stash Host
  • Project: abbreviated project code. eg: PRJ or ~user
  • RepositoryName: eg: Repo

Advanced options

  • Ignore ssl certificates:
  • Build PR targetting only these branches: common separated list of branch names. Blank for all.
  • Rebuild if destination branch changes:
  • Build only if Stash reports no conflicts:
  • Build only if PR is mergeable:
  • CI Skip Phrases: default: "NO TEST"
  • Only build when asked (with test phrase):
  • CI Build Phrases: default: "test this please"

Building the merge of Source Branch into Target Branch

You may want Jenkins to build the merged PR (that is the merge of sourceBranch into targetBranch) to catch any issues resulting from this. To do this change the Branch Specifier from




If you are building the merged PR you probably want Jenkins to do a new build when the target branch changes. There is an advanced option in the build trigger, "Rebuild if destination branch changes?" which enables this.

You probably also only want to build if the PR was mergeable, and possibly also without conflicts. There are advanced options in the build trigger for both of these.

If you are using the StashNotifier plugin and have enabled the 'Notify Stash Instance' Post-build Action while building the merged PR, you need to set


as Commit SHA-1 to record the build result against the source commit.
Notify Stash Instance

If you have enabled the 'Notify Stash Instance' Post-build Action and also enabled the 'Merge before build' extension you need to add '${pullRequestCommit}' as Commit SHA-1. Otherwise you'll notify Stash with the commit hash resulting from the merge which isn't known to Stash (since it's merged locally).

Rerun test builds

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

Adding additional parameters to a build

If you want to add additional parameters to the triggered build, add comments using the pattern p:<parameter_name>=<value>, one at each line, prefixed with 'p:'. If the same parameter name appears multiple times the latest comment with that parameter will decide the value.


test this please

Post Build Comment

It is possible to add a post build action that gives the option to post additional information to Stash when a build has been either successful or failed. These comments can contain environment variables that will be translated when posted to Stash.

This feature can be used to post for instance a url to the deployed application or code coverage at a successful build and why the build failed like what tests that did not pass.


Release notes;

  • Bug fix - Jenkins issue #30558 - sockets causing problems with hanging triggers
  • Bug fix - include default parameter values in build queue
  • Added project name to log messages
  • Branch name filters can now be regular expressions
  • Support all build states (now all states are reported, not just success or everything else as failure in the build PR comment)
  • Fix PR branch filters
  • Added ability to only keep the most recent PR status comment
  • Logging improvements
  • Ability to limit PR builds to specified target branches only
  • Added credentials support - this is a breaking change, please add a username/password credential for the user you want PR build comments to be posted from. Old builds will fail until you update them with the right credentials from the credentials plugin. 
  • Fixup branch & ref specs in git config - again this is a breaking change and you should update your git configuration (URL, ref spec & branch specifier), please see the updated README  
  • Fix bug with Stash response code handling 
  • Better error handling when Stash returns 200/OK response
  • Added support for custom parameters in the 'test this please' comment
  • Option to ignore SSL certificates (useful if you dont have proper certificates with your Stash instance)
  • Fixes for PR pagination
  • Added build duration to build finished message in PR - useful for tracking runtimes/test overheads added in PRs. 
  • Improved Stash polling
  • Better JSON handling 
  • Added better support for the notify Stash plugin to only tag the source commit SHA1
  • Bugfixes
  • Use Git SCM as provider for hostname and credentials needed for the pull request builder
  • Now it is also possible to verify pull requests from another fork (while previously it would only work in the same repository, or at least with the merge before build feature). Prerequisite is that you add +refs/pull-requests/:refs/remotes/origin/pr/ as refspec.
  • Additionally you can filter on the target branch which makes you able to restrict checking pull requests on a specific (release) branch.
  • Support for global environment variables has been added.
  • Added post build custom comment support
  • Marked credentials plugin as required dependency for upcoming v1.3.0 release with Credentials support
  • Added ability to customise the build phrase (change from the default of 'test this please')
  • Added ability to only have PR built if its merge-able (i..e has been approved)
  • Added ability to only have PR built if its not conflicted
  • Added check to only build PR on comment (don't auto build) based on build phrase (default is 'test this please')
  • Fix bug with passing branch names with a '/'
  • Reduce logging verbosity
  • Initial release
ArchivesGet past versions