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:

Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-40-virtual x86_64) 

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:

sudo apt-get install build-essential git-core sudo apt-get install curl 

And install RVM with ruby as user jenkins:

#remember to switch to user `jenkins` first sudo su jenkins  curl -L | bash -s stable --ruby sudo apt-get install libmysqlclient-dev ruby-dev 
– Install Possible Databases
sudo apt-get install mysql-client mysql-server libmysql-ruby libmysqlclient-dev 
sudo aptitude install libpq-dev sudo apt-get install postgresql sudo apt-get install postgresql-client 

If you had a problem with UTF-8 take a look at

sudo apt-key adv --keyserver --recv 7F0CEB10 echo 'deb dist 10gen' | sudo tee /etc/apt/sources.list.d/10gen.list sudo apt-get update sudo apt-get install mongodb-10gen 

Now Install Jenkins


wget -q -O - | sudo apt-key add - sudo sh -c 'echo deb binary/ > /etc/apt/sources.list.d/jenkins.list' sudo aptitude update sudo aptitude install jenkins 

Uninstalling Jenkins is easy too, just:

sudo apt-get remove jenkins 

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:

sudo apt-get install nginx sudo /etc/init.d/nginx start 

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

sudo vim /etc/nginx/nginx.conf 
http {          # ...Omitted Parts…          include /etc/nginx/conf.d/*.conf;    # This line not modified.         include /etc/nginx/sites-enabled/*;  # This line not modified.          ##         # Reverse proxy port 80 to port 8080 for Jenkins         ##         server {                 listen 80 default;                 server_name;                 location /{                         proxy_pass;                 }         } }  

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

Ready to build an industry-changing product?

Let’s talk about your project today >>