SlideShare a Scribd company logo
https://www.flickr.com/photos/amerune/9294639633/in/photostream/
Jenkins Pipelines
Ramanathan Muthaiah,
rus.cahimb@gmail.com
DevOps Meetup, Bengaluru,
19/Aug/2017
What’s in it for me?
Pipeline helps to,
codify build flow
divide monolithic build
to logical stages
bind execution of one
or more stages based
on previous stage’s
result
abstract common tasks
to shared libraries
Learn Groovy DSL (scripted
syntax, shared libraries)
Declarative syntax follows
imperative model
Jenkins v2.x + Pipeline suite
of plugins
Tons and tons of patience to
toil, sweat a.k.a. R(ead),
A(pply), D(ocument) and
S(hare)
lots and lots of
Pre-requisites
https://www.flickr.com/photos/87232391@N00/403119696
Getting Started. . .
Have a test Jenkins master,
playground for trial and error
mirror (as close as possible) production instance
access to rest of infra or replicate where infra cannot be shared (e.g:
artifactory, s3, build agents)
mental model of what to do — logical blocks needed, how to tie them
up, what can or cannot be done in parallel, archive, notifications.
Tooo……ooons of material on the Internet on Jenkins Pipeline
Bite the bullet . . . Start writing pipeline as code
Start with individual stages, one stage at a time
Pipeline syntax and snippet generator
Pipeline script in <Version Control> => modify, build, test : repeat
Better yet, Replay on the passed or failed job
update on the fly, build, test
But, but, no Replay for builds failed on Groovy syntax :-(
Namaskara…
#!groovy
node(‘linux’) { // any build agent with label, linux;if left blank, master
stage(‘Prep’) {
def greet = “Welcome to Pipeline” // variable declaration
echo “${greet}”
sh “uname -a”
def ip_address = sh(returnStdout: true, 
script: “ifconfig eth0 | grep -i inet | head -1 | awk -F’:’ ‘{print $2}’
| awk -F’ ‘ ‘{print $1}’”).trim()
println “Node’s IP address, ip_address”
}
}
Common Gotchas…
Pipeline syntax errors
DO NOT copy and paste from your editor or from the previous slide
Most common: Typos in pipeline code
Cautious with usage of Unix tools within Pipeline
single, double quotes
Got it finally…
#!groovy
node(‘linux’) { // build agent with label ‘linux’;if left blank,
master
stage("Prep") {
def greet = “Welcome to Pipeline" // variable declaration
echo "${greet}"
sh "uname -a"
sh "'/sbin/ifconfig eth0 | 
grep -i inet | head -1 | 
cut -d: -f2 |
awk -F' ' '{print $1}' 
"'
}
sh step has many avatars
1. sh “command”
2. sh (returnStdout …)
3. sh (returnStatus …)
4. sh followed by three single or double quotes
(for variable interpolation)
Output from build console log
useful links
Online examples for various steps…
wiki => https://jenkins.io/doc/pipeline/examples/
code => https://github.com/jenkinsci/pipeline-examples/tree/master/
pipeline-examples
contribute your’s today, https://github.com/jenkinsci/pipeline-examples
Plugins compatible with Pipeline
https://github.com/jenkinsci/pipeline-plugin/blob/master/COMPATIBILITY.md
Pipeline resources
Syntax reference, https://jenkins.io/doc/book/pipeline/syntax
Steps reference, https://jenkins.io/doc/pipeline/steps
BlueOcean
https://jenkins.io/doc/book/blueocean
Handling SCM … Git
Have generic service accounts, avoid storing user credentials
Jenkins has built-in implementation of Git :-)
But, it may not be in sync with generally available version of Git :-(
Handling large Git repos in Jenkins
First 10mins from Jenkins online meetup video, https://www.youtube.com/
watch?v=TsWkZLLU-s4
https://www.cloudbees.com/blog/advanced-git-jenkins
General tips for handling large Git repos,
https://www.atlassian.com/blog/git/handle-big-repositories-git
https://larsxschneider.github.io/2016/09/21/large-git-repos

More Related Content

PDF
Jenkins remote loader
PDF
Groovy - Grails as a modern scripting language for Web applications
PPT
Testing Web Apps With Scripting Language - Mark Rees, Century Software
PDF
Graduating to Jenkins CI for Ruby(-on-Rails) Teams
PDF
CocoaHeads Rennes #13 : CocoaPods
PDF
Jenkins Best Practices Meetup Slides
PDF
Create your own composer package
PDF
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Jenkins remote loader
Groovy - Grails as a modern scripting language for Web applications
Testing Web Apps With Scripting Language - Mark Rees, Century Software
Graduating to Jenkins CI for Ruby(-on-Rails) Teams
CocoaHeads Rennes #13 : CocoaPods
Jenkins Best Practices Meetup Slides
Create your own composer package
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...

What's hot (20)

PPTX
DevOps Fest 2020. Роман Орлов. Инфраструктура тестирования в Kubernetes
PDF
@arzumy Dev Setup #klxrb
PDF
JavaScript and Desktop Apps - Introduction to Electron
PDF
Learned lessons in a real world project
PPT
Jenkins auto configureforbranch-php
PPTX
Session on Selenium 4 : What’s coming our way? by Hitesh Prajapati
PDF
Deliver Python Apps with Docker
PPTX
2. auto deploy to tomcat on jenkins
PPTX
WordPress workflow of the future
PPT
Jenkins on Docker
PDF
XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS) Par Jean-...
PPTX
Session on Launching Selenium Grid and Running tests using docker compose and...
PDF
Introduction to Eclipse Che - Devoxx FR - 2017
PDF
How to convince a malware to avoid us
PDF
CodeIgniter Lab
PPT
Building an in house support team
PPTX
PHP Dependency Management with Composer
PDF
Composer for Busy Developers - php|tek13
PDF
Lightweight development (Lightning talk)
DevOps Fest 2020. Роман Орлов. Инфраструктура тестирования в Kubernetes
@arzumy Dev Setup #klxrb
JavaScript and Desktop Apps - Introduction to Electron
Learned lessons in a real world project
Jenkins auto configureforbranch-php
Session on Selenium 4 : What’s coming our way? by Hitesh Prajapati
Deliver Python Apps with Docker
2. auto deploy to tomcat on jenkins
WordPress workflow of the future
Jenkins on Docker
XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS) Par Jean-...
Session on Launching Selenium Grid and Running tests using docker compose and...
Introduction to Eclipse Che - Devoxx FR - 2017
How to convince a malware to avoid us
CodeIgniter Lab
Building an in house support team
PHP Dependency Management with Composer
Composer for Busy Developers - php|tek13
Lightweight development (Lightning talk)
Ad

Similar to Jenkins pipeline -- Gentle Introduction (20)

PDF
The Unbearable Lightness: Extending the Bash shell
ODP
NYPHP March 2009 Presentation
PPTX
510Lec01-Overview.pptx
PDF
(1) cpp introducing the_cpp_programming_language
PDF
Easy deployment & management of cloud apps
PDF
Introduction to PowerShell
PDF
Functional Programming with Streams in node.js
PDF
Developing IT infrastructures with Puppet
PDF
Sinatra: прошлое, будущее и настоящее
PDF
Operating System Lecture Notes Mit 6828 Itebooks
PDF
PyCon 2011: IronPython Command Line
PDF
BUILDING APPS WITH ASYNCIO
PDF
Python for Linux System Administration
PPT
Shell scripting - By Vu Duy Tu from eXo Platform SEA
PDF
Slackware Demystified [SELF 2011]
PDF
Bash is not a second zone citizen programming language
PDF
Container (Docker) Orchestration Tools
PDF
Porting your favourite cmdline tool to Android
DOCX
Program Assignment Process ManagementObjective This program a.docx
PPTX
The GO Language : From Beginners to Gophers
The Unbearable Lightness: Extending the Bash shell
NYPHP March 2009 Presentation
510Lec01-Overview.pptx
(1) cpp introducing the_cpp_programming_language
Easy deployment & management of cloud apps
Introduction to PowerShell
Functional Programming with Streams in node.js
Developing IT infrastructures with Puppet
Sinatra: прошлое, будущее и настоящее
Operating System Lecture Notes Mit 6828 Itebooks
PyCon 2011: IronPython Command Line
BUILDING APPS WITH ASYNCIO
Python for Linux System Administration
Shell scripting - By Vu Duy Tu from eXo Platform SEA
Slackware Demystified [SELF 2011]
Bash is not a second zone citizen programming language
Container (Docker) Orchestration Tools
Porting your favourite cmdline tool to Android
Program Assignment Process ManagementObjective This program a.docx
The GO Language : From Beginners to Gophers
Ad

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Cloud computing and distributed systems.
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Approach and Philosophy of On baking technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Empathic Computing: Creating Shared Understanding
Network Security Unit 5.pdf for BCA BBA.
Building Integrated photovoltaic BIPV_UPV.pdf
The AUB Centre for AI in Media Proposal.docx
Review of recent advances in non-invasive hemoglobin estimation
Reach Out and Touch Someone: Haptics and Empathic Computing
Cloud computing and distributed systems.
Dropbox Q2 2025 Financial Results & Investor Presentation
Understanding_Digital_Forensics_Presentation.pptx
Encapsulation_ Review paper, used for researhc scholars
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Advanced methodologies resolving dimensionality complications for autism neur...
NewMind AI Weekly Chronicles - August'25 Week I
Unlocking AI with Model Context Protocol (MCP)
MIND Revenue Release Quarter 2 2025 Press Release
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Approach and Philosophy of On baking technology

Jenkins pipeline -- Gentle Introduction

  • 3. What’s in it for me? Pipeline helps to, codify build flow divide monolithic build to logical stages bind execution of one or more stages based on previous stage’s result abstract common tasks to shared libraries Learn Groovy DSL (scripted syntax, shared libraries) Declarative syntax follows imperative model Jenkins v2.x + Pipeline suite of plugins Tons and tons of patience to toil, sweat a.k.a. R(ead), A(pply), D(ocument) and S(hare) lots and lots of Pre-requisites https://www.flickr.com/photos/87232391@N00/403119696
  • 4. Getting Started. . . Have a test Jenkins master, playground for trial and error mirror (as close as possible) production instance access to rest of infra or replicate where infra cannot be shared (e.g: artifactory, s3, build agents) mental model of what to do — logical blocks needed, how to tie them up, what can or cannot be done in parallel, archive, notifications. Tooo……ooons of material on the Internet on Jenkins Pipeline
  • 5. Bite the bullet . . . Start writing pipeline as code Start with individual stages, one stage at a time Pipeline syntax and snippet generator Pipeline script in <Version Control> => modify, build, test : repeat Better yet, Replay on the passed or failed job update on the fly, build, test But, but, no Replay for builds failed on Groovy syntax :-(
  • 6. Namaskara… #!groovy node(‘linux’) { // any build agent with label, linux;if left blank, master stage(‘Prep’) { def greet = “Welcome to Pipeline” // variable declaration echo “${greet}” sh “uname -a” def ip_address = sh(returnStdout: true, script: “ifconfig eth0 | grep -i inet | head -1 | awk -F’:’ ‘{print $2}’ | awk -F’ ‘ ‘{print $1}’”).trim() println “Node’s IP address, ip_address” } }
  • 7. Common Gotchas… Pipeline syntax errors DO NOT copy and paste from your editor or from the previous slide Most common: Typos in pipeline code Cautious with usage of Unix tools within Pipeline single, double quotes
  • 8. Got it finally… #!groovy node(‘linux’) { // build agent with label ‘linux’;if left blank, master stage("Prep") { def greet = “Welcome to Pipeline" // variable declaration echo "${greet}" sh "uname -a" sh "'/sbin/ifconfig eth0 | grep -i inet | head -1 | cut -d: -f2 | awk -F' ' '{print $1}' "' } sh step has many avatars 1. sh “command” 2. sh (returnStdout …) 3. sh (returnStatus …) 4. sh followed by three single or double quotes (for variable interpolation) Output from build console log
  • 9. useful links Online examples for various steps… wiki => https://jenkins.io/doc/pipeline/examples/ code => https://github.com/jenkinsci/pipeline-examples/tree/master/ pipeline-examples contribute your’s today, https://github.com/jenkinsci/pipeline-examples Plugins compatible with Pipeline https://github.com/jenkinsci/pipeline-plugin/blob/master/COMPATIBILITY.md Pipeline resources Syntax reference, https://jenkins.io/doc/book/pipeline/syntax Steps reference, https://jenkins.io/doc/pipeline/steps BlueOcean https://jenkins.io/doc/book/blueocean
  • 10. Handling SCM … Git Have generic service accounts, avoid storing user credentials Jenkins has built-in implementation of Git :-) But, it may not be in sync with generally available version of Git :-( Handling large Git repos in Jenkins First 10mins from Jenkins online meetup video, https://www.youtube.com/ watch?v=TsWkZLLU-s4 https://www.cloudbees.com/blog/advanced-git-jenkins General tips for handling large Git repos, https://www.atlassian.com/blog/git/handle-big-repositories-git https://larsxschneider.github.io/2016/09/21/large-git-repos