Friday, December 23, 2011

DEV@cloud Meets GitHub Janky

GitHub announced Jenkins-based continuous integration using Janky and Hubot with Campfire chat integration. Basically, it means from the Campfire chatroom we can setup a Jenkins job, setup service hooks on GitHub to trigger builds, get build info and so forth.

It sounded pretty compelling so I thought I would give it a try. The setup requires running Janky and Hubot web applications, and to wire them with Campfire chatroom and Jenkins server.

Here is how I went about setting it all up to trigger Jenkins job management from chat room.

I got a Jenkins instance provisioned with few mouse clicks at CloudBees DEV@cloud. You can run your own Jenkins server and also then do all the administration and management, but it's much easier and cheaper to have someone else do it for you.

CloudBees offers the DEV@cloud platform which includes Jenkins in the Cloud, and unlimited Git and SVN repositories with all PaaS benefits (backups, high availability, secured, etc.). Checkout our new reduced pricing and choose the plan that fits your needs. You can start with a free subscription or choose the plan that fits your needs. Finally, if you have an Open Source project, you can join our FOSS program.

Not only are there obvious cost and PaaS-centric benefits for developers, rather than hosting Jenkins on their own, but CloudBees DEV@cloud comes ready to work with Janky and already has GitHub integration. Thus, it was an obvious choice for me.

Janky needs a Notification plugin to receive build related notifications. I installed the Notification plugin on the Jenkins Plugin management console.

Janky is a web application that talks to Jenkins, GitHub, Hubot and Campfire chat room. It's a Ruby/Sinatra application that serves the commands that are entered in the chat room and relayed via Hubot chat bot. It supports various commands meant to manage the builds of your GitHub repositories by communicating with Jenkins and GitHub. I followed Janky GitHub page to set it up. You can host it anywhere but make sure it accepts incoming connections. For our RUN@cloud platform, we are working on adding procfile support which will allow running Janky or Hubot or other non-Java languages based apps. Stay tuned, as it's being cooked!

Setting Janky was not that hard. The most critical part of this process was setting up about a dozen environment variables, most of these were credentials of GitHub, Hubot, Campfire chat and URL for Jenkins. Jenkins running on CloudBees DEV@cloud is protected, so I set JANKY_BUILDER_DEFAULT to the URL with basic auth. Please note the URL encoding applied to the basic auth username:password value.

Once Janky was setup, accessing it in browser shows the page below

Hubot is a chat bot developed by Github. It has built in support for Campfire chat. There are other adapters for various chat and IM systems, for example, IRC, GTalk etc. It's quite extensible, you can drop your own script to add additional commands that this bot can respond to. To add support for Jenkins commands, I needed to add script. I also had to set the environment variable to point to Janky endpoint URL with shared basic auth. This Janky endpoint listens to communication from Hubot.

Note about configuring Campfire chat: I had to set campfire env variable for Janky and Hubot with the chat room name and id, respectively.

While testing, I noticed Janky did not support talking to Jenkins over HTTPS. I fixed it in my Janky fork. My pull request has been accepted by the Janky project owner and it is now merged to the trunk. The next version of Janky gem should have this fix. In the meantime, you can either use my fork or Janky trunk which has these fixes merged.

Show Time
Once I had Hubot and Janky configured, I logged into my Campfire chat room as a guest and noticed Hubot present in the chat room as Vivek P, since the Campfire account was set up with this name, and Hubot chat bot was set up with the same account. Real Vivek is me. Once in the chat room, I typed a command to set up Jenkins jobs for my GitHub repositories.

Almost instantly, there were jobs created on my Jenkins instance running over DEV@cloud. The job names were not what I expected, they look like some kind of unique ID, maybe a commit ID, but I don't think they are.

On checking the Jenkins job configuration, the notification plugin configuration had an entry with Janky endpoint where it can post build notifications.

The Job was configured with the default build script that goes in the Janky configuration config/jobs/default.xml.erb,

To customize the build script, update default.xml.erb with your custom script and run hubot ci setup in the Campfire chatroom and the corresponding Jenkins job will be updated with the new script.

To sum it up, Janky is a great idea that opens up the social aspects of managing Jenkins jobs along with GitHub repos! DEV@cloud works seamlessly with Janky and provides many other benefits.

DEV@cloud is already GitHub friendly. Read how you can establish post-commit-hook to trigger build on commits to your GitHub repositories or how you can setup continuous deployment of your GitHub repo on RUN@cloud platform using DEV@cloud Jenkins in the cloud.

If you don't already have a CloudBees account, sign up now. You can subscribe to free DEV@cloud and RUN@cloud services to provision your instance of Jenkins, MySQL DB and deploy apps -- all automatically providing the benefits that come with the cloud and with the additional value-add of deep GitHub integration. And of course use Janky to manage them from a chat room!

-- Vivek Pandey
Elite Developer, CloudBees

Follow CloudBees:
Facebook Twitter


  1. if installing Janky would just be as easy as Jenkins...
    Janky has just so many dependencies which I will never have available in a closed environment at work.

  2. Does your tutorial assume deploying Jenky at Heroku (as the instructions referenced say)and then point to Jenkins on Cloudbees?