Linux sysadmin in a developers world.

Everyone knows about pushing your dotfiles to github/bitbucket or whatever version control provider you like best but not many people implement a easy way to copy or link the dotfiles.

Lots of people use bloatedgems to manage the linking or even write there own but to me these are just over engineered for my needs. My solution is to use a tool that will be already on everyone's machine GNU/Make - nice and simple!

Below is a copy of my Makefile which I used to keep my desktop (archlinux) and my laptop (Slackware) in sync. You can also find it on my git account.

I will add a Chef cookbook and a SaltStack state to my git to automate the install - the way it should be!

Jenkins setup on CentOS/Redhat

Installing Jenkins can be as easy as downloading the Jenkins WAR file and then running it from the command line. I prefer to use Jenkins own repo as it allows you to update to the latest version with easy and in the case of redhat based distributions you get an INIT script too.

To install Jenkins via YUM then run these commands as root or sudo under a user account and you will be good to go!

Jenkins Plugins

To install Jenkins plug-ins from the main page go to Manage Jenkins -> Plugin Manager then click available. From here you can search for the plug-ins listed below.

On a side note, checkout the Chuck Norris and Green ball plug-ins.

Jenkins Git Plugin

The main plug-in that you will need is this one, it allows us to pull down from a Git repo.

Brakeman Plugin

Brakeman plugin detects security vulnerabilities in RoR applications and as such is useful to run against builds for production environments. To run Brakeman during a build add the following line to your build step.

brakeman -o brakeman-output.tabs

This is included in my build script below.

ThinBackup Plugin

ThinBackup Plugin takes a backup of your current Jenkins Home in TAR GZ format, clearly very handy! Once you have it installed then go to Manage Jenkins -> ThinBackup -> Settings and fill out the required information. I suggest you use something like Rsnapshot to pull the backups offsite nightly.

Dashboard View

Dashboard View allows you to make a custom view that looks a lot snappier than the default. You can use this to remove any un-needed information such as build times etc.

Workspace Cleanup Plugin

I love this plugin, before each build it will clear out the workspace. Such a simple thing to do but not clearing out the workspace has caused me a few headaches in the past!

When you create a new build make sure you tick the box saying clear out workspace before build!

Jenkins Build Script

Once I have created a new Job, selected a free-style project and then filled in the git account information (remember the delete workspace checkbox). As a post-build action select Publish Brakeman warnings and as the File output enter

brakeman-output.tabs

Add the script below in as a Build step as a execute shell, it will do the following steps:

Run a bundle install for and GEM updates.

Create the DBs and migrate and changes.

Run Brakeman

Run the RSpec tests, if they fail Jenkins will fail the build.

Deploy the code base to EngineYard

Check the URL for a 200 response, if it fails rollback to the last good version

You can easily modify this script to use Capistrano instead of the Engineyard Gem. The results of the Brakeman scan will be shown on the Job main page.