continuous integration using cruise control

29
© 2005 PlatinumSolutions, Inc. 2005 PlatinumSolutions, Inc. The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and Government Independent, Open Solutions for Business and Government Continuous Integration Continuous Integration using Cruise Control using Cruise Control Presented By Presented By Tom Grant Tom Grant PlatinumSolutions, Inc. PlatinumSolutions, Inc. Thursday, April 14 Thursday, April 14 th th , 2005 , 2005

Upload: elliando-dias

Post on 03-Jul-2015

2.058 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Continuous Integration Continuous Integration using Cruise Controlusing Cruise Control

Presented ByPresented By

Tom GrantTom Grant

PlatinumSolutions, Inc.PlatinumSolutions, Inc.

Thursday, April 14Thursday, April 14thth, 2005, 2005

Page 2: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

What is Integration?What is Integration?

Definition: “the act of combining into an integral whole”Definition: “the act of combining into an integral whole”

In software development, integration includes…In software development, integration includes…

Combining source filesCombining source files

Combining software and environmentCombining software and environment

Combining software and dataCombining software and data

Combining software and requirements (tests)Combining software and requirements (tests)

Combining developersCombining developers

Page 3: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Integration Testing in the SDLCIntegration Testing in the SDLC

Combine the application’s components into Combine the application’s components into working software. working software.

Historically done near the end of the project.Historically done near the end of the project.

Very risky! Software modules don’t always work Very risky! Software modules don’t always work together as expectedtogether as expected

Best case: Time to fix, time to retest that moduleBest case: Time to fix, time to retest that module

Worst case: Time to determine why, time to redesign, time to Worst case: Time to determine why, time to redesign, time to fix, time to test all of the modules affected by the redesign.fix, time to test all of the modules affected by the redesign.

Page 4: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Nightly BuildsNightly Builds

Practice became popular in the late 90s Practice became popular in the late 90s after Microsoft published its development after Microsoft published its development practicespractices

Integrate all of the software on a nightly Integrate all of the software on a nightly basis. basis.

Smoke Test – run the application and Smoke Test – run the application and conduct a minimal set of tests to see if it conduct a minimal set of tests to see if it “catches fire”. “catches fire”.

Page 5: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Take it to the ExtremeTake it to the Extreme

Extreme Programming says…Extreme Programming says…if testing is good, test all the timeif testing is good, test all the time

if integration testing is important, integrate and test if integration testing is important, integrate and test all the timeall the time

if short iterations are good, make the iterations if short iterations are good, make the iterations really, really short (minutes and hours, not weeks really, really short (minutes and hours, not weeks and months)and months)

Continuous Integration is born.Continuous Integration is born.

Page 6: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

What is Continuous Integration?What is Continuous Integration?

Integrates source code and runs tests Integrates source code and runs tests after each commit of code to the source after each commit of code to the source repository.repository.

Near-immediate feedback to the developer Near-immediate feedback to the developer from the authoritative source, the system from the authoritative source, the system itself.itself.

Page 7: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Nightly vs. Continuous BuildsNightly vs. Continuous Builds

Nightly builds generate deliverables. They result in something tangible: something for Nightly builds generate deliverables. They result in something tangible: something for QA to test, something for product managers to review, and something to reassure QA to test, something for product managers to review, and something to reassure team members that they are in fact building a product. Because of the external team members that they are in fact building a product. Because of the external audience, the nightly build is a formal event, a mini-milestone that your team should audience, the nightly build is a formal event, a mini-milestone that your team should hit without fail. Breaking the nightly build is something that generates blame and often hit without fail. Breaking the nightly build is something that generates blame and often consequences, such as becoming the build mother or being awarded a dunce cap.consequences, such as becoming the build mother or being awarded a dunce cap.

Continuous Integration builds don’t need durable build products to be beneficial. They Continuous Integration builds don’t need durable build products to be beneficial. They are a way for a developer to have a conversation with the system to gain reassurance are a way for a developer to have a conversation with the system to gain reassurance that they have done their part. that they have done their part.

Source: Source: http://www.stickyminds.com/BetterSoftware/magazine.asp?fn=cifea&id=58http://www.stickyminds.com/BetterSoftware/magazine.asp?fn=cifea&id=58

