SoftwareConstruction ContinuousIntegration

SoftwareConstruction

ContinuousIntegration

MartinKropp UniversityofAppliedSciencesNorthwesternSwitzerland InstituteforMobileandDistributedSystems

LearningTarget

You  canexplaintheimportanceofcontinuous integration(CI)  knowwhatContinuousIntegrationis  canexplainthebeneftisofCI  candescribeatypicalCIenvironment  cansetupanduseaCItool

ContinuousIntegration, v1.2 IMVS,M.Kropp 2

InstituteforMobileandDistributedSystems M.Kropp 1 SoftwareConstruction ContinuousIntegration

Agenda

 WhyIntegration?  WhatisContinuousIntegration?  ContinuousIntegrationProcess  CIInfrastructure  CITools

ContinuousIntegration, v1.2 IMVS,M.Kropp 3

Integration

Integrationis… Makingdifferentmodulesworktogether

 Modularization  enablesteamdevelopment  makescomplexsystemsmanageable  Moduleshavetoworktogether  i.e.theymustbe integrated  IntegratedModulesdosuccessfully  compile  run  passtest  deploy

ContinuousIntegration, v1.2 IMVS,M.Kropp 4

InstituteforMobileandDistributedSystems M.Kropp 2 SoftwareConstruction ContinuousIntegration

IntegrationChallenges

Integrationoccurswhenchanges aremergedwiththesourcecode repository

Module1 Module2 Module3 Module3 Module4

SystemA SystemB

Integrationoccursat interfaces SharedModule

ContinuousIntegration, v1.2 IMVS,M.Kropp 5

BrokenIntegration

 Youhaveabrokenintegrationwhen:  Sourcecodeserverdoesnotbuildsuccessfully  Sharedcomponentworksinonesystem,butbreaks others  Unittestsfail  Codequalityfails(codingconventions,quality metrics)  Deploymentfails

Theearlieryoucandetectproblems,theeasieritisto resolvethem

ContinuousIntegration, v1.2 IMVS,M.Kropp 6

InstituteforMobileandDistributedSystems M.Kropp 3 SoftwareConstruction ContinuousIntegration

ManualIntegration

 Integrationbecomesexpensive  ifmademanual(build,test,deployment,…)  withtoolesscheckin’s(hoursordays…)  Ifintegrationproblemsandbugsaredetectedtoolate

 Reducesdesiretorefactor  Longtimebetweenintegrationincreasesriskof merge  IDEmakesmanycross-cuttingchangeseasy

ContinuousIntegration, v1.2 IMVS,M.Kropp 7

WhatIsContinuousIntegration

 SomeDefinitions

“Animportantpartofanysoftwaredevelopmentprocessisgetting reliablebuilds of thesoftware.Despiteit'simportance,weareoftensurprisedwhenthisisn'tdone. Westressa fullyautomated and reproduciblebuild , includingtesting ,that runs manytimesaday .Thisallowseachdevelopertointegratedailythusreducing integrationproblems.” MartinFowlerandMatthewFoemmel,ContinuousIntegration

“Themacroprocessofobject-orienteddevelopmentisoneof"."... Atregularintervals,theprocessof"continuousintegration" yieldsexecutablereleasesthatgrowinfunctionalityateveryrelease ....Itis throughthesemilestonesthatmanagementcanmeasureprogressandquality,and henceanticipate,identify,andthenactivelyattachrisksonanongoingbasis.” GradyBooch,Object-OrientedAnalysisandDesignwithApplications

ContinuousIntegration, v1.2 IMVS,M.Kropp 8

InstituteforMobileandDistributedSystems M.Kropp 4 SoftwareConstruction ContinuousIntegration

PracticesofContinuousIntegration

 MaintainaSingleSourceRepository.  AutomatetheBuild  MakeYourBuildSelf-Testing  EveryoneCommitsEveryDay  EveryCommitShouldBuildtheMainlineonanIntegrationMachine  KeeptheBuildFast  TestinaCloneoftheProductionEnvironment  MakeitEasyforAnyonetoGettheLatestExecutable  Everyonecanseewhat'shappening  AutomateDeployment Fromhttp://martinfowler.com/articles/continuousIntegration.html

ContinuousIntegration, v1.2 IMVS,M.Kropp 9

EmbraceContinuousIntegration

 WhatisContinuousIntegration

Getlatest Build RunTest SendReport version

VCS  Integrationservermonitorssourcerepository  Rebuildswitheverychange  Runsallunitandacceptancetests  Publishesbuildresults  Notifiesdevelopersifbuildbreaks  Labelssuccessfulbuildsinsourcerepository

ContinuousIntegration, v1.2 IMVS,M.Kropp 10

InstituteforMobileandDistributedSystems M.Kropp 5 SoftwareConstruction ContinuousIntegration

ContinuousIntegrationPrerequisites

 Toolsneeded  VCSserver  Buildserver  DeploymentServer  Automationtools  CItools

 WorkProcess  Commit/Updateoften(eachchange)  Runoften  Writetest  Runtestoften  Commoncodeownership

ContinuousIntegration, v1.2 IMVS,M.Kropp 11

ContinuousIntegrationInfrastructure

Monitorsprojects/paths insourcerepository

buildserver vcsserver Development DeploymentServer

BuildScript

-Getlatestversion Executestaskson - Build schedule/event - CodeAudit -UnitTest -CodeCoverage buildreport -Deploy

Getlocalcopies/ developers Commitchanges

