20
Pipeline as Code Pipeline as Code Kris Buytaert @krisbuytaert

Pipeline as Code

Embed Size (px)

Citation preview

Page 1: Pipeline as Code

Pipeline as CodePipeline as Code

Kris Buytaert

@krisbuytaert

Page 2: Pipeline as Code

Kris BuytaertKris Buytaert● I used to be a Dev,I used to be a Dev,● Then Became an OpThen Became an Op● CTO and Open Source Consultant CTO and Open Source Consultant

@@inuits.euinuits.eu● Everything is a freaking DNS Everything is a freaking DNS

ProblemProblem● Evangelizing devopsEvangelizing devops● Organiser of #devopsdays, Organiser of #devopsdays,

#cfgmgmtcamp, #loadays, ….#cfgmgmtcamp, #loadays, ….

Page 3: Pipeline as Code

cAmscAms● Build AutomationBuild Automation

● Test AutomationTest Automation

● Infrastructure as CodeInfrastructure as Code

● Monitoring as CodeMonitoring as Code

● Security as CodeSecurity as Code

● Pipeline as CodePipeline as Code

Page 4: Pipeline as Code

Jenkins as ExampleJenkins as Example

• Open Source toolOpen Source tool

• Widely adopted in the EnterpriseWidely adopted in the Enterprise

• Plenty of plugins availablePlenty of plugins available

• UI FocusedUI Focused

Page 5: Pipeline as Code

PipelinesPipelines● Lots of themLots of them

● Similar ones, but not identical onesSimilar ones, but not identical ones

● One project = different deployment One project = different deployment targetstargets

● People move teams expect same People move teams expect same patternspatterns

● Mostly unmaintaned Mostly unmaintaned

Page 6: Pipeline as Code

Dirty ClickersDirty Clickers

Page 7: Pipeline as Code

Complex PipelinesComplex Pipelines

Page 8: Pipeline as Code

Scaling PipelinesScaling Pipelines● Create a Pipeline,Create a Pipeline,

● For job in PipelineFor job in Pipeline

• Create new Job Based on OldJobCreate new Job Based on OldJob

● Update One JobUpdate One Job

● Never refactor the restNever refactor the rest

Page 9: Pipeline as Code

Generating Jenkins PipelinesGenerating Jenkins Pipelines

● Template the XMLTemplate the XML

● Put it in PuppetPut it in Puppet

• Worked for stable pipelinesWorked for stable pipelines

• KindaKinda

● XML gets rewritten on the flyXML gets rewritten on the fly

Page 10: Pipeline as Code

JenkinsJobBuilderJenkinsJobBuilder● First Usable AttemptFirst Usable Attempt

● Python BasedPython Based

● Openstack CommunityOpenstack Community

● Limited FunctionalityLimited Functionality

● Little Adoption / Openstack Little Adoption / Openstack Abandonned itAbandonned it

Page 11: Pipeline as Code

PipelineDSLPipelineDSL● Jenkinsfile Jenkinsfile

● Inside a repoInside a repo

● GroovyGroovy

● Limited functionalityLimited functionality

● Initially buggy Initially buggy

● Popular for Easy tasksPopular for Easy tasks

• (straight, no splits etc) (straight, no splits etc)

Page 12: Pipeline as Code

Jenkins Job DSLJenkins Job DSL● GroovyGroovy

● FlexibleFlexible

● Well SupportedWell Supported

● Suitable for more complex PipelinesSuitable for more complex Pipelines

Page 13: Pipeline as Code

SeedjobsSeedjobs● GroovyGroovy

● GitGit

● Rebuild jobs on Rebuild jobs on commitcommit

● Projects in Projects in foldersfolders

Page 14: Pipeline as Code

ExampleExample

Page 15: Pipeline as Code

Example dsl projectExample dsl projectjob("${foldername}/dashing-dashboard-build") job("${foldername}/dashing-dashboard-build")

job("${foldername}/dashing-dashboard-test")job("${foldername}/dashing-dashboard-test")

job("${foldername}/dashing-upload2repo") job("${foldername}/dashing-upload2repo")

job("${foldername}/dashing-dashboard-job("${foldername}/dashing-dashboard-deploy") deploy")

job("${foldername}/dashing-dashboard-job("${foldername}/dashing-dashboard-deploy-prd") deploy-prd")

job("${foldername}/dashing-build") job("${foldername}/dashing-build")

Page 16: Pipeline as Code

Larger CI StacksLarger CI Stacks● Generate Pipelines / Jobs based on Generate Pipelines / Jobs based on

config files , config files ,

● Build librariesBuild libraries

• CheckoutJobCheckoutJob

• DeployJobDeployJob

• PackageJobPackageJob

● Use Groovy / JobDSL to generate Use Groovy / JobDSL to generate PipelineDSLPipelineDSL

Page 17: Pipeline as Code

Other Tools :Other Tools :

Page 18: Pipeline as Code

Problems solvedProblems solved

● One job per task, no reuse of jobs with One job per task, no reuse of jobs with different parametersdifferent parameters

● All Jobs are in sync, update one = All Jobs are in sync, update one = update all update all

● Centrally managed jobs (git)Centrally managed jobs (git)

Page 19: Pipeline as Code

Stop Clicking , Write CodeStop Clicking , Write Code

Page 20: Pipeline as Code

ContactContactKris Buytaert Kris Buytaert [email protected]@inuits.be

Further ReadingFurther Reading@krisbuytaert @krisbuytaert http://www.krisbuytaert.be/blog/http://www.krisbuytaert.be/blog/http://www.inuits.be/http://www.inuits.be/

InuitsInuits

Essensteenweg Essensteenweg 3131BrasschaatBrasschaatBelgiumBelgium891.514.231891.514.231

+32 475 961221+32 475 961221