Fedora is quite easy.
$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
$ sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
$ sudo yum install jenkins
$ sudo service jenkins start/stop/restart
Start jenkins by
$ sudo service jenkins start
You will get a success message.
Starting Jenkins [ OK ]
By default jenkins starts on port 8080. Visit
http://localhost:8080. You will be greeted by jenkins index page.
Setting up System
shell for jenkins user
$ sudo usermod -s /bin/bash jenkins
home for jenkins user
$ sudo usermod -m /var/lib/jenkins jenkins
Now we have to perform next steps as
jenkins user. You can give superuser permissions to
$ sudo su - jenkins
$ curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled
Complete script is here
$ vi /var/lib/jenkins/.bashrc
$ [ -s "/var/lib/jenkins/.rvm/scripts/rvm" ] && source "/var/lib/jenkins/.rvm/scripts/rvm" # This loads RVM into a shell session.
Make sure that you have configured your
bashrc properly so that
PATH has everything that is needed to run a Rails project. I spent a lot of time with
nodejs installed. Later i realized that my
bashrc was not containing
I am using Gitlab as the repository server.
Create new key with
From the jenkins UI, you can install gitlab plugin. More info can be found here.
Build now hook
Add this web hook on your Gitlab project:
Now whenever there will be commit, gitlab will send a request to jenkins to trigger the build.
We can run rake tasks, shell scripts once the build is triggered. This configuration can be done on the project page on jenkins server.
I prefer running a shell script which will do
all the steps required to run specs. This script can be stored into version control system like git so that it will be available to everyone in your project.
I have created a sample ci script for a Rails 3.2+ project with PostgreSQL database here.
Post Build configuration
It allows to add email ids of project members who will get email after every build. It generates report for last build using various plugins.
Same steps can be used with CentOS to setup jenkins.