Janky - The forgotten tool

Where I work we use GitHub as our Git central repository, and we have Yoda, our Hubot, helping us on our day to day tasks. We had to setup a Continuous Integration server for our project and after looking at all the CI options out there, we had to decide between Travis-ci or Jenkins. Both are well-known continuous integration servers but they were not exactly what we needed at the moment. Travis is $150 per month and Jenkins has to be manually installed and configured, plus it has an awkward interface.

Travis could certainly be our solution in a future moment but, for now, we decided to try Jenkins out. As a solution for the issues raised, we decided to use Janky, “(…) a continuous integration server built on top of Jenkins, controlled by Hubot, and designed for GitHub”.

When I first read Janky’s readme, I thought it would be an easy setup… Well, I couldn’t be more wrong. It’s hard to know which values should be set for each of the required environment variables, and the gem is outdated forcing you to build it from git directly…

Anyway, one can always fork and submit pull requests, right? So, let’s focus on the setup process.

Installing Jenkins

Janky recommends Jenkins version 1.427, but as I installed a newer version (1.498) you should be fine with newer versions. Installing Jenkins guide is easy to follow and will help you on installing a Jenkins server if you don’t have one yet.

Installing Janky

Janky’s guide on the other hand will guide you to failure since the beginning as the [Gist][] you use to install is outdated and lacks the *JANKY_BRANCH* variable definition.. Apparently the gist has been updated, so you can almost run the commands as they say:

➜ git clone git://gist.github.com/1497335 janky
➜ cd janky
➜ heroku create --stack cedar

At this point, I suggest to not use the latest released gem version (0.9.13) – as its outdated – and bundle the gem directly from the repository by changing the following lines in the Gemfile.

gem "janky"

to:

gem "janky", :git => "git://github.com/github/janky.git"

And now we can proceed with the installation guide:

➜ bundle install
➜ git add Gemfile.lock
➜ git commit Gemfile.lock -m "lock bundle"
➜ git push heroku master

Configuring Janky

All variables are defined with the following syntax:

➜ heroku config:add VARIABLE=value


Define janky’s URL on heroku with a trailing slash:

JANKY_BASE_URL: http://JANKY_APP_NAME.herokuapp.com/

Our server has Jenkins’ Matrix-based security enabled, so only registered users can access Jenkins. In order to authorize Janky, you need to create an account for it and specify both the username and its api token that can be found on the user configuration page: http://jenkins.example.com/user/JENKINS_USER_NAME/configure on the URL.

JANKY_BUILDER_DEFAULT: http://USER:API_TOKEN@jenkins.example.com/

Define the configuration dir (default):

JANKY_CONFIG_DIR: /app/config

Hubot’s user and password are the same passwords you will use when configuring Janky’s hubot script. Create your own secure user/password here.

JANKY_HUBOT_USER: Login used to protect the Hubot API.
JANKY_HUBOT_PASSWORD: Password for the Hubot API.

You have to create a github account (or use your own) to allow janky to connect to github and set up service hooks for you.

JANKY_GITHUB_USER: Login of the GitHub user. Requires Administrative privileges to set up service hooks.
JANKY_GITHUB_PASSWORD: Password for the GitHub user.

There are two variables that apparently should be configured with the same value, and the token value is obtained by using the one that comes in the following curl command response:

➜ curl -u USERNAME:PASSWORD -d '{ "scopes": [ "repo:status" ], "note": "janky" }' \
https://api.github.com/authorizations

JANKY_GITHUB_HOOK_SECRET: Secret used to sign hook requests from GitHub.
JANKY_GITHUB_STATUS_TOKEN: To update pull requests with the build status.

You should also specifiy the default chat room, but I don’t know whether this is the room name or number on campfire. It should not be a problem as long as you specify the room for each project.

JANKY_CHAT_DEFAULT_ROOM: Chat room where notifications are sent by default.

Migrating the database

Now you can run the database migration.

➜ heroku run rake db:migrate

Configuring hubot

Configuring hubot is pretty easy, all you have to do is enable its script on hubot-scripts.json:

["janky.coffee"]

and define an environment variable on hubot’s server (not janky’s). Don’t forget to append _hubot/ to the URL:

HUBOT_JANKY_URL: http://JANKY_HUBOT_USER:JANKY_HUBOT_PASSWORD@JANKY_APP_NAME.herokuapp.com/_hubot/

Troubleshooting

After all heroku commands you might need to specify the app on which you want to run the command using the argument −−app.

➜ heroku run rake db:migrate --app MY_APP_NAME
  1. Date: January 17, 2013
  2. Tags: janky, jenkins, github, ci, continuous, integration, campfire, and hubot
comments powered by Disqus