Use Use bothboth..

Page 8: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Benefits of Continuous Benefits of Continuous IntegrationIntegration

It minimizes integration risk.It minimizes integration risk.

Easier defect diagnosis.Easier defect diagnosis.

It saves time creating releases.It saves time creating releases.

Encourages good testing habitsEncourages good testing habits

It enables other good development It enables other good development practices…practices…

Page 9: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

C.I. Enables other PracticesC.I. Enables other Practices

Test Driven DevelopmentTest Driven DevelopmentFewer bugs, less time debuggingFewer bugs, less time debuggingConfidence to refactorConfidence to refactorExecutable DocumentationExecutable DocumentationValidation that you are completeValidation that you are complete

Release ManagementRelease ManagementBuilds are centralizedBuilds are centralizedBuilds are repeatable/re-creatableBuilds are repeatable/re-creatableModifications are clearly mapped to releasesModifications are clearly mapped to releasesIssues are clearly mapped to releases and thus to modificationsIssues are clearly mapped to releases and thus to modificationsReleases are only created with committed codeReleases are only created with committed codeDigitally signed codeDigitally signed code

Enforcement of Company Development PolicyEnforcement of Company Development PolicyAutomate policy tests with CheckstyleAutomate policy tests with CheckstyleLess need for manual code reviewsLess need for manual code reviews

Page 10: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Continuous Integration ToolkitsContinuous Integration ToolkitsCruise ControlCruise Control

http://cruisecontrol.sourceforge.nethttp://cruisecontrol.sourceforge.net

Damage ControlDamage Control

http://damagecontrol.codehaus.org/http://damagecontrol.codehaus.org/

AnthillAnthill

http://www.urbancode.com/projects/anthill/default.jsphttp://www.urbancode.com/projects/anthill/default.jsp

GumpGump

http://jakarta.apache.org/gump/http://jakarta.apache.org/gump/

Feature Comparison MatrixFeature Comparison Matrix

http://docs.codehaus.org/display/DAMAGECONTROL/Continuous+Integration+Server+Feature+Matrixhttp://docs.codehaus.org/display/DAMAGECONTROL/Continuous+Integration+Server+Feature+Matrix

Page 11: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Cruise ControlCruise Control

Think of it as “Cron for Ant”.Think of it as “Cron for Ant”.

Simple design. Full featured, but not Simple design. Full featured, but not bloated.bloated.

Adapts to your project, not the other way Adapts to your project, not the other way around.around.

Can be completely customized.Can be completely customized.

Page 12: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Cruise Control’s Build LoopCruise Control’s Build Loop

Executes every “n” seconds or Executes every “n” seconds or schedulable at particular times.schedulable at particular times.

The process:The process:Bootstrap (setup)Bootstrap (setup)

Check for modificationsCheck for modifications

Run buildRun build

Publish resultsPublish results

Page 13: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

The Build LoopThe Build Loop

CVS

Build Artifacts Dir(Samba Share)

SMTP Server

1. Bootstrap

2. Check for modifications

3. Get the revision log

Cruise Control

Your project’s Build file

Ant, Maven, Make2. Run Build

5. Publish Artifacts

6. Send Emails1. Get the latest

source3. Tag source

Cruise Control to project adapter.

(build-project.xml) Ant script

4. Run Build

Page 14: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

SchedulingScheduling

You can schedule continuous buildsYou can schedule continuous buildsYou can schedule builds at particular times You can schedule builds at particular times (nightly builds)(nightly builds)You can schedule builds at particular intervals You can schedule builds at particular intervals (hourly, weekly)(hourly, weekly)You can omit certain times or days (no builds on You can omit certain times or days (no builds on Sunday)Sunday)You can run different targets for each iteration. You can run different targets for each iteration. (do a complete test every 3(do a complete test every 3rdrd run) run)

Page 15: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

BootstrapBootstrap

Gives the developer a chance to run Gives the developer a chance to run something before a build.something before a build.

Always runs, regardless of the existence Always runs, regardless of the existence of modificationsof modifications

Usually emptyUsually empty

Page 16: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Check for ModificationsCheck for Modifications

Checks for the existence of modifications, and retrieves the list of those Checks for the existence of modifications, and retrieves the list of those modifications.modifications.

