Tải bản đầy đủ - 0 (trang)
Chapter 5. Setting Up a Continuous Integration Server with Continuum

Chapter 5. Setting Up a Continuous Integration Server with Continuum

Tải bản đầy đủ - 0trang

pointintime,theteamleaderdecides(orreminds

everyone)thatadeliveryisdueinacoupleofweeks.It

maybejustanalphaoraprototype,butitisadelivery

nevertheless.Soit'sallhandsondecktogetsomething

workingfortheduedeadline.Theproblemis,whenIcheck

outmycode,itdoesn'tcompileanymore!Ofcourse,I

knowthatmycodeisOK,soit'sprobablysomeother

developer'sfault—maybetheyforgottocommitaclass,or

changedoneofmyinterfaceswithoutaskingmy

permission…oh,yeah,andsomeoftheunittestsnolonger

work,buttheybelongtotheDBteamdownthecorridor,so

Iwon'tworryaboutthemtoomuch…andsoon.

ThiswidelyobservedphenomenonisknowninAgilecircles

andelsewhereas"IntegrationHell."

ContinousIntegrationistheantidotetoIntegrationHell.It

offersapowerfulwaytodetectbugsandconflictsearlyso

thattheycanbefixedquicklyandeasilyandwithouttoo

muchbloodshedamongteammembers.Itbasically

involvesautomaticallybuildingandtestingcodeatregular

intervals.Teammemberscommittheircodetoversion

controlveryfrequently(atleastonadailybasis).Acentral

serverregularlychecksoutthelatestversionoftheproject

sourcecode,andrunsacompletebuild,including

compilationandtests.Thebuildprocessautomatically

notifiesteammembersofanybuildfailures,and(hopefully)

theteammemberresponsibleforcommitingfaultyor

conflictingcodewillimmediatelyjumpoutofhischair

(figurativelyspeaking)andrushofftofixtheproblem

beforeanyoneelsenotices!

Thispracticeisfirstandforemostarisk-reductionstrategy,

ensuringthattheapplicationintegratescorrectlyatall

timesandreducingtheriskofintegrationissuesappearing

lateintheproject.Additionalbenefitsincludeimproving

communicationbetweenteammembersandreducingthe

timeneededtopreparearelease.Indeed,inaprojectusing



ContinuousIntegration,youvirtuallyalwayshavea

demonstratable,ifnotdeliverable,versionoftheapplication

runningsomewhere.

However,ContinuousIntegrationgoesmuchfurtherthan

simplyensuringthatyourapplicationbuildscorrectlyatall

times.ContinuousIntegrationmeansthatyoualways(well,

almostalways)haveaworkingversionofyourapplication

toshowtotesters,users,andprojectsponsors.Don't

underestimatethebenefitsthatthiscanhaveonyour

project.Thismeansthat,atanypoint,youcandemonstrate

aparticularfeature,andgetfast,earlyfeedbackfrom

testersandendusers.Usersandsponsorsgetbetter

visibilityontheapplication'sfeaturesandontheproject's

realprogress,andpotentialissuesareraised(andfixed)

soonerratherthanlater.

Now,inpractice,aContinuousIntegrationprocesscanbe

automatedtovaryingdegrees.Someteamsusealargely

manualprocess;oncedevelopershavecompletedatask,

theyrunanintegrationbuildusinganautomatedbuildona

separateintegrationbuildmachine.Otherteamsusea

ContinuousIntegrationtoolsuchasCruiseControlto

automatetheprocess.

ThemostfundamentalfeatureofanyContinuous

Integrationtoolistheautomaticbuildcycle.TheContinuous

Integrationtool,eitheratascheduledpointintimeor

wheneveranychangesaredetectedinthesourcecode

repository,fetchesthesourcecode'slatestversionand

attemptstobuildandtesttheproject.Ifthebuildfails,

developerscanbenotifiedinanynumberofways:e-mail,

instantmessaging,telepathy,courierpigeon,orthrough

someother,moreexotic,notificationtechnique.

TherearemanyContinuousIntegrationtools,bothopen

sourceandcommercial,onthemarket,anddecidingwhich

onewouldbestsuityourparticularenvironmentcanprove

difficult.SomeContinuousIntegrationtoolsalsoboast



additionalSDLCfeatures,suchasreleasemanagementand

buildartifactmanagement,whereasothersconcentrateon

coreContinuousIntegrationfunctionalities.Sometryto

provideawiderangeofnotificationmethodsandsupport

