Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
What to Upload to SlideShare
Next
Download to read offline and view in fullscreen.

2

Share

Download to read offline

Jenkins pipeline -- Gentle Introduction

Download to read offline

Slide deck presented by Ramanathan.M at the Bengaluru DevOps meetup on 19/Aug/2017

Related Books

Free with a 30 day trial from Scribd

See all

Jenkins pipeline -- Gentle Introduction

  1. 1. https://www.flickr.com/photos/amerune/9294639633/in/photostream/ Jenkins Pipelines
  2. 2. Ramanathan Muthaiah, rus.cahimb@gmail.com DevOps Meetup, Bengaluru, 19/Aug/2017
  3. 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. 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. 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. 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. 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. 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. 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. 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
  • AnanthCB

    Aug. 21, 2017
  • taroshun

    Aug. 21, 2017

Slide deck presented by Ramanathan.M at the Bengaluru DevOps meetup on 19/Aug/2017

Views

Total views

400

On Slideshare

0

From embeds

0

Number of embeds

1

Actions

Downloads

9

Shares

0

Comments

0

Likes

2

×