Pipeline as Code

Kris Buytaert
Kris BuytaertDevops, Linux and Open Source Expert at Inuits
Pipeline as CodePipeline as Code
Kris Buytaert
@krisbuytaert
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 ConsultantCTO and Open Source Consultant
@@inuits.euinuits.eu
● Everything is a freaking DNSEverything is a freaking DNS
ProblemProblem
● Evangelizing devopsEvangelizing devops
● Organiser of #devopsdays,Organiser of #devopsdays,
#cfgmgmtcamp, #loadays, ….#cfgmgmtcamp, #loadays, ….
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
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
PipelinesPipelines
● Lots of themLots of them
● Similar ones, but not identical onesSimilar ones, but not identical ones
● One project = different deploymentOne project = different deployment
targetstargets
● People move teams expect samePeople move teams expect same
patternspatterns
● Mostly unmaintanedMostly unmaintaned
Dirty ClickersDirty Clickers
Complex PipelinesComplex Pipelines
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
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
JenkinsJobBuilderJenkinsJobBuilder
● First Usable AttemptFirst Usable Attempt
● Python BasedPython Based
● Openstack CommunityOpenstack Community
● Limited FunctionalityLimited Functionality
● Little Adoption / OpenstackLittle Adoption / Openstack
Abandonned itAbandonned it
PipelineDSLPipelineDSL
● JenkinsfileJenkinsfile
● Inside a repoInside a repo
● GroovyGroovy
● Limited functionalityLimited functionality
● Initially buggyInitially buggy
● Popular for Easy tasksPopular for Easy tasks
•
(straight, no splits etc)(straight, no splits etc)
Jenkins Job DSLJenkins Job DSL
● GroovyGroovy
● FlexibleFlexible
● Well SupportedWell Supported
● Suitable for more complex PipelinesSuitable for more complex Pipelines
SeedjobsSeedjobs
● GroovyGroovy
● GitGit
● Rebuild jobs onRebuild jobs on
commitcommit
● Projects inProjects in
foldersfolders
ExampleExample
Example dsl projectExample dsl project
job("${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")
Larger CI StacksLarger CI Stacks
● Generate Pipelines / Jobs based onGenerate Pipelines / Jobs based on
config files ,config files ,
● Build librariesBuild libraries
•
CheckoutJobCheckoutJob
•
DeployJobDeployJob
•
PackageJobPackageJob
● Use Groovy / JobDSL to generateUse Groovy / JobDSL to generate
PipelineDSLPipelineDSL
Other Tools :Other Tools :
Problems solvedProblems solved
● One job per task, no reuse of jobs withOne 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 allupdate all
● Centrally managed jobs (git)Centrally managed jobs (git)
Stop Clicking , Write CodeStop Clicking , Write Code
ContactContact
Kris BuytaertKris Buytaert Kris.Buytaert@inuits.beKris.Buytaert@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
EssensteenwegEssensteenweg
3131
BrasschaatBrasschaat
BelgiumBelgium
891.514.231891.514.231
1 of 20

More Related Content

What's hot(20)

The Return of the Dull Stack EngineerThe Return of the Dull Stack Engineer
The Return of the Dull Stack Engineer
Kris Buytaert2.4K views
Repositories as CodeRepositories as Code
Repositories as Code
Kris Buytaert642 views
Nightmare on Docker streetNightmare on Docker street
Nightmare on Docker street
Kris Buytaert4K views
Dev secops opsec, devsec, devops ?Dev secops opsec, devsec, devops ?
Dev secops opsec, devsec, devops ?
Kris Buytaert17.4K views
Devops is a Security RequirementDevops is a Security Requirement
Devops is a Security Requirement
Kris Buytaert699 views
devops is a reorgdevops is a reorg
devops is a reorg
Kris Buytaert2.1K views
Another 7 tools for your #devops stackAnother 7 tools for your #devops stack
Another 7 tools for your #devops stack
Kris Buytaert1.6K views
Continuous Infrastructure FirstContinuous Infrastructure First
Continuous Infrastructure First
Kris Buytaert568 views
No, we can't do continuous deliveryNo, we can't do continuous delivery
No, we can't do continuous delivery
Kris Buytaert1.8K views
Dod is not doneDod is not done
Dod is not done
Kris Buytaert21.9K views
Open Source Monitoring in 2019 Open Source Monitoring in 2019
Open Source Monitoring in 2019
Kris Buytaert1.5K views

More from Kris Buytaert(12)

Pipeline as Code

  • 1. Pipeline as CodePipeline as Code Kris Buytaert @krisbuytaert
  • 2. 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 ConsultantCTO and Open Source Consultant @@inuits.euinuits.eu ● Everything is a freaking DNSEverything is a freaking DNS ProblemProblem ● Evangelizing devopsEvangelizing devops ● Organiser of #devopsdays,Organiser of #devopsdays, #cfgmgmtcamp, #loadays, ….#cfgmgmtcamp, #loadays, ….
  • 3. 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
  • 4. 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
  • 5. PipelinesPipelines ● Lots of themLots of them ● Similar ones, but not identical onesSimilar ones, but not identical ones ● One project = different deploymentOne project = different deployment targetstargets ● People move teams expect samePeople move teams expect same patternspatterns ● Mostly unmaintanedMostly unmaintaned
  • 8. 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
  • 9. 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
  • 10. JenkinsJobBuilderJenkinsJobBuilder ● First Usable AttemptFirst Usable Attempt ● Python BasedPython Based ● Openstack CommunityOpenstack Community ● Limited FunctionalityLimited Functionality ● Little Adoption / OpenstackLittle Adoption / Openstack Abandonned itAbandonned it
  • 11. PipelineDSLPipelineDSL ● JenkinsfileJenkinsfile ● Inside a repoInside a repo ● GroovyGroovy ● Limited functionalityLimited functionality ● Initially buggyInitially buggy ● Popular for Easy tasksPopular for Easy tasks • (straight, no splits etc)(straight, no splits etc)
  • 12. Jenkins Job DSLJenkins Job DSL ● GroovyGroovy ● FlexibleFlexible ● Well SupportedWell Supported ● Suitable for more complex PipelinesSuitable for more complex Pipelines
  • 13. SeedjobsSeedjobs ● GroovyGroovy ● GitGit ● Rebuild jobs onRebuild jobs on commitcommit ● Projects inProjects in foldersfolders
  • 15. Example dsl projectExample dsl project job("${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")
  • 16. Larger CI StacksLarger CI Stacks ● Generate Pipelines / Jobs based onGenerate Pipelines / Jobs based on config files ,config files , ● Build librariesBuild libraries • CheckoutJobCheckoutJob • DeployJobDeployJob • PackageJobPackageJob ● Use Groovy / JobDSL to generateUse Groovy / JobDSL to generate PipelineDSLPipelineDSL
  • 18. Problems solvedProblems solved ● One job per task, no reuse of jobs withOne 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 allupdate all ● Centrally managed jobs (git)Centrally managed jobs (git)
  • 19. Stop Clicking , Write CodeStop Clicking , Write Code
  • 20. ContactContact Kris BuytaertKris Buytaert Kris.Buytaert@inuits.beKris.Buytaert@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 EssensteenwegEssensteenweg 3131 BrasschaatBrasschaat BelgiumBelgium 891.514.231891.514.231