Jenkins 1.59 / CentOS 7 / GitHub / Rails / RSpec / Rbenv

As this is for personal use the system I configured has 1 64bit CPU, 1GB of RAM, and 30GB SSD HDD (the $10/mo DigitalOcean plan). I first tried it with the $5 plan, that kept giving me memory issues as Jenkins/Hudson runs on a JavaVM so for my needs 1GB of ram was needed. I won’t be running multiple builds with multiple nodes, pretty much whenever I push code to GitHub/BitBucket I want Jenkins to build and deploy code. If I push to master and it passes deploy to production, If I push to development and it passes deploy to staging.

My setup: 1 VM production server, 1 Physical staging server (in my office), 1 JenkinsCI VM server, and numerous repositories on GitHub and BitBucket.

Setting up Jenkins on CentOS 7

# ssh as root into your server

# grab Jenkins repo
wget -O /etc/yum.repos.d/jenkins.repo

# add to rpm
rpm --import

# update yum
yum update

# install git
yum install git

# install dev tools
yum groupinstall "Development Tools"

# install jenkins
yum install jenkins

# install java for jenkins
yum install java-1.7.0-openjdk

# open firewall for 8080 if you have firewalld on and are going to use 8080
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

# restart jenkins service
systemctl restart jenkins.service

# check on status
systemctl status jenkins.service

# add jenkins service boot on restart
chkconfig jenkins on

# at this point jenkins should be running point your browser to http://ip_address:8080

# additional steps if you want to have nginx in front of jenkins
# follow install procedures for nginx here:
# or here:
# i prefer the digitalocean guide
# and here for nginx conf:

# things you might need
yum install epel-release
yum install nodejs
yum install npm
yum install sqlite-devel

Setup for Rails / Rbenv

# for rbenv sourced from:
yum install -y gcc openssl-devel libyaml-devel readline-devel zlib-devel

# you might need to change jenkins user to be able to use a shell
vi /etc/passwd

# change jenkins entry from /bin/false to /bin/bash

# switch to jenkins user
su - jenkins

# install rbenv
git clone ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
exec -l $SHELL

# list all versions of ruby available
rbenv install --list

# install ruby 2.1.5
rbenv install 2.1.5

# 'rbenv rehash' with newer versions of rbenv this is not required 0.4.0 or later

# set 2.1.5 as global ruby
rbenv global 2.1.5


Leave a Reply

Your email address will not be published. Required fields are marked *