title: GitHub pull request builds now available on builds.apache.org
date: '2014-10-02T13:00:00+00:00'
permalink: github_pull_request_builds_now
layout: post

<font face="arial, helvetica, sans-serif"><span style="font-stretch: normal;">The ASF Infrastructure team is happy to announce that you can now set up jobs on <a href="https://builds.apache.org">builds.apache.org</a> to listen for pull requests to <a href="https://github.com/apache">github.com/apache</a> repositories, build that pull request’s changes, and then comment on the pull request with the build’s results. This is done using the <a href="http://www.cloudbees.com/products/jenkins-enterprise">Jenkins Enterprise</a> <a href="https://wiki.cloudbees.com/bin/view/DEV/Github+Pull+Request+Validation">GitHub pull request builder plugin</a>, generously provided to the ASF by our friends at <a href="http://www.cloudbees.com/">CloudBees</a>. We've set up the necessary hooks on all github.com/apache repositories that are up as of Wednesday, Oct 1, 2014, and will be adding the hooks to all new repositories going forward.</span><br /> <span style="font-stretch: normal;"></span><br /> <span style="font-stretch: normal;">Here’s what you need to do to set it up:</span><br /> </font> 
  <ul> 
    <li><font face="arial, helvetica, sans-serif">Create a new job, probably copied from an existing job.</font></li> 
    <li><font face="arial, helvetica, sans-serif">Make sure you’re not doing any “mvn deploy” or equivalent in the new job - this job shouldn’t be deploying any artifacts to Nexus, etc.</font></li> 
    <li><font face="arial, helvetica, sans-serif">Check the &quot;Enable Git validated merge support” box - you can leave the first few fields set to their default, since we’re not actually pushing anything. This is just required to get the pull request builder to register correctly.</font></li> 
    <li><font face="arial, helvetica, sans-serif"><span style="font-stretch: normal;">Set the “GitHub project” field to the HTTP URL for your repository - i.e.,&quot;http://github.com/apache/incubator-brooklyn/&quot;</span><span style="font-stretch: normal;">- make sure it ends with that trailing slash and doesn’t include .git, etc.</span></font></li> 
    <li><font face="arial, helvetica, sans-serif"><span style="font-stretch: normal;"></span>In the Git SCM section of the job configuration, set the repository URL to point to the GitHub git:// URL for your repository - i.e.,&nbsp;git://github.com/apache/incubator-brooklyn.git.</font></li> 
    <li><font face="arial, helvetica, sans-serif">You should be able to leave the “Branches to build” field as is - this won’t be relevant anyway.</font></li> 
    <li><font face="arial, helvetica, sans-serif">Click the “Add” button in “Additional Behaviors” and choose &quot;Strategy for choosing what to build”. Make sure the choosing strategy is set to “Build commits submitted for validated merge”.</font></li> 
    <li><font face="arial, helvetica, sans-serif">Uncheck any existing build triggers - this shouldn’t be running on a schedule, polling, running when SNAPSHOT dependencies are built, etc.</font></li> 
    <li><font face="arial, helvetica, sans-serif">Check the “Build pull requests to the repository” option in the build triggers.</font></li> 
    <li><font face="arial, helvetica, sans-serif">Optionally change anything else in the job that you’d like to be different for a pull request build than for a normal build - i.e., any downstream build triggers should probably be removed, &nbsp;you may want to change email recipients, etc.</font></li> 
    <li><font face="arial, helvetica, sans-serif">Save, and you’re done!</font></li> 
  </ul> 
  <p> <span style="font-stretch: normal;"><font face="arial, helvetica, sans-serif">Now when a pull request is opened or new changes are pushed to an existing pull request to your repository, this job will be triggered, and it will build the pull request. A link will be added to the pull request in the list of builds for the job, and when the build completes, Jenkins will comment on the pull request with the build result and a link to the build at <a href="https://builds.apache.org">builds.apache.org</a>.&nbsp;</font></span></p> 
  <p><font face="arial, helvetica, sans-serif"><span style="font-stretch: normal;"></span>In addition, you can also use the &quot;Build when a change is pushed to GitHub&quot; option in the build triggers for non-pull request jobs, instead of polling - Jenkins receives notifications from GitHub whenever one of our repositories has been pushed to. Jenkins can then determine which jobs use that repository and the branch that was pushed to, and trigger the appropriate build.<br /> <span style="font-stretch: normal;"></span><br /> <span style="font-stretch: normal;">If you have any questions or problems, please email builds@apache.org or open a BUILDS JIRA at <a href="https://issues.apache.org/jira/browse/BUILDS/">issues.apache.org</a>.&nbsp;</span></font> </p>
