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.

Continuous delivery with jenkins pipelines incl. dev tools (@ Vienna DevOps & Security Meetup)

310 views

Published on

Presentation at Vienna DevOps & Security Meetup 14.06.2017:
Scripted Jenkins Pipelines - everyone knows and loves them. However, on this day, Roman Pickl (Fluidtime) will show us the new Syntax: Declarative Pipelines! A hint for the insiders: The presentation will be in ocean blue!

Published in: Software
  • Be the first to comment

Continuous delivery with jenkins pipelines incl. dev tools (@ Vienna DevOps & Security Meetup)

  1. 1. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Con4nuous Delivery with Jenkins Pipelines (incl. Advanced Topics) Roman Pickl
  2. 2. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com •  10+ years’ experience in integra4ng transport systems •  22 mobility Apps in the stores •  43+ million requests / month •  500.000+ unique users / month At a glance qando Vienna, Linz, Graz, Salzburg, Klagenfurt. SMILE Lighthouse project for integrated mobility Wien Mobil Lab Vienna FluidHub Powering the Integrated Mobility and MaaS Ecosystem 2009 avv connect Aachen Region, North Rhine-Westphalia. 2014 NUMO Vienna 2012 2015 2016
  3. 3. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com How did I end up here? •  Roman Pickl (@rompic) •  CTO @ Fluid4me •  In charge of the technical development •  Uses Jenkins since 2012 •  Loves CI/CD/DevOps •  Here to learn
  4. 4. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Con4nuous Delivery (CD) Automated implementa4on of your system‘s build, deploy, test, release process •  Every change results in a build •  Every build is a release candidate •  Delivery can be done at any 4me, on any environment à Make releases a non-event Deployment Pipeline provides: •  Visibility •  Feedback •  Control Read these books! Jez Humble on Con4nuous Delivery(2012): hgps://www.youtube.com/watch?v=skLJuksCRTw
  5. 5. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Deployment Pipelines (Let’s build it with jenkins) (Jez Humble D. F., Con4nuous Delivery: Reliable Sojware Releases Through Build, Test, and Deployment Automa4on, 2010)
  6. 6. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Jenkins #1 Con4nuous Integra4on and Delivery server •  Created by Kohsuke Kawaguchi •  Ini4al Release 2005 (Hudson) •  Open Source (MIT License) •  Ac4ve and independent community (hgps://jenkins.io) •  100,000 ac4ve installa4ons •  300,000 Jenkins servers •  1,200+ plugins (!) •  Since 2.0 Pipelines (April 2016) are first class ci4zens •  Pipeline as Code (Jenkinsfile) •  New User Experience “Blue Ocean” 1.0 released in April •  BlueOcean Pipeline Editor Plugin (0.2.0) hgp://dduportal.github.io/presenta4ons/mixit-2017-jenkins-pipeline/slides.html#/meet_jenkins hgps://jenkins.io/blog/2017/04/05/say-hello-blueocean-1-0/
  7. 7. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Jenkinsfile Wrigen in a Groovy DSL “Jenkinsfile” in top level folder (different path possible since June 2017 hgps://issues.jenkins-ci.org/browse/ JENKINS-34561) Store in SCM (e.g. GIT) for addi4onal benefits •  Code review/itera4on •  Audit trail •  Single source of truth Supports two syntaxes (can be mixed) •  Declara4ve pipelines (easier; new since 2.5) •  Scripted pipelines (more powerful) hgps://jenkins.io/doc/book/pipeline/jenkinsfile/
  8. 8. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Scripted vs. Declara4ve Scripted Pipelines: Declara4ve Pipeline: hgps://jenkins.io/doc/book/pipeline/syntax/
  9. 9. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Scripted vs. Declara4ve Scripted Pipeline: Declara4ve Pipeline: hgps://jenkins.io/doc/book/pipeline/syntax/ •  impera4ve programming model •  fully featured programming environment, •  higher flexibility and extensibility •  very few limits => for power-users and more complex requirements •  declara4ve programming model •  simpler and more opinionated syntax for authoring Jenkins Pipeline. •  limits what is available to the user => ideal choice for simpler con4nuous delivery pipelines Both: •  use Groovy •  same Pipeline sub-system underneath •  mostly use same steps •  able to u4lize Shared Libraries => can be mixed using the script step See hgps://jenkins.io/blog/2017/01/19/conver4ng-condi4onal-to-pipeline/ for a more complex example of migra4ng a freestyle job to a declara4ve/scripted pipeline.
  10. 10. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com script Step •  takes a block of Scripted Pipeline & executes that in the Declara4ve Pipeline •  can provide a useful "escape hatch". •  script blocks of non-trivial size and/or complexity should be moved into Shared Libraries hgps://jenkins.io/doc/book/pipeline/syntax/
  11. 11. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Seyngs
  12. 12. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Stages
  13. 13. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Parallel Execu4on
  14. 14. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Approval ... Deploy to Stage, Deploy Live, Release omiUed here
  15. 15. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Post Build No4fica4ons
  16. 16. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Demo 1.  docker run -p 8080:8080 jenkinsci/blueocean (add –p 44444:44444 or any other port to try the ssh linter) 2.  Go to hgp://localhost:8080/ 3.  Unlock jenkins with ini4alpw from log file 4.  Install suggested plugins (you may have to con4nue the broken process and update plugins later on) 5.  Create admin user / or con4nue with admin and initalpw 6.  Open hgp://localhost:8080/blue/pipelines 7.  Generate new Pipeline with Github repository 8.  Create Jenkinsfile (e.g. hgps://github.com/rompic/jenkinspipeline)
  17. 17. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Blue Ocean 1.1 released 12.06.2017 •  Fast search •  Trigger reasons •  Blockage reasons •  History jump •  Analyse 1,000s of tests •  Custom run names and descripKons •  Performance •  48+ bug fixes hRps://jenkins.io/blog/2017/06/13/blueocean-1-1/ New public roadmap hRps://jenkins.io/projects/blueocean/roadmap/
  18. 18. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Overview
  19. 19. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Approval
  20. 20. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Detail
  21. 21. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Pipeline Development and Advanced Tools •  Blue Ocean Pipeline Editor •  Snippet Generator •  IntelliJ IDEA GDSL – Autocomplete •  Command-line Pipeline Linter •  Replay Feature •  Unit Tes4ng Jenkins Pipelines •  Shared Libaries hgps://jenkins.io/doc/book/pipeline/development/ hgps://jenkins.io/doc/book/pipeline/shared-libraries/
  22. 22. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Pipeline Editor (beta) Currently only for GITHUB (GIT coming! hgps://issues.jenkins-ci.org/browse/JENKINS-43148) Workaround: hgp://localhost:8080/blue/organiza4ons/jenkins/pipeline-editor/ Ctrl-S / Cmd-S to open the load save dialog
  23. 23. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Snippet generator hgp://localhost:8080/pipeline-syntax hgps://jenkins.io/doc/book/pipeline/geyng-started/#snippet-generator
  24. 24. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com IntelliJ IDEA GDSL - Autocomplete •  Autocomple4on of steps for scripted pipelines •  Install Groovy Plugin •  Download hgp://localhost:8080/pipeline-syntax/gdsl •  Add it as e.g. pipeline.gdsl to your projects src path See hgps://st-g.de/2016/08/jenkins-pipeline-autocomple4on-in-intellij hgps://stackoverflow.com/ques4ons/41062514/use-gdsl-file-in-a-java-project-in-intellij hgps://stackoverflow.com/a/41149255/3165782 for seyng it up.
  25. 25. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Command-line Pipeline Linter Validate Declara4ve Pipelines from the cli before actually running it/checking it in. See hgps://jenkins.io/doc/book/pipeline/development/#linter for details. Remember to enable SSH access, expose a port on your docker container and add ssh key to try this!
  26. 26. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Replay Feature •  Allows for quick modifica4ons and execu4on of an exis4ng (valid) Pipeline without changing the Pipeline configura4on or crea4ng a new commit. •  Once you are sa4sfied with the changes, you can use Replay to view them again, copy them back to your Pipeline job or Jenkinsfile, and then commit them using your usual engineering processes hgps://jenkins.io/doc/book/pipeline/development/
  27. 27. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Shared Libraries Share parts of Pipelines between various projects to reduce redundancies and keep code "DRY“. Func4ons can than be called from Jenkinsfiles. See hgps://jenkins.io/doc/book/pipeline/ shared-libraries/ for more details.
  28. 28. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Unit Tes4ng Jenkins Pipelines •  Allows to unit test Pipelines and Shared Libraries before running them in full •  Provides a mock execu4on environment that can be used to check for expected behavior •  S4ll quite rough around the edges. (e.g. no support for declara4ve pipeline yet hgps://github.com/lesfurets/JenkinsPipelineUnit/pull/13) See: hgps://github.com/lesfurets/JenkinsPipelineUnit hgps://github.com/lesfurets/JenkinsPipelineUnit/blob/master/README.md hgps://issues.jenkins-ci.org/browse/JENKINS-33925
  29. 29. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Website: hgps://jenkins.io Blog: hgps://jenkins.io/node/ hgps://www.slideshare.net/legrimpeur/belgium-jenkins-area-meetup-jenkins-blueocean- and-declara4ve-pipelines Geyng Started hgps://jenkins.io/doc/book/geyng-started/ hgps://jenkins.io/doc/book/pipeline/syntax/ hgps://jenkins.io/doc/pipeline/steps/ hgps://jenkins.io/doc/book/blueocean/geyng-started/ hgps://github.com/jenkinsci/pipeline-model-defini4on-plugin/wiki/geyng%20started hgps://jenkins.io/blog/2017/05/18/pipeline-dev-tools/ Further references & informa4on I
  30. 30. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Docker Files: hgps://github.com/jenkinsci/docker/blob/master/README.md hgps://hub.docker.com/r/jenkinsci/blueocean/ Further references & informa4on II
  31. 31. © 2017 Copyright Fluid4me Data Services GmbH | www.fluid4me.com Contact Roman Pickl (@rompic) roman.pickl@fluid4me.com Fluid4me Data Services GmbH Neubaugasse 12-14/25 A–1070 Wien Tel +43 (0)1 5860 180 www.fluid4me.com

×