Skip to content

Instantly share code, notes, and snippets.

@jkeroes
Last active December 19, 2015 01:49
Show Gist options
  • Save jkeroes/5878762 to your computer and use it in GitHub Desktop.
Save jkeroes/5878762 to your computer and use it in GitHub Desktop.

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.

Problem

autoprove (Test::Continous): a lightweight Perl-only CI app. Broken in Perl 5.18.0+.

Smolder: a heavyweight Perl-only CI server. Broken in Perl 5.12+/OSX.

Solution

Jenkins. A fork of Hudson. Open source. Free. Mature. Polyglot. Network farm architecture. Plugins for everything.

OSX installation

  1. Install from http://jenkins-ci.org/ (don't use brew install jenkins - it's old)
  2. patch if necessary from jenkinsci/jenkins#828
  3. 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
  10. Dashboard View

Deactivate:

  1. CVS
  2. Svn

Jenkins menu | Manage Jenkins | Configure System

Global properties

[√] Environment variables

PERLBREW_HOME: /opt/perlbrew

PERLBREW_ROOT: /opt/perlbrew

Git plugin

Global Config user.name Value: Jenkins CI

Global Config user.email Value: [email protected] # or a role account

Growl

Global password: RingRing

Shell

Shell executable: /bin/bash

Needed instead of /bin/sh for perlbrew integration.

IRC

[√] Enable IRC Notification

Hostname: as7585.integra.net

Port: 6667

Email-notification

SMTP server: relay.integra.net

Default email suffix: @integratelecom.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, or Redmine for auth.

Configuration TBD.

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

[√] Copy from existing Job (eg CA-API)

Update the CA-API settings:

Source Code Management

[√] Git

Repository URL: git@git:repository-name

Build triggers:

[√] Poll SCM

Schedule:

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

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

Add post-build action: Growl

Growl IP: Your desktop IP

Also add passsword "RingRing" to System Preferences | Growl. This will permit other computers to send notifications to your Desktop.

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 jenkinsci/jenkins#828. This adds controls for Java heap sizing and working defaults on OSX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment