SlideShare a Scribd company logo
1 of 25
Declarative	
  Pipeline
Malcolm	
  Groves
malcolm@code-­‐partners.com
@malgroves
Training,	
  Consulting	
  and	
  Services	
  across	
  
the	
  whole	
  Development	
  and	
  Deployment	
  
lifecycle.
What’s	
  Pipeline?
Pipeline
• Pipeline	
  as	
  Code
• Versioned	
  with	
  rest	
  of	
  application	
  source
• Pipelines	
  can	
  be	
  restarted!	
  Yay!	
  
• Initially	
  specified	
  in	
  Groovy-­‐based	
  language	
  :	
  Scripted	
  Pipelines
• Very	
  flexible,	
  it’s	
  code!
• Shared	
  Objects	
  
Sounds	
  Awesome.	
  What’s	
  the	
  
problem?
“Problem”	
  is	
  probably	
  too	
  harsh,	
  but:
• Some	
  barrier	
  to	
  adopting	
  (even	
  if	
  perceived	
  barrier)
• “I	
  don’t	
  know	
  Groovy”
• Structure	
  of	
  code	
  doesn’t	
  always	
  communicate	
  what	
  pipeline	
  does
• Tough	
  to	
  catch	
  errors	
  without	
  running	
  pipeline
• Visual	
  Tooling	
  challenging.
What’s	
  Declarative	
  Pipeline?
Declarative	
  Pipeline
• Alternative	
  to	
  Scripted	
  Pipeline
• More	
  approachable,	
  no	
  need	
  to	
  know	
  any	
  Groovy
• More	
  readable
• Structure	
  communicates	
  what	
  is	
  happening
• Visual,	
  two-­‐way	
  Editor	
  
• Still	
  Jenkinsfile-­‐based
Hello	
  World	
  of	
  Declarative
Pipelines
Declarative	
  Pipeline	
  Sections
Basic	
  Structure pipeline  {
agent  any    
environment  {
Foo  =  'Bar’
Fred  =  'Flintstone’
}
stages  {        
stage('Build')  {
steps  {
bat  'echo  %Foo%’
}
}
}
}
• Whole	
  file	
  wrapped	
  in	
  a	
  pipeline	
  
section
• stages specifies	
  what	
  will	
  run	
  
• 1	
  or	
  more	
  stage	
  directives
• Each	
  stage	
  contains	
  1	
  or	
  more	
  
steps
agent pipeline  {    
agent  any    
environment  {
Foo  =  'Bar’
Fred  =  'Flintstone’
}
stages  {        
stage('Build')  {
steps  {
bat  'echo  %Foo%’
}
}
}
}
• agent	
  specifies	
  where	
  pipeline	
  
will	
  be	
  run:
• any,	
  none,	
  label,	
  docker,	
  dockerfile
• Can	
  specify	
  per	
  stage	
  as	
  well
agent
pipeline  {
agent  none
stages  {
stage('Example  Build')  {
agent  {docker 'maven:3-­‐alpine'}
steps  {
echo  'Hello,  Maven’
sh 'mvn -­‐-­‐version'                        
}
}
stage('Example  Test')  {
agent  {docker 'openjdk:8-­‐jre'}
steps  {
echo  'Hello,  JDK'                                
sh 'java  -­‐version'
}
}        
}
}
• Example	
  of	
  per-­‐stage	
  agent	
  
directive
• Needs	
  pipeline-­‐level	
  agent	
  
directive	
  to	
  be	
  none
Stages pipeline  {
agent  any
stages  {
stage('Example  Build')  {
steps  {
echo  'Hello  World’
}
}
stage('Example  Deploy')  {
when  {branch  'production'}
echo  'Deploying’
}
}
}
• “When”	
  directive	
  allows	
  
conditional	
  execution	
  of	
  stages
• Conditions:
• branch	
  – match	
  to	
  branch	
  name
• environment	
  – match	
  to	
  
environment	
  variables
• expression	
  – Groovy	
  expression	
  
evaluates	
  to	
  true	
  
Steps
pipeline  {
agent  any
stages  {
stage(’Test')  {
steps  {
archive  ‘*/target/**/*’
junit‘*/target/reports/*.xml’
}
}
}
}
• The	
  actual	
  work	
  to	
  be	
  performed	
  
inside	
  this	
  stage
• Individual	
  Steps	
  can	
  be:
• Any	
  pipeline	
  build	
  step.
Steps
pipeline  {
agent  any
stages  {
stage(’Audits')  {
steps  {
parallel(
“code  analysis”:  {
bat:  ‘echo  do  stuff’
},
“security  scan”:  {
bat:  ‘echo  do  stuff’
},
)
}
}
}
}
• The	
  actual	
  work	
  to	
  be	
  performed	
  
inside	
  this	
  stage
• Individual	
  Steps	
  can	
  be:
• Any	
  pipeline	
  build	
  step.
• parallel
Steps
pipeline  {
agent  any
stages  {
stage(’Audits')  {
steps  {
echo  'Hello  World’
script  {
def browsers  =  ['chrome',  'firefox']
for  (int i =  0;  i <  browsers.size();  ++i)  {
echo  "Testing  the  ${browsers[i]}  browser"    
}
}
}
}
}
}
• The	
  actual	
  work	
  to	
  be	
  performed	
  
inside	
  this	
  stage
• Individual	
  Steps	
  can	
  be:
• Any	
  pipeline	
  build	
  step.
• Parallel
• Script
Environment
pipeline  {
agent  any
environment  {
CC  =  'clang’
}
stages  {
stage('Example')  {
environment  {
MY_KEY  =  credentials('my-­‐secret-­‐text')
}
steps  {
sh 'printenv’
}
}
}
}
• Name	
  =	
  value	
  pairs	
  that	
  will	
  be	
  
defined	
  as	
  environment	
  
variables
• Variables	
  are	
  scoped:
• to	
  whole	
  pipeline,	
  or
• to	
  just	
  an	
  individual	
  stage	
  if	
  
defined	
  at	
  stage	
  level
• Helper	
  function	
  to	
  access	
  
Credentials	
  defined	
  in	
  Jenkins
Post
pipeline  {
agent  any
stages  {
stage('Example')  {
steps  {
echo  'Hello  World’
}
}
}        
post  {
always  {
archive  ‘*/target/**/*’
junit‘*/target/reports/*.xml’
}
failure  {
echo  ‘yikes,  build  broke!’
}
}
}
• Defines	
  steps	
  to	
  run	
  at	
  end	
  of	
  
pipeline	
  (or	
  stage)
• Conditions:
• Always
• Failure
• Success
• Unstable
• Changed
A	
  few	
  other	
  sections
• Options
• Options	
  for	
  whole	
  pipeline,	
  eg.	
  Timeout,	
  skipDefaultCheckout,	
  etc
• Tools
• Install	
  pre-­‐defined	
  tools
• Triggers
• alternative	
  triggers	
  for	
  pipeline,	
  eg.	
  Schedule,	
  poll,	
  etc
• Parameters	
  
• Define	
  parameters	
  that	
  will	
  be	
  prompted	
  for	
  at	
  run	
  time
https://jenkins.io/doc/book/pipeline/syntax/
Declarative	
  Pipelines	
  are	
  for	
  
making	
  most	
  things	
  easier.
For	
  corner-­‐cases,	
  you	
  have	
  Scripted	
  Pipelines
The	
  Dev	
  workflow	
  I’ve	
  shown	
  is	
  a	
  
bit	
  cumbersome
Let’s	
  fix	
  that
Tools	
  and	
  Resources
Links
• Pipeline	
  Syntax	
  https://jenkins.io/doc/book/pipeline/syntax/
• Steps	
  Reference	
  https://jenkins.io/doc/pipeline/steps/
Tools
• Replay	
  https://jenkins.io/doc/book/pipeline/development/#replay
• Linter	
  https://jenkins.io/doc/book/pipeline/development/#linter
• Unit	
  Testing	
  (3rd Party)	
  
https://github.com/lesfurets/JenkinsPipelineUnit
Questions?
Thank	
  You
malcolm@code-­‐partners.com
@malgroves

More Related Content

What's hot

Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 PipelineDelivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 PipelineSlawa Giterman
 
Building an Extensible, Resumable DSL on Top of Apache Groovy
Building an Extensible, Resumable DSL on Top of Apache GroovyBuilding an Extensible, Resumable DSL on Top of Apache Groovy
Building an Extensible, Resumable DSL on Top of Apache Groovyjgcloudbees
 
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins PipelinesAn Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins PipelinesSteffen Gebert
 
Jenkins days workshop pipelines - Eric Long
Jenkins days workshop  pipelines - Eric LongJenkins days workshop  pipelines - Eric Long
Jenkins days workshop pipelines - Eric Longericlongtx
 
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...Edureka!
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins PipelinesSteffen Gebert
 
Continuous Delivery - Pipeline as-code
Continuous Delivery - Pipeline as-codeContinuous Delivery - Pipeline as-code
Continuous Delivery - Pipeline as-codeMike van Vendeloo
 
Jenkins, pipeline and docker
Jenkins, pipeline and docker Jenkins, pipeline and docker
Jenkins, pipeline and docker AgileDenver
 
CI/CD on Android project via Jenkins Pipeline
CI/CD on Android project via Jenkins PipelineCI/CD on Android project via Jenkins Pipeline
CI/CD on Android project via Jenkins PipelineVeaceslav Gaidarji
 
7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins Users7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins UsersJules Pierre-Louis
 
Continuous Integration With Jenkins Docker SQL Server
Continuous Integration With Jenkins Docker SQL ServerContinuous Integration With Jenkins Docker SQL Server
Continuous Integration With Jenkins Docker SQL ServerChris Adkin
 
Ci with jenkins docker and mssql belgium
Ci with jenkins docker and mssql belgiumCi with jenkins docker and mssql belgium
Ci with jenkins docker and mssql belgiumChris Adkin
 
Building Jenkins Pipelines at Scale
Building Jenkins Pipelines at ScaleBuilding Jenkins Pipelines at Scale
Building Jenkins Pipelines at ScaleJulien Pivotto
 
Flash Camp Chennai - Build automation of Flex and AIR applications
Flash Camp Chennai - Build automation of Flex and AIR applicationsFlash Camp Chennai - Build automation of Flex and AIR applications
Flash Camp Chennai - Build automation of Flex and AIR applicationsRIA RUI Society
 
Testing with Docker
Testing with DockerTesting with Docker
Testing with Dockertoffermann
 
Let's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a CertificateLet's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a CertificateSteffen Gebert
 
Continuous Delivery Pipeline with Docker and Jenkins
Continuous Delivery Pipeline with Docker and JenkinsContinuous Delivery Pipeline with Docker and Jenkins
Continuous Delivery Pipeline with Docker and JenkinsCamilo Ribeiro
 
How to write a Dockerfile
How to write a DockerfileHow to write a Dockerfile
How to write a DockerfileKnoldus Inc.
 

What's hot (20)

Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 PipelineDelivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
 
Building an Extensible, Resumable DSL on Top of Apache Groovy
Building an Extensible, Resumable DSL on Top of Apache GroovyBuilding an Extensible, Resumable DSL on Top of Apache Groovy
Building an Extensible, Resumable DSL on Top of Apache Groovy
 
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins PipelinesAn Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
 
Jenkins days workshop pipelines - Eric Long
Jenkins days workshop  pipelines - Eric LongJenkins days workshop  pipelines - Eric Long
Jenkins days workshop pipelines - Eric Long
 
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines
 
Continuous Delivery - Pipeline as-code
Continuous Delivery - Pipeline as-codeContinuous Delivery - Pipeline as-code
Continuous Delivery - Pipeline as-code
 
Jenkins, pipeline and docker
Jenkins, pipeline and docker Jenkins, pipeline and docker
Jenkins, pipeline and docker
 
CI/CD on Android project via Jenkins Pipeline
CI/CD on Android project via Jenkins PipelineCI/CD on Android project via Jenkins Pipeline
CI/CD on Android project via Jenkins Pipeline
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins Users7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins Users
 
sed.pdf
sed.pdfsed.pdf
sed.pdf
 
Continuous Integration With Jenkins Docker SQL Server
Continuous Integration With Jenkins Docker SQL ServerContinuous Integration With Jenkins Docker SQL Server
Continuous Integration With Jenkins Docker SQL Server
 
Ci with jenkins docker and mssql belgium
Ci with jenkins docker and mssql belgiumCi with jenkins docker and mssql belgium
Ci with jenkins docker and mssql belgium
 
Building Jenkins Pipelines at Scale
Building Jenkins Pipelines at ScaleBuilding Jenkins Pipelines at Scale
Building Jenkins Pipelines at Scale
 
Flash Camp Chennai - Build automation of Flex and AIR applications
Flash Camp Chennai - Build automation of Flex and AIR applicationsFlash Camp Chennai - Build automation of Flex and AIR applications
Flash Camp Chennai - Build automation of Flex and AIR applications
 
Testing with Docker
Testing with DockerTesting with Docker
Testing with Docker
 
Let's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a CertificateLet's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a Certificate
 
Continuous Delivery Pipeline with Docker and Jenkins
Continuous Delivery Pipeline with Docker and JenkinsContinuous Delivery Pipeline with Docker and Jenkins
Continuous Delivery Pipeline with Docker and Jenkins
 
How to write a Dockerfile
How to write a DockerfileHow to write a Dockerfile
How to write a Dockerfile
 

Similar to Jenkins Declarative Pipelines 101

Atlanta Jenkins Area Meetup October 22nd 2015
Atlanta Jenkins Area Meetup October 22nd 2015Atlanta Jenkins Area Meetup October 22nd 2015
Atlanta Jenkins Area Meetup October 22nd 2015Kurt Madel
 
Pipeline 101 Lorelei Mccollum
Pipeline 101 Lorelei MccollumPipeline 101 Lorelei Mccollum
Pipeline 101 Lorelei MccollumLorelei McCollum
 
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Jenkins Days - Workshop - Let's Build a Pipeline - Los AngelesJenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Jenkins Days - Workshop - Let's Build a Pipeline - Los AngelesAndy Pemberton
 
How to build rock solid apps & keep 100m+ users happy
How to build rock solid apps & keep 100m+ users happyHow to build rock solid apps & keep 100m+ users happy
How to build rock solid apps & keep 100m+ users happyIordanis (Jordan) Giannakakis
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFXHendrik Ebbers
 
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source ToolsTYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source ToolsMichael Lihs
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance testBryan Liu
 
Everything as Code with Azure DevOps
Everything as Code with Azure DevOpsEverything as Code with Azure DevOps
Everything as Code with Azure DevOpsVenura Athukorala
 
Moving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresMoving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresFrits Van Der Holst
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Michael Lihs
 
Jenkins Pipeline 101 and TCI - presentation and workshop
Jenkins Pipeline 101 and TCI - presentation and workshopJenkins Pipeline 101 and TCI - presentation and workshop
Jenkins Pipeline 101 and TCI - presentation and workshopYoram Michaeli
 
Madrid JAM limitaciones - dificultades
Madrid JAM limitaciones - dificultadesMadrid JAM limitaciones - dificultades
Madrid JAM limitaciones - dificultadesJavier Delgado Garrido
 
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginGr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginYasuharu Nakano
 
Web a Quebec - JS Debugging
Web a Quebec - JS DebuggingWeb a Quebec - JS Debugging
Web a Quebec - JS DebuggingRami Sayar
 
Introduction to GOCD - Amulya Sharma
Introduction to GOCD - Amulya SharmaIntroduction to GOCD - Amulya Sharma
Introduction to GOCD - Amulya SharmaAmulya Sharma
 
Kubernetes Workshop
Kubernetes WorkshopKubernetes Workshop
Kubernetes Workshoploodse
 
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08Борис Зора
 

Similar to Jenkins Declarative Pipelines 101 (20)

Atlanta Jenkins Area Meetup October 22nd 2015
Atlanta Jenkins Area Meetup October 22nd 2015Atlanta Jenkins Area Meetup October 22nd 2015
Atlanta Jenkins Area Meetup October 22nd 2015
 
Jenkins presentation
Jenkins presentationJenkins presentation
Jenkins presentation
 
Pipeline 101 Lorelei Mccollum
Pipeline 101 Lorelei MccollumPipeline 101 Lorelei Mccollum
Pipeline 101 Lorelei Mccollum
 
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Jenkins Days - Workshop - Let's Build a Pipeline - Los AngelesJenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
 
DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020
 
How to build rock solid apps & keep 100m+ users happy
How to build rock solid apps & keep 100m+ users happyHow to build rock solid apps & keep 100m+ users happy
How to build rock solid apps & keep 100m+ users happy
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source ToolsTYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance test
 
Introduction to Go
Introduction to GoIntroduction to Go
Introduction to Go
 
Everything as Code with Azure DevOps
Everything as Code with Azure DevOpsEverything as Code with Azure DevOps
Everything as Code with Azure DevOps
 
Moving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresMoving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventures
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
 
Jenkins Pipeline 101 and TCI - presentation and workshop
Jenkins Pipeline 101 and TCI - presentation and workshopJenkins Pipeline 101 and TCI - presentation and workshop
Jenkins Pipeline 101 and TCI - presentation and workshop
 
Madrid JAM limitaciones - dificultades
Madrid JAM limitaciones - dificultadesMadrid JAM limitaciones - dificultades
Madrid JAM limitaciones - dificultades
 
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginGr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
 
Web a Quebec - JS Debugging
Web a Quebec - JS DebuggingWeb a Quebec - JS Debugging
Web a Quebec - JS Debugging
 
Introduction to GOCD - Amulya Sharma
Introduction to GOCD - Amulya SharmaIntroduction to GOCD - Amulya Sharma
Introduction to GOCD - Amulya Sharma
 
Kubernetes Workshop
Kubernetes WorkshopKubernetes Workshop
Kubernetes Workshop
 
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
 

Recently uploaded

Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 

Recently uploaded (20)

Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 

Jenkins Declarative Pipelines 101

  • 2. Training,  Consulting  and  Services  across   the  whole  Development  and  Deployment   lifecycle.
  • 4. Pipeline • Pipeline  as  Code • Versioned  with  rest  of  application  source • Pipelines  can  be  restarted!  Yay!   • Initially  specified  in  Groovy-­‐based  language  :  Scripted  Pipelines • Very  flexible,  it’s  code! • Shared  Objects  
  • 5. Sounds  Awesome.  What’s  the   problem?
  • 6. “Problem”  is  probably  too  harsh,  but: • Some  barrier  to  adopting  (even  if  perceived  barrier) • “I  don’t  know  Groovy” • Structure  of  code  doesn’t  always  communicate  what  pipeline  does • Tough  to  catch  errors  without  running  pipeline • Visual  Tooling  challenging.
  • 8. Declarative  Pipeline • Alternative  to  Scripted  Pipeline • More  approachable,  no  need  to  know  any  Groovy • More  readable • Structure  communicates  what  is  happening • Visual,  two-­‐way  Editor   • Still  Jenkinsfile-­‐based
  • 9. Hello  World  of  Declarative Pipelines
  • 11. Basic  Structure pipeline  { agent  any     environment  { Foo  =  'Bar’ Fred  =  'Flintstone’ } stages  {         stage('Build')  { steps  { bat  'echo  %Foo%’ } } } } • Whole  file  wrapped  in  a  pipeline   section • stages specifies  what  will  run   • 1  or  more  stage  directives • Each  stage  contains  1  or  more   steps
  • 12. agent pipeline  {     agent  any     environment  { Foo  =  'Bar’ Fred  =  'Flintstone’ } stages  {         stage('Build')  { steps  { bat  'echo  %Foo%’ } } } } • agent  specifies  where  pipeline   will  be  run: • any,  none,  label,  docker,  dockerfile • Can  specify  per  stage  as  well
  • 13. agent pipeline  { agent  none stages  { stage('Example  Build')  { agent  {docker 'maven:3-­‐alpine'} steps  { echo  'Hello,  Maven’ sh 'mvn -­‐-­‐version'                         } } stage('Example  Test')  { agent  {docker 'openjdk:8-­‐jre'} steps  { echo  'Hello,  JDK'                                 sh 'java  -­‐version' } }         } } • Example  of  per-­‐stage  agent   directive • Needs  pipeline-­‐level  agent   directive  to  be  none
  • 14. Stages pipeline  { agent  any stages  { stage('Example  Build')  { steps  { echo  'Hello  World’ } } stage('Example  Deploy')  { when  {branch  'production'} echo  'Deploying’ } } } • “When”  directive  allows   conditional  execution  of  stages • Conditions: • branch  – match  to  branch  name • environment  – match  to   environment  variables • expression  – Groovy  expression   evaluates  to  true  
  • 15. Steps pipeline  { agent  any stages  { stage(’Test')  { steps  { archive  ‘*/target/**/*’ junit‘*/target/reports/*.xml’ } } } } • The  actual  work  to  be  performed   inside  this  stage • Individual  Steps  can  be: • Any  pipeline  build  step.
  • 16. Steps pipeline  { agent  any stages  { stage(’Audits')  { steps  { parallel( “code  analysis”:  { bat:  ‘echo  do  stuff’ }, “security  scan”:  { bat:  ‘echo  do  stuff’ }, ) } } } } • The  actual  work  to  be  performed   inside  this  stage • Individual  Steps  can  be: • Any  pipeline  build  step. • parallel
  • 17. Steps pipeline  { agent  any stages  { stage(’Audits')  { steps  { echo  'Hello  World’ script  { def browsers  =  ['chrome',  'firefox'] for  (int i =  0;  i <  browsers.size();  ++i)  { echo  "Testing  the  ${browsers[i]}  browser"     } } } } } } • The  actual  work  to  be  performed   inside  this  stage • Individual  Steps  can  be: • Any  pipeline  build  step. • Parallel • Script
  • 18. Environment pipeline  { agent  any environment  { CC  =  'clang’ } stages  { stage('Example')  { environment  { MY_KEY  =  credentials('my-­‐secret-­‐text') } steps  { sh 'printenv’ } } } } • Name  =  value  pairs  that  will  be   defined  as  environment   variables • Variables  are  scoped: • to  whole  pipeline,  or • to  just  an  individual  stage  if   defined  at  stage  level • Helper  function  to  access   Credentials  defined  in  Jenkins
  • 19. Post pipeline  { agent  any stages  { stage('Example')  { steps  { echo  'Hello  World’ } } }         post  { always  { archive  ‘*/target/**/*’ junit‘*/target/reports/*.xml’ } failure  { echo  ‘yikes,  build  broke!’ } } } • Defines  steps  to  run  at  end  of   pipeline  (or  stage) • Conditions: • Always • Failure • Success • Unstable • Changed
  • 20. A  few  other  sections • Options • Options  for  whole  pipeline,  eg.  Timeout,  skipDefaultCheckout,  etc • Tools • Install  pre-­‐defined  tools • Triggers • alternative  triggers  for  pipeline,  eg.  Schedule,  poll,  etc • Parameters   • Define  parameters  that  will  be  prompted  for  at  run  time https://jenkins.io/doc/book/pipeline/syntax/
  • 21. Declarative  Pipelines  are  for   making  most  things  easier. For  corner-­‐cases,  you  have  Scripted  Pipelines
  • 22. The  Dev  workflow  I’ve  shown  is  a   bit  cumbersome Let’s  fix  that
  • 23. Tools  and  Resources Links • Pipeline  Syntax  https://jenkins.io/doc/book/pipeline/syntax/ • Steps  Reference  https://jenkins.io/doc/pipeline/steps/ Tools • Replay  https://jenkins.io/doc/book/pipeline/development/#replay • Linter  https://jenkins.io/doc/book/pipeline/development/#linter • Unit  Testing  (3rd Party)   https://github.com/lesfurets/JenkinsPipelineUnit