virtuallyeveryversioncontrolsystemunderthesun,

whereasothersconcentrateondeliveringasmall,light,

easy-to-understandproduct.

Inthispart,wewilllookatfourofthemoreinteresting

opensourceContinousIntegrationtools:Continuum,

CruiseControl,LuntBuild,andHudson.

Continuumisasimple,lightweight,web-basedContinuous

Integrationtool.Itiseasytoinstallandinvolveslittleinitial

configuration.Onthedownside,itisnotasfeature-richas

someoftheothertools,andtheuserinterfaceisalittle

clunky.

CruiseControlisamatureandrobustJavaContinuous

Integrationtoolthatenjoysastronguserbaseandasolid

industryreputation.Itsupportsvirtuallyanytypeof

project,beitAnt,Maven,Maven2,make,orjustaplainoldcommandlinescript,aswellasawiderangeofSCM

(sourceconfigurationmanagement)tools.Itsnotification

techniquesaresecondtonone,anditcanintegrateeasily

withanythingfromamailservertoaLavaLamp.Italso

benefitsfromalargenumberofthird-partyplug-ins.Onthe

downside,itismuchhardertosetup,toconfigure,andto

maintainthananyoftheothertools,andtheuserinterface

issomewhatunappealing.

LuntbuildisanotheropensourceContinuousIntegration

toolwritteninJava.Itisfairlyeasytoinstallandconfigure,

and,likeContinuum,allserveradministrationtasksare

doneviaa(somewhatclunky)web-basedadministration

console.Luntbuildisdesignedtodomorethanjustmanage

thecontinuousintegrationprocess:italsoletsyoustore

andmanagegeneratedartifacts,labelandpromote

versions,andmanagedependenciesbetweenbuilds.It



supportsawiderangeofversioncontroltools,and

notificationscanbediffusedviae-mail,IM,andevenona

blogsite.

Thelastproductonourlist,Hudson,isarelativenewcomer

totheContinuousIntegrationfield,butitisonethatis

rapidlygainingasubstantialfollowingoverthelastyearor

so.Hudsonisentirelyweb-basedandhasapleasantand

veryfunctionaluserinterface.HudsonsupportsfewerSCM

productsthantheothertoolswehaveseen,concentrating

exclusivelyonSubversionandCVS-basedprojects.By

contrast,itcomeswithmanyusefuladvancedfeaturesnot

seenonsomeoftheothertools,suchasparallelbuilds,

inter-projectdependencies,graphicalbuildstatistics,and

thestorageofbuildartifacts.Hudsonalsobenefitsfroma

largeandincreasinglibraryofplug-ins,allowingintegration

withawidevarietyofothertools,includingstaticanalysis

datafromCheckstyle,PMDandFindBugs,testcoverage

statisticsusingCoberturaorEmma,andissuemanagement

systemssuchasJIRAandTrac.Todate,Hudsonisprobably

oneofthemostinnovativeoftheopensourceContinuous

Integrationtools.

Finally,althoughitisnotinthescopeofthisbooktodiscuss

commercialproductsinanydetail,somearewortha

mention.Overthepastfewyears,anumberofhigh-quality

commercialContinuousIntegrationtoolshaveemerged,

suchasTeamCity(fromJetBrains),Bamboo(from

Atlassian),andPulse(fromZutubi).These"nextgeneration"ContinuousIntegrationtoolsproposeslickuser

interfaces,integrationwithlotsofotherproducts,and

interestingnewfeaturessuchastheabilitytobuildandtest

anapplicationbeforeitiscommittedtothesourcecode

repository.Thisstrategypreemptivelypreventsbroken

buildsbeingeverplacedinthesourcecoderepository.

Foranyreadersinterestedinlearningmoreabout

ContinuousIntegrationasaprocess,Iwouldrecommend



theexcellentbookContinuousIntegration(AddisonWesley),byPaulDuvall,SteveMatyas,andAndrewGlover.

Finally,inthissectionwewillalsolookatOpenfire,anopen

sourceJavainstantmessagingtoolthatcanbeauseful

additiontoyourContinousIntegrationinfrastructure.



Chapter5.SettingUpaContinuous

IntegrationServerwithContinuum

AnIntroductiontoContinuum

InstallingaContinuumServer

ManuallyStartingandStoppingtheServer

CheckingtheStatusoftheServer

RunningtheContinuumServerinVerboseMode

AddingaProjectGroup

AddingaMavenProject

AddinganAntProject

