GitHub pull request builder plugin

Skip to end of metadata
Go to start of metadata

This plugin builds pull requests in github and report results.

Plugin Information

Plugin ID ghprb Changes In Latest Release
Since Latest Release
Latest Release
Latest Release Date
Required Core
Dependencies
1.21 (archives)
May 26, 2015
1.532
token-macro (version:1.10, optional)
git (version:2.2.4)
github-api (version:1.66)
build-flow-plugin (version:0.12, optional)
github (version:1.9.1)
ssh-agent (version:1.3)
Source Code
Issue Tracking
Pull Requests
Maintainer(s)
GitHub
Open Issues
Pull Requests
Honza Br��zdil (id: janinko)
Valdis Rigdon (id: valdisrigdon)
Usage Installations 2014-May 2716
2014-Jun 2829
2014-Jul 3091
2014-Aug 3206
2014-Sep 3366
2014-Oct 3665
2014-Nov 3751
2014-Dec 3823
2015-Jan 4033
2015-Feb 4191
2015-Mar 4553
2015-Apr 4616

Commands: 

When a new pull request is opened in the project and the author of the pull request isn't white-listed, builder will ask "Can one of the admins verify this patch?".

  • "ok to test" to accept this pull request for testing
  • "test this please" for a one time test run
  • "add to whitelist" to add the author to the whitelist

If the build fails for other various reasons you can rebuild.

  • "retest this please" to start a new build

Installation:

  • I recommend to create GitHub 'bot' user that will be used for communication with GitHub (however you can use your own account if you want).
  • The user needs to have push rights for your repository (must be collaborator (user repo) or must have Push & Pull rights (organization repo)).
  • If you want to use GitHub hooks have them set automatically the user needs to have administrator rights for your repository (must be owner (user repo) or must have Push, Pull & Administrative rights (organization repo))
  • Install the plugin.
  • Go to "Manage Jenkins" -> "Configure System" -> "Github pull requests builder" section.
  • If you are using Enterprise GitHub set the server api URL in "Github server api URL". Otherwise leave there "https://api.github.com".
  • Set your 'bot' user's Access Token.
    • If you don't have generated your access token you can generate one in "Advanced...".
      • Set your 'bot' user's GitHub username and password.
      • Press the "Create Access Token" button
      • Copy the generated Access Token into the field "Access Token"
      • Clear the username and password fields
    • If you don't want to use Access Token leave the field empty and fill the username and password in "Advanced...".
  • Add GitHub usernames of admins (these usernames will be used as defaults in new jobs).
  • Under Advanced, you can modify:
    • The phrase for adding users to the whitelist via comment. (Java regexp)
    • The phrase for accepting a pullrequest for testing. (Java regexp)
    • The phrase for starting a new build. (Java regexp)
    • The crontab line. This specify default setting for new jobs.
    • The target branch whitelist.  This allows you to test only pull requests targeted for the branches in this list.
    • If you want to get comments posted to GitHub for each build, fill the "Published Jenkins URL", if you only want to use the GitHub status API, leave it empty.
  • Save to preserve your changes.
  • Allow raw HTML rendering. (See JENKINS-22028)
    • Manage Jenkins > Configure Global Security > Under "markup formatter", set to "raw HTML"

Creating job:

  • Create a new job.
  • Add the project's GitHub URL to the "GitHub project" field (the one you can enter into browser. eg: "https://github.com/janinko/ghprb")
  • Select Git SCM.
  • Add your GitHub "Repository URL".
  • Under Advanced, set "refspec" to
    +refs/pull/*:refs/remotes/origin/pr/*
  • In "Branch Specifier", enter "${sha1}".
  • Under "Build Triggers", check "Github pull requests builder".
    • Add admins for this specific job.
    • If you want to use GitHub hooks for automatic testing, read the help for "Use github hooks for build triggering" in job configuration. Then you can check the checkbox.
    • In Advanced, you can modify:
      • The crontab line for this specific job. This schedules polling to GitHub for new changes in Pull Requests.
      • The whitelisted users for this specific job.
      • The organisation names whose members are considered whitelisted for this specific job.
  • Save to preserve your changes.
    Make sure you DON'T have "Prune remote branches before build" advanced option selected, since it will prune the branch created to test this build.

If you want to manually build the job, in the job setting check "This build is parameterized" and add string parameter named "sha1". When starting build give the "sha1" parameter commit id you want to build or refname (eg: "origin/pr/9/head").

Environment Variables

The plugin makes some very useful environment variables available.

  • ghprbActualCommit
  • ghprbActualCommitAuthor
  • ghprbActualCommitAuthorEmail
  • ghprbPullDescription
  • ghprbPullId
  • ghprbPullLink
  • ghprbPullTitle
  • ghprbSourceBranch
  • ghprbTargetBranch
  • sha1

Changelog

1.18

Add support for folder projects.
Correcting issue with default credentials.
Correcting issue with ghRepository being null when it shouldn't be.
Ignoring case when matching repo to url.
Changing the wording for pull requests that are mergeable.
Change requestForTesting phrase to a textArea.
Check if project is disabled, if it is then don't do anything.

1.14

A comment file can be created during the build and added to any comment made to the pull request. podarok#33
Added a [skip ci] setting, that can be changed. Adding the skip statement to the pull request body will cause the job not to run. sathiya-mit#29
Escaping single quotes in log statements tIGO#38
Fixed owner name deduction from url on github hook handling nikicat#40
Removed unused Test field from the config

1.13-1

Replacing deprecated Github.connect method. tIGO#39
Added a merge plugin for post build. If the build is successful, the job can specify conditions under which the pull request "button" will be pressed.

1.12

Fixes issue with checking rate limits for GitHub Enterprise
Internal refactorings
Fixes checking of TriggerTimer (JENKINS-22550)

1.11.2

Major reduction in the number of requests made to GitHub to avoid rate limit issues
Fixed changelog for a build so it reports differences between Pull Request build
Fixes bug on getting author email address from GitHub APIs
Updates warning message is URL isn't set on the GitHub project plugin
Adds some additional parameters to the build, such as the source branch, pull request link, etc.
Success/failure message now put into the comment on Pull Requests

1.10 - 1.11.1

Not publicly released.

1.9

Added job specific triggers.
Added more informations as job parameters.
Fix support for gh-ent token generation. JENKINS-17334
Lookup PR detailed information for each PR. JENKINS-17852
Fix closing PR.
various bugfixes

1.8

Support auto-close at build level
add pull id and target branch to environment variables
fix GitHub Hooks when authentication is required on Jenkins
various bug fixes and improvements

1.7

implemented support for GitHub hooks
added button for generating API token

1.6

option for specifying how to mark unstable builds in GitHub
Close failed pull requests automatically if plugin admin configured it
customizeable pass/fail comments
Refactoring of code
help description in Jenkins configuration

1.5

checkbox enabling sending comments when update of comment status fails
option to enter organisations which members are whitelisted
support for Enterprise GitHub
link to pull request into build description
fixes

1.4

Changed comment commands - phrases for testing once, pull request or add user to whitelist
"test this please" starts new build
"ok to test" allow pull request for building
"add to whitelist" add user to whitelist

1.3

Add published URL feature.
Enable connection to GitHub Enterprise instances.
Enable authentication via a token.
When automatic merge is possible, build the merge.

1.2

Use commit status API instead of comments for reporting results.

Labels

Edit
plugin-trigger plugin-trigger Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Add Comment