We’ve been using Phabricator for just about a year here at Disqus. It was originally created at Facebook and open sourced in Spring 2011. To sum it up using their own words: “Phabricator is a open source collection of web applications which make it easier to write, review, and share source code.” The small team working on it at Phacility (the SaaS company behind Phabricator) is constantly improving it so it’s on a continuous release cycle.
Jenkins has been used for continuous integration testing here for much longer. I’m not exactly sure for how long since it was setup before I started in September 2011. David Cramer has always been pushing for an ideal continuous integration/deployment system (IE herehere) so part of my duties has been to improve what we have to achieve that goal (we’re hiring).
Currently, there isn’t a direct CI hook into Phabricator that is as deep as say Github+Travis. However, with a little script and an simple event listener for Arcanist, we can replicate most of that functionality.
First things, first. Jenkins needs an account in Phabricator to perform actions on the differentials. Make sure the account has the role of System Agent. This keeps it from polluting the user autocomplete in various forms and allows administrative access to its conduit certificate.
You will need to install Arcanist wherever you plan to have Jenkins run these Phabricator builds (master and/or slaves nodes.) However, it doesn’t need the custom PhutilEventListener described below. Instead of running arc install-certificate on each node, it’s easier to just distribute the .arcrc with your Phabricator instance’s conduit uri, Jenkin’s Phabricator username and conduit certificate. Make sure to place .arcrc in Jenkin’s user’s home directory. A good way to test you have arc installed and configured properly is by running arc call-conduit user.whoami from the Jenkins node script console to double check it’s the right user. Make sure to change the conduit-uri to your instance.
To notify Jenkins to do builds on differentials, we need a custom PhutilEventListener. It’s a super simple class with only a couple configuration options. The Arcanist user guide has instructions on how to Create a libphutil library.
Last but not least, setting up the Jenkins job. As there are numerous ways that jobs can be configured, I’m just going to outline a crude one that can be adapted to your own style. Your Jenkins installation will need at least the PostBuildScript Plugin and Python Plugin.
Since arc diff is going to be kicking off this job, it needs to be a parameterized build that takes a String Paramter DIFF_ID so it knows which patch to run.
As we use Git for SCM at Disqus, setup the job to follow origin/master and under advanced, enable Prune remote branches before build and Clean after checkout to keep the repo tidy.
There won’t be automatic build triggers since we’re using the event listener to trigger builds on arc diff.
Below is the shell script you can drop into an “Execute shell” build step that will handle applying the diff. This should be the first build step.
Now to post back to Phabricator with the results of the build. This needs to be added to the Post-build Actions. Otherwise, the results of the build won’t be available yet from the Jenkins API. Add “[PostBuildScript] – Execute a set of scripts” action with a build step of “Execute Python Script” of the following script (make sure Python-phabricator is in the PYTHON_PATH):
Huge thanks to Zameer Manji who interned with us Summer 2012 and was instrumental in getting this working!