Upload
others
View
11
Download
0
Embed Size (px)
Citation preview
ContinuousIntegration• WhatisContinuousIntegration?• Whydoweneedit?• DifferentphasesofadoptingContinuousIntegration
• Developerscommitcodetoasharedrepositoryonaregularbasis.
• Versioncontrolsystemisbeingmonitored.Whenacommitisdetected,abuildwillbetriggeredautomatically.
• Ifthebuildisnotgreen,developerswillbenotifiedimmediately.
WhatisContinuousIntegration?
WhydoweneedContinuousIntegration?
• Detectproblemsorbugs,asearlyaspossible,inthedevelopmentlifecycle.
• Sincetheentirecodebaseisintegrated,builtandtestedconstantly,thepotentialbugsanderrorsarecaughtearlierinthelifecyclewhichresultsinbetterqualitysoftware.
Fewcommits
Stage1:
• Nobuildservers.
• Developerscommitonaregularbasis.
• Changesareintegratedandtestedmanually.
• Fewerreleases.
Stage2:
Buildnightly
Buildandruntests
• Automatedbuildsarescheduledonaregularbasis.
• Buildscriptcompilestheapplicationandrunsasetofautomatedtests.
• Developersnowcommittheirchangesregularly.
• Buildserverswouldalerttheteammembersincaseofbuildfailure.
Stage3:
Triggeredatomically
Buildandruntests
• A buildistriggeredwhenevernewcodeiscommittedtothecentralrepository.
• Brokenbuildsareusuallytreatedasahighpriorityissueandarefixedquickly.
Stage4:
Triggeredatomically
Build,runcodequalityandcodecoveragemetricsalongwithtests
• Automatedcodequalityandcodecoveragemetricsarenowrunalongwithunitteststocontinuouslyevaluatethecodequality.
Isthecodecoverageincreasing?
Dowehavefewerandfewerbuildfailures?
• ContinuousIntegrationThepracticeofmergingdevelopmentworkwiththemainbranchconstantly.
• ContinuousDeliveryContinualdeliveryofcodetoanenvironmentoncethecodeisreadytoship.Thiscouldbestagingorproduction.Theideaistheproductisdeliveredtoauserbase,whichcanbeQAsorcustomersforreviewandinspection.
• ContinuousDeploymentThedeploymentorreleaseofcodetoproductionassoonasitisready.
DevOps
__________________________________________________
ContinuousIntegrationisalsoamindset
• Fixingbrokenbuildsshouldbetreatedasahighpriorityissueforallteammembers.
• Thedeploymentprocessshouldbeautomated,withnomanualstepsinvolved.
• Allteammembersshouldfocusoncontributingtohigh-qualitytestsbecausetheconfidentialityoftheCIprocesshighlydependsonthequalityofthetests.
WhatisJenkins• Jenkinsisacontinuousintegrationandbuildserver.
• Itisusedtomanually,periodically,orautomaticallybuildsoftware
developmentprojects.
• ItisanopensourceContinuousIntegrationtoolwritteninJava.
• Jenkinsisusedbyteamsofalldifferentsizes,forprojectswithvarious
languages.
WhyJenkinsispopular• Easytouse
• Greatextensibility– Supportdifferentversioncontrolsystems
– Codequalitymetrics
– Buildnotifiers
– UIcustomization
Jenkins’MasterandSlaveArchitecture
Master:• Schedulebuildjobs.• Dispatchbuildstotheslavesforthe
actualjobexecution.• Monitortheslavesandrecordthe
buildresults.• Canalsoexecutebuildjobsdirectly.
Slave:• Executebuildjobsdispatchedby
themaster.
Mavenpom.xml file• Describethesoftwareprojectbeingbuilt,including
– Thedependenciesonotherexternalmodules.– Thedirectorystructures.– Therequiredplugins.– Thepredefinedtargetsforperformingcertaintaskssuchas
compilationandpackaging.
DifferentPhasesinMavenBuildLifecycle
validate Validatetheprojectiscorrectandallnecessaryinformationisavailable.compile Compilethesourcecodeoftheproject.test Testthecompiledsourcecodeusingasuitableunittestingframework.package Takethecompiledcodeandpackageitinitsdistributableformat.verify Runanychecksonresultsofintegrationteststoensurequalitycriteriaaremet.install Installthepackageintothelocalrepository,foruseasadependencyinother
projectslocally.deploy Copythefinalpackagetotheremoterepositoryforsharingwithother
developersandprojects.
MavenBuildPhases• Theselifecyclephasesareexecutedsequentiallytocompletethedefault
lifecycle.
• Wewanttospecifythemavenpackage command,thiscommandwouldexecuteeachdefaultlifecyclephaseinorderincludingvalidate,compile,test beforeexecutingpackage.
• Weonlyneedtocallthelastbuildphasetobeexecuted.
Checkstyle isacodestaticanalysistooltohelpprogrammerstowriteJavacodethatadherestoacodingstandardsuchas
• Avoidingmultipleblanklines;• Removingunusedvariables;• Enforcingcorrectindentations;• …
ApacheAnt• Widely-usedandverywell-knownbuildscriptinglanguageforJava.• Flexible,extensible,relativelylow-levelscriptinglanguage.• AnAntbuildscriptismadeupofanumberoftargets,eachtarget
performsaparticularjobinthebuildprocess.
Gradle• Gradle isarelativelynewopensourcebuildtoolfortheJavaVirtualMachine.• BuildscriptsforGradle arewritteninaDomainSpecificLanguagebasedon
Groovy.• TheconcisenatureofGroovyscriptingletsyouwriteveryexpressivebuildscripts
withverylittlecode.
TomcatTomcatisanopen-sourcewebserverandprovidesa"pureJava”HTTPwebserverenvironmentinwhichJavacodecanrun.
Benefitsofacode-basedpipeline• Versioncontrol
• BestPractices
• Lesserror-proneexecutionofjobs
• Logic-basedexecutionofsteps
Additionalautomation• SetupGitrepositorypolling
• Deploymenttoourtomcatservers
• Wewillsetuptasks to run in parallel
Steps• Step1:Configuresecurit groups for Tomcat servers and create key pairs.
• Step2:Provisioninstances to staging and productionenvironments.
• Step3:InstallandrunTomcatoncreatedinstances.
• Step4:FullyautomateourexistingJenkinspipeline.
Build Orchestration: Jenkins _____________________________
• Continuous integration system • Enable automated build and test process • Can monitoring executions of externally‐run jobs, such as cron jobs and procmail jobs… • Dependency tracking, allowing file finger printing and tracking for example which build is using which version of jars… • Generates list of changes made to build from Subversion • Distributed build/test
• Jenkins is a build orchestration, CI software • building/testing software projects continuously • monitoring executions of externally‐run jobs
• FishEye allows you to extract information from your source code repository and display it in sophisticated reports. • Crucible allows you to request, perform and manage code reviews. • Subversion centralized version control system • Sonar is a quality management platform for analyzing and measuring source code quality.
CI/CD Pipeline: Functional Architecture
_______________________________________________
Version Control
Version
Control System
Code
Repository
Artifact Repository (Artifactory)
Build Management
(Maven)
Build
Automation
(Jenkins)
Test
Automation QA
(SonarCube)
Release
Orchestration
Deployment
Automation
Develop Pre-commit Tests
1
2 Commit code to Version Control
System 3 CI polls VCS
and creates Build 5
Automated Test Staging
UAT SAT
Security Scan Perf. & Load Testing
7
4 6
Release
8
Fail Fail Fail
Not approved
9
An Automated, Integrated and End to Ent CCRM
_______________________________________________
Git, GitLab, GitHub Enteprise, SVN…
Maven, Ant, Gradle
Nexsus, Artifactory
Jenkins…
Junit, Test NG, Cucumber, Selenium, JMeter, SoapUI, LoadRunner…
Release Management
Source Code Management
( Version Control)
Build Automation
CCRM
Test
Automation
Environment Configuration Management CI/CD