Jenkins-CI with perlbrew on OSX

Continuous Integration

Continuous Integration (CI) is the autotesting of unit tests.

Why autotest?

There are many good answers. First and most importantly, developers get fast notification of when and where defects were committed to the source code repo. Testing on multiple platforms and environments also becomes possible and automatic. Invoking a unit test build manually is silly when we have computers. Let's be smart and lazy.

headshot.png Jenkins is a fork of Hudson. It's open source, free, and mature. Polyglot; it'll test language. Network farm architecture. Plugins for everything.

This build will set up a sane Jenkins on OSX against gitolite with notification via IRC and Growl and metrics via Dashboard View.

I use perlbrew. This build will also show you how to configure tests using a perlbrew's prove(1).

OSX installation

  1. Install from package from http://jenkins-ci.org/ (don't use brew install jenkins - it's old)
  2. cpanm -S Task::Jenkins

Jenkins menu | Manage Jenkins | Manage Plugins

  1. Git Client Plugin
  2. Git Plugin
  3. Instant Messaging Plugin
  4. IRC Plugin
  5. Growl Plugin
  6. Redmine Plugin
  7. Active Directory plugin
  8. Perl Plugin
  9. Green Balls - show green balls for successful tests instead of blue
  10. Dashboard View - more test metrics

Deactivate:

  1. CVS
  2. Svn

Jenkins menu | Manage Jenkins | Configure System

Global properties

[√] Environment variables

PERLBREW_HOME: /opt/perlbrew (or wherever you have perlbrew installed)

PERLBREW_ROOT: /opt/perlbrew (ditto)

Git plugin

Global Config user.name Value: Jenkins CI

Global Config user.email Value: jenkins@example.com

Growl

Global password: Holla-At-Me

Shell

Shell executable: /bin/bash

Needed instead of /bin/sh for perlbrew integration.

IRC

[√] Enable IRC Notification

Hostname: irc.example.com

Port: 6667

Email-notification

SMTP server: smtp.example.com

Default email suffix: @your-domain.com

Configure Jenkins Git user

Instructions at https://wiki.jenkins-ci.org/display/JENKINS/Gitolite

In short:

  1. Create ssh-key for user jenkins.
  2. Copy to gitolite-admin/keydir/ as jenkins_rsa.pub
  3. Add jenkins_rsa to readonly users in gitolite-admin/conf/gitolite.conf
  4. git commit -am 'Add jenkins' && git push

Configure Global Security

Can plug into AD, LDAP, Redmine and more for authentication.

We use Active Directory in this land of Windows. Our settings similar to:

Domain Name: ads.example.com

Bind DN: CN=redacted,OU=Services,OU=Users,OU=Example Co.,DC=ads,DC=example,DC=com

Bind Password: redacted

[√] Logged-in users can do anything

Configure Dashboard View

On main page:

  1. Click the [+] tab
  2. Name it ""
  3. Add everything?

Jenkins Project Configuration

How to add a new git repo to Jenkins.

Click New Job on the left.

Job Name: Widget-Twister

[√] Build a free-style software project

Source Code Management

[√] Git

Repository URL: git@git:repository-name

Build triggers:

[√] Poll SCM

Schedule:

# every 5 minutes M-F
H/5 * * * 1-5

Is there a way to use a file-change notifier (eg linux's inotify) instead?

Build

Execute Shell | Add build step

source /opt/perlbrew/etc/bashrc
perlbrew use perl-5.16.2@dev
/opt/perlbrew/libs/perl-5.16.2@dev/bin/prove -r --timer --formatter=TAP::Formatter::JUnit -l t

If you don't need perlbrew, this should do the trick:

prove -r --timer --formatter=TAP::Formatter::JUnit -l t

Add post-build action: Growl

Growl IP: Your desktop IP

Also add passsword "Holla-At-Me" to System Preferences | Growl. This will permit other computers to send notifications to your Desktop.

This is more of a shared secret than a password. It will open your desktop up to Growl shenanigans from coworkers.

Add post-build action: IRC Notication

Click Advanced

Channel Name: #ci

Notification Strategy: change

Dealing with Java heap errors on OSX

Problem: The Java Permgen pool would run out of memory and the app would stop responding.

Jenkins' heap allocations can be viewed by running sudo jmap -heap $(pgrep -u jenkins java)

Fix: Submitted https://github.com/jenkinsci/jenkins/pull/828. This adds controls for Java heap sizing and working defaults on OSX.

Leave a comment

About Joshua Keroes

user-pic I like you.