Version Control SystemsVersion Control Systems cvs, pvcs, clearcase, visual source safe, subversion, …cvs, pvcs, clearcase, visual source safe, subversion, …

Local filesLocal filesHttp filesHttp filesAlways or “Force only”Always or “Force only”Combinations of multiple typesCombinations of multiple typesCustomCustom

Quiet Period –Makes sure that the repository is “quiet” for Quiet Period –Makes sure that the repository is “quiet” for n n seconds to seconds to prevent builds from kicking off in the middle of a multi step code prevent builds from kicking off in the middle of a multi step code commit. commit.

Page 17: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Run The BuildRun The Build

Only runs if modifications were detected.Only runs if modifications were detected.

It can run an ant script, maven or any It can run an ant script, maven or any other system executable such as make.other system executable such as make.

Cruise Control’s approach is that it will run Cruise Control’s approach is that it will run youryour application’s build file.application’s build file. Your build Your build file should know how to do everything to file should know how to do everything to build your project.build your project.

Page 18: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Publish ResultsPublish Results

Only runs if modifications were detected. Most publishers can be Only runs if modifications were detected. Most publishers can be disabled on a failure.disabled on a failure.

Build artifactsBuild artifacts Copies files to a labeled release directoryCopies files to a labeled release directory SCP, FTPSCP, FTP

EmailEmailReports generated via XSL transformsReports generated via XSL transforms XSL transforms exist for HTML, EmailXSL transforms exist for HTML, Email You can add your ownYou can add your own

Execute scripts or applicationsExecute scripts or applicationsX10X10 Sirens, lamps. Notification using your other senses.Sirens, lamps. Notification using your other senses.

Page 19: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

DemonstrationsDemonstrations

Mike Clark (Pragmatic Project Automation)Mike Clark (Pragmatic Project Automation)http://media.pragprog.com/movies/auto/CruiseControl_MikeClark.htmlhttp://media.pragprog.com/movies/auto/CruiseControl_MikeClark.html

PS ProjectPS Project

Page 20: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

PS Project with CruisePS Project with Cruise

Checkout the code with cvs.exeCheckout the code with cvs.exe

build-crs.xml – The project specific build-crs.xml – The project specific adapter between Cruise Control and the adapter between Cruise Control and the CRS build file. CRS build file.

config.xml – The Cruise Control config.xml – The Cruise Control configuration file.configuration file.

Page 21: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Cruise Control SetupCruise Control Setup

• Install required softwareInstall required software• Java SDKJava SDK• AntAnt• TomcatTomcat• cvs.exe for cvs accesscvs.exe for cvs access

• Download the Cruise Control softwareDownload the Cruise Control software• Install the Cruise Control softwareInstall the Cruise Control software• Install the reporting WAR fileInstall the reporting WAR file

Page 22: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Cruise Control SoftwareCruise Control Software

Getting Started How-toGetting Started How-tohttp://cruisecontrol.sourceforge.net/gettingstarted.htmlhttp://cruisecontrol.sourceforge.net/gettingstarted.html

Pragmatic Project AutomationPragmatic Project Automationhttp://www.pragmaticprogrammer.com/starter_kit/au/scheduled.pdfhttp://www.pragmaticprogrammer.com/starter_kit/au/scheduled.pdf

Installation Directory - C:\Program Files\CruiseControl\Installation Directory - C:\Program Files\CruiseControl\bin\cruisecontrol.batbin\cruisecontrol.bat

Build Directory - C:\builds\Build Directory - C:\builds\artifacts\ - files to be deliveredartifacts\ - files to be deliveredcheckout\ - the source to buildcheckout\ - the source to buildlogs\ - the details about each buildlogs\ - the details about each buildconfig.xml – the config file for Cruise Controlconfig.xml – the config file for Cruise Control

Page 23: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Installation TipsInstallation Tips

