Recently, like any other serious engineer, I realized I need a CI server. I didn’t want to spend money on travis-ci, or using 3rd-party services like codeship.com and alike, so I decided to roll my own Jenkins server. I thought it will be just to start a new instance, install Jenkins, configure some plugins and up it goes! C’mon, how hard could that possibly be? I could probably get it running in couples of hours!
I’ve never been so wrong in my entire life.
Installing Jenkins is indeed a piece of cake, but configuring the thing is a real pain in the butt.
The first weekend passed by and I haven’t got it running, I thought: okay, this is annoying, but I can probably get it done in the next couples of hours.
But the second weekend passed by and Jenkins still didn’t work, I was not annoyed anymore. I was frustrated, so frustrated that I decided to rant about it (after I get it done, of course).
Seriously, can’t you make this a bit more verbose and tell me what could be possibly wrong? All I want is just a simple Jenkins server that builds every Pull Request, and gets trigged when something happened on my git server. Is it too much of a thing to ask? Also, can someone please write some tutorials that is up-to-date?
The cool thing about Jenkins is that it is very flexible, but so flexible that any single plugin can break your system. I ran into NullPointerException, and when that is fixed, my build never gets triggered. At some moment in time I got it running, but naively I updated the plugin to the latest version and it stopped working. Never thought Jenkins will be this troublesome.
So here you go, this is how I get it done (at last, yea, I managed to get it done without committing suicide).
- Number 1 rule: use Github Integration plugin, instead of the probably outdated GitHub pull request builder.
- In fact if you happened to install GitHub pull request builder, you need to disable Auto-manage webhooks in Jenkins configuration, otherwise all the hooks will be handled by this plugin, instead of GitHub Integration plugin.
- Configure Github Integration plugin is pretty easy, although the guy was pretty terse in words.
- But then don’t upgrade the plugin! I initially used Github Integration plugin v0.1.0-rc9, and it works. But v0.1.0-rc10 has just been released couple days ago, and it stops working when I upgraded it. So this is the learning: Jenkins plugins might stop working when you upgrade it, think twice before doing that.
- As a bonus, use the Environment Script plugin to specify environment variables needed for your build. Don’t use Shell script, because in Jenkins, shell scripts will be executed with sh -ex script_file.sh, so anything you do with export ABC=… will go away once the script finished executing.
But the Environment Script plugin is pretty retarded. You set the environment variables with echo “ABC=…”, instead of export ABC=….
Since it took me way much more time than I estimated, I decided to take some extra miles. Here are a few things that will make your build a bit cooler:
- Use Scoverage plugin to publish test coverage results (produced by sbt-scoverage, for instance)
- Use Embedded Build Status plugin to display those tiny logos in your README file on github. Honestly, those logos are quite satisfying to have on your repo.
- Use Slack plugin for better integration with Slack.
When something you thought as “trivial” as setting up Jenkins took you this much time, you will start worrying about all other estimations you have made in your entire life…