Install Jenkins CI for Rails Project With Cucumber
Jenkins
This is a short guide on how to setup Jenkins(Hudson) for Rails project with cucumber features. The steps are described for Ubuntu machine. First of all – what is Jenkins?
Jenkins is an award-winning application that monitors executions of repeated jobs, such as building a software project or jobs run by cron. Among those things, current Jenkins focuses on the following two jobs:
- Building/testing software projects continuously, just like CruiseControl or DamageControl. In a nutshell, Jenkins provides an easy-to-use so-called continuous integration system, making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build. The automated, continuous build increases the productivity.
- Monitoring executions of externally-run jobs, such as cron jobs and procmail jobs, even those that are run on a remote machine. For example, with cron, all you receive is regular e-mails that capture the output, and it is up to you to look at them diligently and notice when it broke. Jenkins keeps those outputs and makes it easy for you to notice when something is wrong.
Let’s install Jenkins with following commands:
1 2 3 4 |
|
From this point you can start jenkins like this:
1
|
|
NGINX
Now we need to configure nginx for jenkins, the most basic setup will look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
So now jenkins web interface is up and running at jenkins.project_name.com
Jenkins User
Jenkins using jenkins
ubuntu user by default. We should add the pair of ssh keys to him, as well as install ruby. For this purposes login as jenkins
sudo su jenkins
. ssh-keygen -t rsa
to generate ssh keys. Install ruby with rvm or your ruby version manager of choice. Also we should add name and email to git for jenkins. So the list of commands will be following:
1 2 3 4 5 6 7 8 |
|
Jenkins Plugins
Now let’s install some useful plugins for Jenkins. Go to the Manage Jenkins –> Manage Plugins and check following plugins:
- Git Client Plugin
- GitHub Plugin
- Ruby Plugin
- Rake plugin
- Cucumber plugin
Add project to Jenkins
Now we a ready to add our project to Jenkins. Go to the New Job –> Free-style Navigate to Source Code Management
menu and choose Git, enter your git repository address and specify the branch.
Now we only need to specify commands for building our project. Specify “Execute shell script” and add following commands, you may want to change them for your needs:
1 2 3 4 5 6 7 |
|
You also may want to add some notifications, for my project i’m using hipchat notification, but the most easiest solution to setup is email notifications. You will need to add SMTP settings in the Manage Jenkins –> System Configurations –> E-mail Notification. After that just specify emails in the project settings.
If you want to run your rspec tests instead of cucumber, or run all together just change your build commands.
That’s all, you are ready to go!