Remember to do a “cvs login” before your “cvs checkout”. Use the Remember to do a “cvs login” before your “cvs checkout”. Use the command line cvs.exe.command line cvs.exe.Run your project’s ant script from the command line to test it, not Run your project’s ant script from the command line to test it, not through your IDE.through your IDE.Use a small Ant build script to wrap your project’s actual build script.Use a small Ant build script to wrap your project’s actual build script.Share the artifacts directory.Share the artifacts directory.Run Cruise Control from the command line before you set it up as a Run Cruise Control from the command line before you set it up as a service.service.Remember to change the user that the Windows service runs under Remember to change the user that the Windows service runs under to be the same user that executed the “cvs login”.to be the same user that executed the “cvs login”.Plan for having multiple projects.Plan for having multiple projects.Cruise Control does not make any assumptions about directory Cruise Control does not make any assumptions about directory structure, but the reporting application does.structure, but the reporting application does.

Page 24: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Reporting Web-applicationReporting Web-application

Deploy it to any servlet container on the Deploy it to any servlet container on the same machine.same machine.

Modify two parameters in the web.xml file.Modify two parameters in the web.xml file.<context-param> <param-name>logDir</param-name> <param-value>c:\builds\logs</param-value></context-param>

<servlet> <servlet-name>ArtifactServlet</servlet-name> <servlet-class>net.sourceforge.cruisecontrol.servlet.FileServlet</servlet-class> <init-param> <param-name>rootDir</param-name> <param-value>c:\builds\artifacts\</param-value> </init-param></servlet>

Page 25: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Cruise Control does…Cruise Control does…

It runs your build script whenever you It runs your build script whenever you commit a change to your source commit a change to your source repository.repository.

It allows you to schedule nightly builds.It allows you to schedule nightly builds.

It allows you to run on-demand builds.It allows you to run on-demand builds.

It notifies you of the results of those builds.It notifies you of the results of those builds.

It simplifies release management.It simplifies release management.

Page 26: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

Cruise Control does not…Cruise Control does not…

It does not write your build script for you.It does not write your build script for you.

It does not write your unit tests for you.It does not write your unit tests for you.

It does not automatically resolve project It does not automatically resolve project dependencies.dependencies.

Page 27: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

What does it cost?What does it cost?

Free, Open Source SoftwareFree, Open Source Software One time costsOne time costs

$500 for a dedicated build machine $500 for a dedicated build machine 4 hours configuration time for a first-timer, 2 hours 4 hours configuration time for a first-timer, 2 hours for an experienced Cruise Control user.for an experienced Cruise Control user.

Recurring costsRecurring costs20 minutes to set up a new project20 minutes to set up a new projectElectricityElectricityDisk spaceDisk space

Page 28: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

The Bottom LineThe Bottom Line

It takes practically nothing to set it up. It takes practically nothing to set it up. At a minimum, use it for nightly builds. At a minimum, use it for nightly builds. As the number of developers increases, it As the number of developers increases, it becomes more valuable.becomes more valuable.As the number of releases increases, it As the number of releases increases, it becomes more valuable.becomes more valuable.As the number of unit tests increases, it As the number of unit tests increases, it becomes more valuable.becomes more valuable.

Page 29: Continuous Integration using Cruise Control

©©2005 PlatinumSolutions, Inc.2005 PlatinumSolutions, Inc.The Freedom to Achieve – The Freedom to Achieve – Independent, Open Solutions for Business and GovernmentIndependent, Open Solutions for Business and Government

LinksLinksArticle by Jeffrey Fredrick on Continuous Integration using Cruise ControlArticle by Jeffrey Fredrick on Continuous Integration using Cruise Control

http://www.stickyminds.com/BetterSoftware/magazine.asp?fn=cifea&id=58http://www.stickyminds.com/BetterSoftware/magazine.asp?fn=cifea&id=58

Continuous Integration Toolkit comparison MatrixContinuous Integration Toolkit comparison Matrix

http://docs.codehaus.org/display/DAMAGECONTROL/Continuous+Integration+Server+Feature+Matrixhttp://docs.codehaus.org/display/DAMAGECONTROL/Continuous+Integration+Server+Feature+Matrix

Cruise Control WebsiteCruise Control Website

http://cruisecontrol.sourceforge.nethttp://cruisecontrol.sourceforge.net

Ant WebsiteAnt Website

http://ant.apache.orghttp://ant.apache.org

Pragmatic Project Automation by Mike ClarkPragmatic Project Automation by Mike Clark

http://www.pragmaticprogrammer.com/sk/auto/http://www.pragmaticprogrammer.com/sk/auto/