CI,CDandJenkins2
WhoAmI?
• [email protected]• Youwillfindmehere
https://github.com/tan9
http://stackoverflow.com/users/3440376/tan9
• AnexperiencedCIadaptor• Hudson:Mid2009– February2011• Jenkins: February2011– present
2
BeforeWe Get Started…
• Jointhechannel:http://bit.do/jenkins-training• Ordirectlink:https://gitter.im/tan9/jenkins-training
• SigninusingyourGitHub account• Orsignuprightnow!
3
SilverBulletsforSoftwareQuality?
4
5ByCourtesyoftheNavalSurfaceWarfareCenter,Dahlgren,VA.,1988.- U.S.NavalHistoricalCenterOnlineLibraryPhotographNH96566-KN,PublicDomain,https://commons.wikimedia.org/w/index.php?curid=165211
6
DevOps
7Imageby Rajiv.Pant derivativework: Wylve / CCBY3.0https://commons.wikimedia.org/wiki/File:Devops.svg
ChatOps
8ImagefromGithub Hubot website:https://hubot.github.com/
ImmutableInfrastructure
9Josha Stella,ImmutableInfrastructure:Considerations fortheCloudandDistributed Systems,2016,O’Reillyhttps://fugue.co/assets/docs/Immutable_Infrastructure_Fugue.pdf
ContinuousIntegration
10
Failfast andcheap.Failoften.Failinawaythatdoesn’tkillyou.
- SethGodin
11
12https://commons.wikimedia.org/wiki/File:Hsiung_Feng_III_Anti-Ship_Missile_Display_in_Chengkungling_20111009a.jpg
ContinuousIntegrationisthepracticeofmergingalldeveloper workingcopies
toasharedmainlineseveraltimesaday.
13http://en.wikipedia.org/wiki/Continuous_integration
ContinuousWhat?
• Build• Test
• Unittests,integrationtests…
• Analysis• Feedback• Publish• Deploy• ...mosttediousthings!
14
WhatToBeIntegrated?
• People• Code• Environment• Report• Thought• ...everythingvaluable!
15
16WhyDevelopers<3CI:AGuidetoLovingContinuousIntegrationbyRebelLabs,2013http://zeroturnaround.com/rebellabs/rebel-labs-report-why-devs-love-ci-a-guide-to-loving-continuous-integration/
OR NOTIFY?
CIPractices
• Maintainasinglesourcerepository• Automatethebuild• Makeyourbuildself-testing• Everycommitshouldbuildonanintegrationmachine• Keepthebuildfast• Testinacloneoftheproductionenvironment• Makeiteasyforanyonetogetthelatestexecutable• Everyonecanseewhat’shappening• Automatedeployment
ContinuousIntegration|ThoughtWorkshttps://www.thoughtworks.com/continuous-integration
17
PowerTools
18WhyDevelopers<3CI:AGuidetoLovingContinuousIntegrationbyRebelLabs,2013http://zeroturnaround.com/rebellabs/rebel-labs-report-why-devs-love-ci-a-guide-to-loving-continuous-integration/
CI Servers Build Automation Tools Artifact Repositories Test Frameworks Code Analysis
TeamResponsibilities
• Checkinfrequently• Don’tcheckinbrokencode• Don’tcheckinuntestedcode• Don’tcheckinwhenthebuildisbroken• Don’tgohomeaftercheckinginuntilthesystembuilds
19ContinuousIntegration|ThoughtWorkshttps://www.thoughtworks.com/continuous-integration
20PaulM.Duvall etal,ContinuousIntegration:ImprovingSoftwareQualityandReducingRisk,2007,Addison-Wesley
ContinuousDelivery
21
Pipeline
22PragmaticContinuousDeliverywithJenkins,NexusandLiveRebel,2012http://zeroturnaround.com/rebellabs/zt-labs-tutorial-pragmatic-continuous-delivery-with-jenkins-nexus-and-liverebel/
ContinuousDeliveryProcess
23ContinuousDeliveryprocessdiagrambyGrégoire Détrez,originalbyJezHumble//CCBY-SA4.0https://commons.wikimedia.org/wiki/File:Continuous_Delivery_process_diagram.svg
HowAutomatedSurveyby
24PragmaticContinuousDeliverywithJenkins,NexusandLiveRebel,2012http://zeroturnaround.com/rebellabs/zt-labs-tutorial-pragmatic-continuous-delivery-with-jenkins-nexus-and-liverebel/
ThoughtWorks®TechnologyRadar
25ThoughtWorks®Techonlogy RaderApril‘16https://www.thoughtworks.com/radar
JenkinsTheButlerwithBowtie.
26
PersonalInformation
• BabyofKohsuke Kawaguchi( )• InapastlifenamedHudson
27
CIServerUsageSurveyby
28JavaToolsandTechnologiesLandscapeReport2016https://zeroturnaround.com/rebellabs/java-tools-and-technologies-landscape-2016/
Popularity(asof2016/06)
• TotalJenkinsinstallation
136,078• Totalnodes:
464,273⇒ 3.41nodesperinstallation
• Totaljobs8,858,054⇒ 65.56jobsperinstallation
29Jenkinsinfra-statisticshttp://stats.jenkins.io/jenkins-stats/
Terminology
Term Description
Job/Project Runnabletasksthatarecontrolled/monitoredbyJenkins.
Build ResultofonerunofaProject.
Artifact
Slave Slavesarecomputersthataresetuptobuildprojectsforamaster.
Node RefertoallmachinethatarepartofJenkinsgrid,slavesandmaster.
Executor SeparatedstreamofbuildstoberunonNodeinparallel.
Workspace DisposabledirectoryonNodeusedasaworkingdirectoryforbuilding.
Publisher Partofthebuildprocessotherthancompilation.Apublishermayreport stable or unstable resultdependingontheresultofitsprocessing.
30
BuildStatus
• StableBuild• Abuildisstableifitwasbuiltsuccessfullyandnopublisherreportsitasunstable.
• UnstableBuild• Abuildisunstableifitwasbuiltsuccessfullyandoneormorepublishersreportitunstable.
• FailedBuild• Abuildisbrokenifitfailedduringbuilding.Thatis,itisnotsuccessful.
31
RunningJenkins
• Download• https://jenkins.io/
• Setenvironmentvariable(optional)
(defaultpath:~/.jenkins)• Run
32
java -jar jenkins.war [--httpPort=8080]
StartingandAccessingJenkinshttps://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkins
JENKINS_HOME=/home/to/jenkins
33
...Jul 27, 2016 4:59:14 PM jenkins.install.SetupWizard initINFO:
***************************************************************************************************************************************************************************************
Jenkins initial setup is required. An admin user has beencreated and a password generated.Please use the following password to proceed to installation:
9fa65e05a58c4e9c8e6fc4288dfb6c32
This may also be found at:/home/to/jenkins/secrets/initialAdminPassword
***************************************************************************************************************************************************************************************
...
34
35
36
37
FreestyleProjectConfiguration
• SourceCodeManagement• BuildTriggers• BuildEnvironment• Build• Post-BuildActions
38
MavenProjectConfiguration
• SourceCodeManagement• BuildTriggers• BuildEnvironment• Build
• PreSteps• Build• PostSteps• BuildSettings
• Post-BuildActions
39
MultiConfiguration ProjectConfiguration• SourceCodeManagement• BuildTriggers• ConfigurationMatrix• BuildEnvironment• Build• Post-BuildActions
40
WorkBehindProxy
41
JenkinsGrid
42
JenkinsMaster/SlaveMode
• Distributetheworkload• Providedifferentenvironmentsneededforbuilds/tests/deployments
43
AgentLaunchMethods
• ViaJavaWebStart• Theagentneednotbereachablefromthemaster.
• Viaexecutionofcommandonthemaster• ViaSSHforagentsonUnixmachines
• Theslaveneedstobereachablefromthemaster,andyouwillhavetosupplyanaccountthatcanloginonthetargetmachine.
• ControlthisWindowsslaveasaWindowsservice• StartsaWindowsslavebyaremotemanagementfacilitybuiltintoWindows.
44
LabelingNodes
• Groupingnodesby• O.S.:windows,linux,macos…• Architecture:x86,x64…• Capability:docker,jboss-eap…• What’smeaningfultoyou
• RestrictprojectrunnodebyLabelExpression
45
postgres && !vm && (linux || freebsd)
JenkinsPipeline
46
PipelineScript
47
node {// Mark the code checkout 'stage'....stage 'Checkout'
// Get some code from a GitHub repositorygit url: 'https://github.com/jglick/simple-maven-project-with-tests.git'
// Get the maven tool.// ** NOTE: This 'M3' maven tool must be configured// ** in the global configuration.def mvnHome = tool 'M3'
// Mark the code build 'stage'....stage 'Build'// Run the maven buildsh "${mvnHome}/bin/mvn -Dmaven.test.failure.ignore clean package"step([$class: 'JUnitResultArchiver',
testResults: '**/target/surefire-reports/TEST-*.xml'])}
48
MustHavePlugins
49
testng-plugin (5066)aw
s-java-sdk (5138)em
beddable-build-status (5324)publish-over-ftp (5326)global-build-stats (5343)saferestart (5380)port-allocator (5450)dynam
icparameter (5614)
emailext-tem
plate (5631)text-finder (5684)scp (5816)job-dsl (5847)jackson2-api (5900)next-build-num
ber (5922)flexible-publish (5936)join (6047)delivery-pipeline-plugin (6067)xcode-plugin (6075)extra-colum
ns (6075)chucknorris (6116)em
ma (6143)
configurationslicing (6146)job-im
port-plugin (6147)build-blocker-plugin (6152)buildgraph-view
(6173)backup (6220)description-setter (6230)bitbucket (6236)build-user-vars-plugin (6264)python (6304)groovy-postbuild (6799)docker-com
mons (6850)
ghprb (6914)nested-view
(6977)pow
ershell (6992)dry (7094)m
2release (7118)jquery-ui (7231)m
ask-passwords (7276)
performance (7418)
authentication-tokens (7471)m
onitoring (7511)plot (7537)github-oauth (7579)view
-job-filters (7587)copy-to-slave (7604)throttle-concurrents (7690)jacoco (7815)postbuildscript (7821)artifactdeployer (7888)artifactory (7932)gitlab-plugin (8091)sim
ple-theme-plugin (8525)
nodejs (8529)extended-choice-param
eter (8664)nodelabelparam
eter (8710)build-flow
-plugin (8791)scriptler (8800)jira (9035)build-m
onitor-plugin (9296)analysis-collector (9666)log-parser (9858)m
ercurial (10026)config-file-provider (10120)findbugs (10566)disk-usage (10583)prom
oted-builds (10804)deploy (10885)groovy (11094)git-param
eter (11173)w
arnings (11288)thinBackup (11411)jenkins-m
ultijob-plugin (11441)pm
d (11451)postbuild-task (11594)build-nam
e-setter (12007)violations (12025)ruby-runtim
e (12054)m
ultiple-scms (12256)
rebuild (13156)m
sbuild (13724)ansicolor (13728)slack (14224)xunit (14282)checkstyle (14570)cobertura (15036)ssh (15256)role-strategy (15568)active-directory (16103)jobConfigHistory (17002)credentials-binding (17160)sonar (17959)dashboard-view
(18311)publish-over-ssh (20323)build-pipeline-plugin (20789)htm
lpublisher (21602)ssh-agent (21616)github-organization-folder (22666)github-branch-source (23954)tim
estamper (24135)
greenballs (25435)copyartifact (25447)build-tim
eout (26543)gradle (26968)conditional-buildstep (27137)pipeline-input-step (28677)pipeline-stage-view
(28748)pipeline-build-step (28748)pipeline-stage-step (28757)pipeline-rest-api (28915)w
orkflow-m
ultibranch (28923)m
omentjs (29860)
handlebars (29895)w
orkflow-aggregator (29983)
run-condition (30104)branch-api (30341)w
orkflow-cps-global-lib (30519)
analysis-core (31396)w
orkflow-durable-task-step (31586)
ws-cleanup (31678)
workflow
-basic-steps (32051)w
orkflow-job (32349)
workflow
-cps (32438)ace-editor (32579)jquery-detached (33204)w
orkflow-support (33697)
workflow
-api (34186)envinject (34317)cloudbees-folder (35981)durable-task (36386)jquery (38276)w
orkflow-scm
-step (38884)github (40406)git-server (40803)github-api (43238)structs (43239)plain-credentials (44323)param
eterized-trigger (46900)em
ail-ext (50123)icon-shim
(52730)w
orkflow-step-api (56279)
mapdb-api (73081)
token-macro (88146)
git (89345)git-client (92022)scm
-api (104976)script-security (114827)cvs (116614)translation (119714)junit (121377)m
atrix-project (125657)w
indows-slaves (126388)
antisamy-m
arkup-formatter (126489)
maven-plugin (127956)
subversion (128710)m
atrix-auth (129015)ldap (131841)ssh-slaves (132146)pam
-auth (132151)ant (132412)external-m
onitor-job (132612)ssh-credentials (132621)credentials (132919)javadoc (133300)m
ailer (133547)
s/green/blue/g
• It'snotforcolorblindusers.• It'sallabout(influencedby):
• GreenBallsPlugin• https://wiki.jenkins-ci.org/display/JENKINS/Green+Balls
50
青Cyan #00FFFF
“WhydoesJenkinshaveblueballs?” on2012-03-13by R.TylerCroyhttps://jenkins.io/blog/2012/03/13/why-does-jenkins-have-blue-balls/
• Gravatar - GloballyRecognizedAvatar• Registeryourownavatar
• athttps://en.gravatar.com/
• Makeiteasiertoidentifyone
51
StaticCodeAnalyses
52
• Checkstyle• DRY• FindBugs• PMD• CompilerWarnings• TaskScanner
• TODO,FIXME,XXX...
PluginsAvailable
• FindBugs Plugin• Checkstyle Plugin• PMDPlugin• DRYPlugin• JaCoCo Plugin• WarningsPlugin
53
JobConfigurationHistory
• Recordeverysinglechange• Savesacopyoftheconfigurationfileofajob(config.xml)foreverychangemade.
54
SCMSyncConfiguration
• Keepsync'ed configurationswithaSCMrepository.• Trackchanges(andauthor)madeoneveryfilewithcommitmessages.
55
ConfigurationSlicing
56
• Performmassconfigurationofselectprojectproperties.
DiskUsage
• Keepwatching!
57
FutureofJenkins
58
59
ProjectBlueOcean
60
YourTurnNow!
61
Top Related