How To Install Jenkins And Set Up Jenkins CI For Rails Projects

Travis CI is a great solution for OpenSource project. However, what if you want to setup an internal CI server for private projects? Jenkins CI is the choice.

In this post, I’ll guide you through installing and configuring Jenkins CI on a VPS (EC2 instance in this post)

OS Assumption

Assume that you are running an EC2 instance with a Ubuntu system as below:

If you don’t yet have a VPS set up, there is an Amazon free tier that is recommended.

Install Rails Environment

Because you’ll be using this Jenkins CI server for Rails projects, install the following Ruby/Rails libs and tools:

– Install RVM and Ruby

We need to have git core and curl for RVM installation, so install them like so:

And install RVM with ruby as user jenkins:

– Install Possible Databases
MySQL

Postgres

If you had a problem with UTF-8 take a look at http://wiki.gentoo.org/wiki/PostgreSQL

MongoDB

Now Install Jenkins

Installation:

Uninstalling Jenkins is easy too, just:

FYI – There is also a detailed guide for installing Jenkins on Ubuntu.

Run Jenkins on Port 80

By default, Jenkins runs on port 8080, so you’ll need to reverse proxy port 80 to port 8080 for Jenkins. This will make the CI server public to the world.

To install nginx and set this up, open up a terminal and type in:

Open up the config file in vim, and update it.

Notice: Jenkins shows build histories and other information. Tto keep the whole CI server private, you’d better use this guide to add basic auth for your Jenkins CI. It is strongly recommended.

Install valuable plugins for Jenkins

After all of the above installations are done, you are able to visit your Jenkins CI server using your domain. Now it’s time to install the following plugins from the JenkinsPlugin > Manager section:

For more plugins, check out the Jenkins Plugins Document.

References & Resources

https://wiki.jenkins-ci.org/display/JENKINS/Configuring+a+Rails+build
http://aptobits.com/2012/09/setting-up-jenkins-ci-on-an-amazon-ec2-linux-instance/
http://watirmelon.com/2011/08/29/running-your-watir-webdriver-tests-in-the-cloud-for-free/
http://gistflow.com/posts/492-jenkins-ci-setup-for-rails-application-from-scratch
http://blogs.burnsidedigital.com/2013/01/setting-jenkins-ci-server-for-rails-project-on-a-vagrant-box/

Ready to build an industry-changing product?

Let’s talk about your project today >>