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 http://pkg.jenkins-ci.org/redhat/jenkins.repo

# add to rpm
rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key

# 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: http://wiki.nginx.org/Install
# or here: https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7
# i prefer the digitalocean guide
# and here for nginx conf: https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy

# 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: https://github.com/sstephenson/ruby-build/wiki#suggested-build-environment
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 https://github.com/sstephenson/rbenv.git ~/.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

ruby 

Leave a Reply

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