Continuous integration

Post on 13-May-2015

339 views 3 download

Tags:

description

Session I did at Microsoft Developer Days in 2009

Transcript of Continuous integration

If you build it, you’ll ship itDennis van der Stelt

Class-A

Agenda

• What/Why about continuous integration

• How to automate the build• Tools• Development process• Anti patterns

what isan automated build

Is more than CTRL+SHIFT+B or F5Solves integration problems earlyEliminate repetitive tasksMinimize “bad builds”Improve product quality

Save time and money

What if CTRL+SHIFT+B and XCopy

might seem enough?

What if you don’t have

integration problems?

What if setting up builds

costs time?

Don’t do this onlyonce a day…

do it continuously!

what iscontinuous integration

Continuous integration describes a set of software engineering practices that speed up the delivery of software by decreasing integration times.

5 steps tocontinuous integration

1sourcecontrol reposito

ry

Source control repository

Team Foundation

ServerSourceSafe ClearCase

CVSSubversion

(SVN)

JEDIversion control

Source control repository

projectbranch

code

unit tests

branch

libraries

2automat

ethe

build

1 2 3 4 5 6 7 8

Clean up previous builds

• Decide whether you build from scratch• prevents unexpected behavior• rebuilds everything, every time• will make the build take longer to

complete

1 2 3 4 5 6 7 8

Get latest version

• Include everything• Source code• Libraries• Database schema

• Build needs to be able to run on clean machine

1 2 3 4 5 6 7 8

Increase version number

• Include version number in assemblies• Decide whether you

• Increase all assemblies• Increase only updated assemblies

1 2 3 4 5 6 7 8

Build & deploy database

• Create a new & fresh database• Visual Studio DataDude• Comes free now with developer edition

• Deploy test data for integration tests• Usually takes a long time

• Option to do this only in nightly build

• Creating a large change script is a different story

1 2 3 4 5 6 7 8

Build the project

• Don’t build using an IDE like Visual Studio• Rather use MSBuild, TeamBuild or a 3rd party lib.

• Don’t forget to automate• Help files & documentation• Installation files (setup.exe)• Release notes

1 2 3 4 5 6 7 8

Run tests

• Compiling code doesn’t prove it works• Unit tests do

• Although they’re no 100% safety net• Run unittests continuously

• Integration tests only at night• Try web tests and new Visual Studio 2010 abilities

1 2 3 4 5 6 7 8

Create deployment packages

• Create at least two deployment packages• Make the build available to everyone

• Deploy websites to test server• Deploy ClickOnce applications to test

server• Make iteration/milestone versions

available• Try to make automated rollback available

1 2 3 4 5 6 7 8

Don’t leave the build broken overnight

• Make sure you’re developing on a stable base• Builds can break, but…

• not too often• not during the night

1 2 3 4 5 6 7 8

Nightly build

• Not everything has to run continuously• Database deployment• Slower integration tests

• Must be able to run full build manually

1a

1b

5a

5b

5c

3 the tools

Team Foundation Server

Has everything you need• Source control• Data collection• Reporting• Project tracking• For collaborative development• Supports CI since version 2008

MSBuild

Complex XML script based on targets and tasks.Requires additional open source tasks for completeness.

TeamBuild

This is where Team Foundation Server runs on. It’s MSBuild with TFS integration.

FinalBuilderUnified graphical interface to author and execute builds with 650+ actions to execute. Integration with TFS

FinalBuilder ServerContinuous integration server to accompany FinalBuilder.

CruiseControl.NET

Opensource continuous integration server. Multipleplugins available and large userbase.

4development

process

Development process

1. Get latest version of integrated code

2. Add or change a feature3. Build code & run tests locally4. Get latest version & merge5. Build code & run tests locally6. Check-in source code7. Verify automated build succeeds8. Goto 1

Working with changesets

Class A

Class B

Class E

Class D

Class C

A

AB

= Developer A

= Developer B

A

B

AB

B

B

Some best practices

• Setup a build a.s.a.p!• Check-in as often as you can• Use a RAM disk to speed up the build• Use a Continuous Integration Token

5 benefits

Benefits of CI

• Reduced risk• Confidence in frequent deployments

– New features more rapidly– Better feedback on those features

• Better customer relations• Improved team morale

Save time and money

anti patternsin continuous integration

It’s an anti pattern to delay check-ins and

create bottleneck

commits resulting in

going home late

Or from a different view,having files checked out overnight meansproviding theteam withcoffee or cookies

It’s an anti pattern tonot to use feedback of a broken build,

but don’t overdo it

resulting in ignoring

the notifications

And breaking the build willmake you buy cakefor the team…

… or wear thebunny suit!

Conclusion

• Automate your build• Continuous Integration is the key!• Use the best tools available• It will save you time and money

Next steps…

• http://bloggingabout.net/blogs/dennis/

• http://twitter.com/dvdstelt/• dennis@class-a.nl• Visit Devnology for discussions• Come to SDN Conference!• Try out Team System 2010

Thanks for attendingDennis van der Stelt