AddingaShellProject

ManagingYourProjectBuilds

ManagingUsers

SettingUpNotifiers

ConfiguringandSchedulingBuilds

DebuggingYourBuilds

ConfiguringtheContinuumMailServer

ConfiguringtheContinuumWebSitePorts

AutomaticallyGeneratingaMavenSitewithContinuum

ConfiguringaManualBuildTask

Conclusion



5.1.AnIntroductiontoContinuum

Inthischapter,welookatContinuum



(http://maven.apache.org/continuum/).Continuum[35]isa

flexible,easy-to-usetoolthatcanhelpyouputContinuous

Integrationintoaction.Itisfast,lightweight,andundemanding.

Itisalsoself-reliant.LikeMaven,itisbuiltonthePlexus

componentframeworkandcomesbundledwithitsownJetty

applicationserver.Foritsdatabaseneeds,itusesApacheDerby,

a100percentJavafullyembeddeddatabase.Aswewillsee,

thismakesContinuumparticularlyeasytoinstallinalmostany

environment.

[35]http://maven.apache.org/continuum/



Part3:ContinuousIntegration

"Idon'tseemuchsenseinthat,"saidRabbit."No,"said

Poohhumbly,"thereisn't.Buttherewasgoingtobe

whenIbeganit.It'sjustthatsomethinghappenedtoit

alongtheway."

—"Tiggerisunbounced,"TheHouseatPoohCorner,

A.A.Milne.

Oneofthehardestthingstodoinanydevelopmentproject

iskeepingontrack.Manysoftwareprojectsendupgoing

offinunexpecteddirections,bothfromatechnical

perspectiveandfromabusinessone.Modulesbuiltby

differentdeveloperscanbedifficulttointegrate.Lackof

visibilityoftheapplicationbeingcodedoftenleadstoan

ever-wideninggapbetweenwhattheuserexpectsandwhat

thedevelopmentteamactuallybuilds.

ContinuousIntegrationcanhelpyourprojectinboth

regards,asitisapowerfultechniquethatcanbeusedto

makeyourdevelopmentprocesssmoother,morevisible,

andlessrisky.

Ifthereisonetechniquethatcanrevolutionizeyour

developmentprocess,itisContinuousIntegration.

TheunderlyingprincipleofContinuousIntegrationis

simple:integrateearly,andintegrateoften.Continuous

Integrationhasbeenaroundforatleast10years,although

morerecentlyithasbeenbroughtintothespotlightbyAgile

methodologies.

SowhatisContinuousIntegrationanyway?Continuous

Integrationisbasedontheobservationthatthelongeryou

waittointegrateyourteam'scode,theharderitgets.In

manyprojects,atypicaldevelopmentlifecyclegoes

somethinglikethis.Initially,codinggoesalongjustfine;

theremayevenbeunitteststoproveit!Then,atsome



pointintime,theteamleaderdecides(orreminds

everyone)thatadeliveryisdueinacoupleofweeks.It

maybejustanalphaoraprototype,butitisadelivery

nevertheless.Soit'sallhandsondecktogetsomething

workingfortheduedeadline.Theproblemis,whenIcheck

outmycode,itdoesn'tcompileanymore!Ofcourse,I

knowthatmycodeisOK,soit'sprobablysomeother

developer'sfault—maybetheyforgottocommitaclass,or

changedoneofmyinterfaceswithoutaskingmy

permission…oh,yeah,andsomeoftheunittestsnolonger

work,buttheybelongtotheDBteamdownthecorridor,so

Iwon'tworryaboutthemtoomuch…andsoon.

ThiswidelyobservedphenomenonisknowninAgilecircles

andelsewhereas"IntegrationHell."

ContinousIntegrationistheantidotetoIntegrationHell.It

offersapowerfulwaytodetectbugsandconflictsearlyso

thattheycanbefixedquicklyandeasilyandwithouttoo

muchbloodshedamongteammembers.Itbasically

involvesautomaticallybuildingandtestingcodeatregular

intervals.Teammemberscommittheircodetoversion

controlveryfrequently(atleastonadailybasis).Acentral

serverregularlychecksoutthelatestversionoftheproject

sourcecode,andrunsacompletebuild,including

compilationandtests.Thebuildprocessautomatically

notifiesteammembersofanybuildfailures,and(hopefully)

theteammemberresponsibleforcommitingfaultyor

conflictingcodewillimmediatelyjumpoutofhischair

(figurativelyspeaking)andrushofftofixtheproblem

beforeanyoneelsenotices!

Thispracticeisfirstandforemostarisk-reductionstrategy,

ensuringthattheapplicationintegratescorrectlyatall

timesandreducingtheriskofintegrationissuesappearing

lateintheproject.Additionalbenefitsincludeimproving

communicationbetweenteammembersandreducingthe

timeneededtopreparearelease.Indeed,inaprojectusing



ContinuousIntegration,youvirtuallyalwayshavea

demonstratable,ifnotdeliverable,versionoftheapplication

runningsomewhere.

However,ContinuousIntegrationgoesmuchfurtherthan

simplyensuringthatyourapplicationbuildscorrectlyatall

times.ContinuousIntegrationmeansthatyoualways(well,

almostalways)haveaworkingversionofyourapplication

toshowtotesters,users,andprojectsponsors.Don't

underestimatethebenefitsthatthiscanhaveonyour

project.Thismeansthat,atanypoint,youcandemonstrate

aparticularfeature,andgetfast,earlyfeedbackfrom

testersandendusers.Usersandsponsorsgetbetter

visibilityontheapplication'sfeaturesandontheproject's

realprogress,andpotentialissuesareraised(andfixed)

soonerratherthanlater.

Now,inpractice,aContinuousIntegrationprocesscanbe

automatedtovaryingdegrees.Someteamsusealargely

manualprocess;oncedevelopershavecompletedatask,

theyrunanintegrationbuildusinganautomatedbuildona

separateintegrationbuildmachine.Otherteamsusea

ContinuousIntegrationtoolsuchasCruiseControlto

automatetheprocess.

ThemostfundamentalfeatureofanyContinuous

Integrationtoolistheautomaticbuildcycle.TheContinuous

Integrationtool,eitheratascheduledpointintimeor

wheneveranychangesaredetectedinthesourcecode

repository,fetchesthesourcecode'slatestversionand

attemptstobuildandtesttheproject.Ifthebuildfails,

developerscanbenotifiedinanynumberofways:e-mail,

instantmessaging,telepathy,courierpigeon,orthrough

someother,moreexotic,notificationtechnique.

TherearemanyContinuousIntegrationtools,bothopen

sourceandcommercial,onthemarket,anddecidingwhich

onewouldbestsuityourparticularenvironmentcanprove

difficult.SomeContinuousIntegrationtoolsalsoboast



additionalSDLCfeatures,suchasreleasemanagementand

buildartifactmanagement,whereasothersconcentrateon

coreContinuousIntegrationfunctionalities.Sometryto

provideawiderangeofnotificationmethodsandsupport

virtuallyeveryversioncontrolsystemunderthesun,

whereasothersconcentrateondeliveringasmall,light,

easy-to-understandproduct.

Inthispart,wewilllookatfourofthemoreinteresting

opensourceContinousIntegrationtools:Continuum,

CruiseControl,LuntBuild,andHudson.

Continuumisasimple,lightweight,web-basedContinuous

Integrationtool.Itiseasytoinstallandinvolveslittleinitial

configuration.Onthedownside,itisnotasfeature-richas

someoftheothertools,andtheuserinterfaceisalittle

clunky.

CruiseControlisamatureandrobustJavaContinuous

Integrationtoolthatenjoysastronguserbaseandasolid

industryreputation.Itsupportsvirtuallyanytypeof

project,beitAnt,Maven,Maven2,make,orjustaplainoldcommandlinescript,aswellasawiderangeofSCM

(sourceconfigurationmanagement)tools.Itsnotification

techniquesaresecondtonone,anditcanintegrateeasily

withanythingfromamailservertoaLavaLamp.Italso

benefitsfromalargenumberofthird-partyplug-ins.Onthe

downside,itismuchhardertosetup,toconfigure,andto

maintainthananyoftheothertools,andtheuserinterface

issomewhatunappealing.

LuntbuildisanotheropensourceContinuousIntegration

toolwritteninJava.Itisfairlyeasytoinstallandconfigure,

and,likeContinuum,allserveradministrationtasksare

doneviaa(somewhatclunky)web-basedadministration

console.Luntbuildisdesignedtodomorethanjustmanage

thecontinuousintegrationprocess:italsoletsyoustore

andmanagegeneratedartifacts,labelandpromote

versions,andmanagedependenciesbetweenbuilds.It



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 5. Setting Up a Continuous Integration Server with Continuum

Tải bản đầy đủ ngay(0 tr)

×