Continuous integration

44
If you build it, you’ll ship it Dennis van der Stelt Class-A

description

Session I did at Microsoft Developer Days in 2009

Transcript of Continuous integration

Page 1: Continuous integration

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

Class-A

Page 2: Continuous integration

Agenda

• What/Why about continuous integration

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

Page 3: Continuous integration

what isan automated build

Page 4: Continuous integration

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

Save time and money

Page 5: Continuous integration

What if CTRL+SHIFT+B and XCopy

might seem enough?

Page 6: Continuous integration

What if you don’t have

integration problems?

Page 7: Continuous integration

What if setting up builds

costs time?

Page 8: Continuous integration
Page 9: Continuous integration

Don’t do this onlyonce a day…

do it continuously!

Page 10: Continuous integration

what iscontinuous integration

Page 11: Continuous integration

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

Page 12: Continuous integration

5 steps tocontinuous integration

Page 13: Continuous integration

1sourcecontrol reposito

ry

Page 14: Continuous integration

Source control repository

Team Foundation

ServerSourceSafe ClearCase

CVSSubversion

(SVN)

JEDIversion control

Page 15: Continuous integration

Source control repository

projectbranch

code

unit tests

branch

libraries

Page 16: Continuous integration

2automat

ethe

build

Page 17: Continuous integration

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

Page 18: Continuous integration

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

Page 19: Continuous integration

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

Page 20: Continuous integration

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

Page 21: Continuous integration

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

Page 22: Continuous integration

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

Page 23: Continuous integration

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

Page 24: Continuous integration

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

Page 25: Continuous integration

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

Page 26: Continuous integration

3 the tools

Page 27: Continuous integration

Team Foundation Server

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

Page 28: Continuous integration

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.

Page 29: Continuous integration

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

FinalBuilder ServerContinuous integration server to accompany FinalBuilder.

Page 30: Continuous integration

CruiseControl.NET

Opensource continuous integration server. Multipleplugins available and large userbase.

Page 31: Continuous integration

4development

process

Page 32: Continuous integration

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

Page 33: Continuous integration

Working with changesets

Class A

Class B

Class E

Class D

Class C

A

AB

= Developer A

= Developer B

A

B

AB

B

B

Page 34: Continuous integration

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

Page 35: Continuous integration

5 benefits

Page 36: Continuous integration

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

Page 37: Continuous integration

anti patternsin continuous integration

Page 38: Continuous integration

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

create bottleneck

commits resulting in

going home late

Page 39: Continuous integration

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

Page 40: Continuous integration

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

but don’t overdo it

resulting in ignoring

the notifications

Page 41: Continuous integration

And breaking the build willmake you buy cakefor the team…

… or wear thebunny suit!

Page 42: Continuous integration

Conclusion

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

Page 43: Continuous integration

Next steps…

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

• http://twitter.com/dvdstelt/• [email protected]• Visit Devnology for discussions• Come to SDN Conference!• Try out Team System 2010

Page 44: Continuous integration

Thanks for attendingDennis van der Stelt