Upload
jess-chadwick
View
3.291
Download
2
Tags:
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
New Jersey Autumn 2009
Leveraging Continuous Integration for Fun and Profit!
Jess ChadwickIndependent Consultanthttp://blog.jesschadwick.com
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
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
New Jersey Autumn 2009
Layers of Quality AssuranceCompilation
Unit Testing
Functional/UI Testing
Code Metrics
Deployment
New Jersey Autumn 2009
Continuous Integration in XP
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
New Jersey Autumn 2009
Exponentially Building Value
•SOLID (DI)
•Unit Testing
•Continuous Integration
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
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
New Jersey Autumn 2009
Covert Operation
Can’t get your team to buy in?
Run it on your own box!
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>
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>
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 }
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
New Jersey Autumn 2009
DEMO
Let’s see it in action!
New Jersey Autumn 2009
Notifications
Emails
System Tray utilities (CCTray, CCMenu, etc.)
RSS feed
Text Message
New Jersey Autumn 2009
Notifications – Lava Lamps
http://agileworks.blogspot.com/2009/02/lava-lamp-with-cruisecontrol.html
New Jersey Autumn 2009
Notifications – iPhone app
Yeah – there’s an app for that.
New Jersey Autumn 2009
Notifications – Brian the Build Bunny
Brian Woodward: http://www.woodwardweb.com/gadgets/000434.html
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
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
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
New Jersey Autumn 2009
But there’s more!• Post-Build– Database upgrade– Code analysis
(coverage, quality metrics, compliance)– Packaging
• Deployment
New Jersey Autumn 2009
Continuous Deployment• Shrink the ‘Last Mile’ (QA, UAT, Production)• Reduce risk– Exercise deployment process early
• Software always ready for deployment
New Jersey Autumn 2009
Discussion Time• Viewpoints• Experiences & Tips• Values
http://blog.jesschadwick.comTwitter: [email protected]