ContinuousIntegration, v1.2 IMVS,M.Kropp 12

InstituteforMobileandDistributedSystems M.Kropp 6 SoftwareConstruction ContinuousIntegration

RealizingContinuousIntegration

 MonitorsaVCSrepositoryforchanges  CVS=checkforcommitsintherepositorysincelastbuildtime  Ifchangesarefound,thenonaschedulestartthebuild  Buildyourapplication  throughyourexistingAntorMavenscripts  RunyourxUnitTestsuite  Runcodeaudittools  Checkstyle,codecoverage,…  Reportonthebuildresults  sendformattedemailnotifications  publishresultstoawebsite  (Optionally)publishtheapplication  ConfigurationisthroughacentralXMLfile

ContinuousIntegration, v1.2 IMVS,M.Kropp 13

WhatisaSuccessfulBuild?

 Whenisyourbuildsuccessful?  Whenitcompiles?  Whenalltheunit-testshaverun?  Whenithasbeendeployed?

 Infact,everyfailureisasuccess  Youhaveexposedapotentialproblem– early !

ContinuousIntegration, v1.2 IMVS,M.Kropp 14

InstituteforMobileandDistributedSystems M.Kropp 7 SoftwareConstruction ContinuousIntegration

TheAgileProcess

 ContinuousIntegrationisonlyoneaspectofanoverall process.Forittoworkbest,youneedto:

 Planiteratively  scheduleregularreleaseswithevolvinglevelsoffunctionality (CRs)  bewaryofinflexibleChangeControlBoards!  Implementincrementally  identifyandimplementsmallworktasks  refactorifnecessary!  Reportproactively  identifyexactlythecontents(CIs)ofanybuild,inbothfileand content  automatereports!

ContinuousIntegration, v1.2 IMVS,M.Kropp 15

CIBenefits

ReducedRisks

 Alwaysawareofcurrentstatusoftheproject  Lesstimespentinvestigatingintegrationbugs  Integrationtestingperformedearly  Integrationbugscaughtearly  Lesstimewastedbecauseofbrokencodeinversioncontrolsystem  Brokenbuildscaughtearly  Proveyoursystemcanbuild!  Increasecodequalitywithadditionaltasks  Discoverpotentialdeploymentissues

ContinuousIntegration, v1.2 IMVS,M.Kropp 16

InstituteforMobileandDistributedSystems M.Kropp 8 SoftwareConstruction ContinuousIntegration

CIObstacles

 ToughtomoveanexistingsystemintoCI  Systemsthatrelyon“server”components (BizTalk,Sharepoint,etc.)  Db-basedsystemsneedtobeup-to-dated

ContinuousIntegration, v1.2 IMVS,M.Kropp 17

ACITool:CruiseControl

ContinuousIntegration, v1.2 IMVS,M.Kropp 18

InstituteforMobileandDistributedSystems M.Kropp 9 SoftwareConstruction ContinuousIntegration

Monitoring

 CruiseControl  ContinuousIntegrationServer  Integratesbuilding,unittests,codecoverage, analysis,….  Providestheabilitytohookinalmostanyoutput.  Givesinstantknowledgeofstatusofbuilds.  Providesdashboardlikeintegrationformultiple projects

ContinuousIntegration, v1.2 IMVS,M.Kropp 19

CruiseControlBuildStatus

ContinuousIntegration, v1.2 IMVS,M.Kropp 20

InstituteforMobileandDistributedSystems M.Kropp 10 SoftwareConstruction ContinuousIntegration

CruiseControlComponents

 CIServer  Monitorsthecvs  Executesthebuildscript  ConfigurationFile  Dashboard  Buildreportviewer  EmailNotification

ContinuousIntegration, v1.2 IMVS,M.Kropp 21

CIAddOns

 CodeCoverageCobertura  WorkswithJUnitoranyclasses  UsesinstrumentationwithinAntorthecommand line  Integratedintobuildprocessviatask  DependencyManagementwithIVY  SimilarlikeMaven  Antbased

ContinuousIntegration, v1.2 IMVS,M.Kropp 22

InstituteforMobileandDistributedSystems M.Kropp 11 SoftwareConstruction ContinuousIntegration

SomePopularCITools

 CruiseControl(OS)  http://cruisecontrol.sourceforge.net/  AnthillPro(Com)  http://www.anthillpro.com/  Continuum(OS)  http://maven.apache.org/continuum/  Pulse(Com)  http://www.zutubi.com/  Luntbuild(OS)  http://luntbuild.javaforge.com/  ParaBuildServer(Com)  http://www.viewtier.com/index.htm

ContinuousIntegration, v1.2 IMVS,M.Kropp 23

Resources

 MartinFowleraboutCI http://www.martinfowler.com/articles/continuousIntegration.html  Wiki http://c2.com/cgi/wiki?ContinuousIntegration

ContinuousIntegration, v1.2 IMVS,M.Kropp 24

InstituteforMobileandDistributedSystems M.Kropp 12 SoftwareConstruction ContinuousIntegration

Summary

 Continuallyintegrateandtesttoreducerisk

 Detectproblemsearly

 Alwayshaveadeployablebuild

 Generatemetricstoguideprojectmanagement

 ContinuousIntegrationis:  Agoodpracticeinanysoftwaredevelopmentmethod  Vitalforagiledevelopment

ContinuousIntegration, v1.2 IMVS,M.Kropp 25

InstituteforMobileandDistributedSystems M.Kropp 13