25
New Jersey Autumn 2009 Leveraging Continuous Integration for Fun and Profit! Jess Chadwick Independent Consultant http://blog.jesschadwick.com

Leveraging Continuous Integration For Fun And Profit!

Embed Size (px)

DESCRIPTION

This is an introduction to the concepts of Continuous Integration (with a little bit of Agile/XP thrown in for good measure).

Citation preview

Page 1: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Leveraging Continuous Integration for Fun and Profit!

Jess ChadwickIndependent Consultanthttp://blog.jesschadwick.com

Page 2: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Agenda

• What is Continuous Integration?• How does it fit in to the Agile lifecycle?• How do I implement it?• Best Practices

Page 3: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

What is Continuous Integration?Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verified by an automated build (including tests) to detect integration errors as quickly as possible.

Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop software more rapidly.

Martin Fowler, September 2000

Page 4: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Layers of Quality AssuranceCompilation

Unit Testing

Functional/UI Testing

Code Metrics

Deployment

Page 5: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Continuous Integration in XP

Page 6: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Benefits of Continuous Integration

•Unit, integration, functional testing

•Code metrics

•Code conformance

Provide confidence of

quality

•Exercise whole build and deployment process

Reduce risks

•Broken build

•Failed tests

•Can’t deploy

Shorten feedback loop

Page 7: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Exponentially Building Value

•SOLID (DI)

•Unit Testing

•Continuous Integration

Page 8: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Components

• Background process• Web site• Notification (email, system tray, RSS, etc.)

CI Server

• Compile• Run tests• Deploy• Anything you want!

Build Scripts

Page 9: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

CI Servers

Atlassian’s Bamboo

ThoughtWorks’ Cruise

CruiseControl family (CC, CC.NET, CC.rb)

Hudson JetBrains’ TeamCity

Microsoft’s Team Foundation

Server

Page 10: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Covert Operation

Can’t get your team to buy in?

Run it on your own box!

Page 11: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Build Scripts – NAnt<?xml version="1.0"?><project name="Hello World" default="build" basedir="."> <description>The Hello World of build files.</description> <property name="debug" value="true" overwrite="false" /> <target name="clean" description="remove all generated files"> <delete file="HelloWorld.exe" failonerror="false" /> <delete file="HelloWorld.pdb" failonerror="false" /> </target> <target name="build" description="compiles the source code"> <csc target="exe" output="HelloWorld.exe" debug="${debug}"> <sources> <includes name="HelloWorld.cs" /> </sources> </csc> </target></project>

Page 12: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Build Scripts – MSBuild<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <OutputPath>.\bin</OutputPath> </PropertyGroup> <Target Name="FooCompilation"> <MakeDir Directories= "$(OutputPath)"/> <Copy SourceFiles="Image.jpg" DestinationFiles="$(OutputPath)\Image.jpg"/> <Csc Sources="Foo2.cs" TargetType="module" OutputAssembly="$(OutputPath)\Foo2.netmodule" /> <Csc Sources="Foo1.cs" TargetType="exe" AddModules="$(OutputPath)\Foo2.netmodule" LinkResources="Image.jpg" OutputAssembly="$(OutputPath)\Foo1.exe" /> </Target></Project>

Page 13: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Build Scripts – psakeproperties { $testMessage = 'Executed Test!' $compileMessage = 'Executed Compile!' $cleanMessage = 'Executed Clean!' }

task default -depends Test

task Test -depends Compile, Clean { Write-Host $testMessage }

task Compile -depends Clean { Write-Host $compileMessage }

task Clean { Write-Host $cleanMessage }

Page 14: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Build Scripts – rake#!/usr/bin/env ruby

require 'ftools'

def make_directories File.makedirs "html" File.makedirs "html/images"End

def generate_html system %{./runwpb rake.wpb}end

def build make_directories generate_htmlend

build

Page 15: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

DEMO

Let’s see it in action!

Page 16: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Notifications

Emails

System Tray utilities (CCTray, CCMenu, etc.)

RSS feed

Text Message

Page 17: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Notifications – Lava Lamps

http://agileworks.blogspot.com/2009/02/lava-lamp-with-cruisecontrol.html

Page 18: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Notifications – iPhone app

Yeah – there’s an app for that.

Page 19: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Notifications – Brian the Build Bunny

Brian Woodward: http://www.woodwardweb.com/gadgets/000434.html

Page 20: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Best Practices• Build must be green at the end of the day– Never check in code and leave office

(ninja commit)– Stay and fix the code OR revert the check in

• Check in often– Less chance of merge conflict– Always have the latest code

• Never check in or check out of a broken build

Page 21: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Best Practices – cont’d• Communicate– Be informed. Keep up-to-date with build status– If you broke the build, tell the team– Merge conflict?

Talk to - don’t email - the other team member(s)• Be familiar with the build process– Don’t have to be the ‘build master’ but need to

know how to troubleshoot and fix

Page 22: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Various Build Types• Continuous: Run on every commit (give or take)– Lean & Fast– Very basic validation

• Timed: Hourly, Nightly, etc.– Longer– More in-depth– Deployment

• Utility– Much like scheduled tasks– For ease of use

Page 23: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

But there’s more!• Post-Build– Database upgrade– Code analysis

(coverage, quality metrics, compliance)– Packaging

• Deployment

Page 24: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Continuous Deployment• Shrink the ‘Last Mile’ (QA, UAT, Production)• Reduce risk– Exercise deployment process early

• Software always ready for deployment

Page 25: Leveraging Continuous Integration For Fun And Profit!

New Jersey Autumn 2009

Discussion Time• Viewpoints• Experiences & Tips• Values

http://blog.jesschadwick.comTwitter: [email protected]