Jenkins-CI with perlbrew on OSX
Continuous Integration (CI) is the autotesting of unit tests.
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.
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).
- Install from package from http://jenkins-ci.org/ (don't use
brew install jenkins- it's old)
- cpanm -S Task::Jenkins
Jenkins menu | Manage Jenkins | Manage Plugins
- Git Client Plugin
- Git Plugin
- Instant Messaging Plugin
- IRC Plugin
- Growl Plugin
- Redmine Plugin
- Active Directory plugin
- Perl Plugin
- Green Balls - show green balls for successful tests instead of blue
- Dashboard View - more test metrics
Jenkins menu | Manage Jenkins | Configure System
[√] Environment variables
PERLBREW_HOME: /opt/perlbrew (or wherever you have perlbrew installed)
PERLBREW_ROOT: /opt/perlbrew (ditto)
Global Config user.name Value: Jenkins CI
Global Config user.email Value: firstname.lastname@example.org
Global password: Holla-At-Me
Shell executable: /bin/bash
Needed instead of /bin/sh for perlbrew integration.
[√] Enable IRC 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
- Create ssh-key for user jenkins.
- Copy to gitolite-admin/keydir/ as jenkins_rsa.pub
- Add jenkins_rsa to readonly users in gitolite-admin/conf/gitolite.conf
- 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:
- Click the [+] tab
- Name it ""
- 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
Repository URL: git@git:repository-name
[√] Poll SCM
# every 5 minutes M-F H/5 * * * 1-5
Is there a way to use a file-change notifier (eg linux's inotify) instead?
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
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.