Pipeline as Code

Pipeline as Code

Introduction to the benefits which come with Jenkins 2 like Jenkinsfile and the workflow stage view plugin. #T3DD17

09677128abcb12c688ed29f2d8359fae?s=128

Peter Foerger

July 14, 2017
Tweet

Transcript

  1. pipeline as code Jenkins Pipeline dkd Internet Service GmbH TYPO3

    Developer Days 2017 1
  2. 2 agenda

  3. agenda • introduction into Jenkins (Pipeline) • Jenkins basic information

    • scaling a build infrastructure • pipelines • why should we use pipelines • pipeline advantages • syntax • best practises • demo 3
  4. 4 who`s that guy?

  5. Peter Foerger • DevOps Engineer • dkd Internet Service GmbH

    • TCCI • TCCD • @bauschan 5
  6. introduction 6

  7. why a CI server? 7

  8. continuous integration 8

  9. 9 »Continuous Integration doesn’t get rid of bugs, but it

    does make them dramatically easier to find and remove.« Martin Fowler, Chief Scientist, ThoughtWorks
  10. continuous integration 10 • code in scm • check-in and

    push at least daily • automated compiling, testing, integrating and building • reporting and code analysis • deploy to integration environment
  11. continuous delivery 11

  12. 12 »continuous delivery is the ability to get changes of

    all types–including new features, configuration changes, bug fixes and experiments–into production, or into the hands of users, safely and quickly in a sustainable way.« Jez Humble, continuousdelivery.com
  13. 13 »continuous delivery is the ability to get changes of

    all types–including new features, configuration changes, bug fixes and experiments–into production, or into the hands of users, safely and quickly in a sustainable way.« Jez Humble, continuousdelivery.com
  14. 14 »continuous delivery is the ability to get changes of

    all types–including new features, configuration changes, bug fixes and experiments–into production, or into the hands of users, safely and quickly in a sustainable way.« Jez Humble, continuousdelivery.com
  15. 15 »continuous delivery is the ability to get changes of

    all types–including new features, configuration changes, bug fixes and experiments–into production, or into the hands of users, safely and quickly in a sustainable way.« Jez Humble, continuousdelivery.com
  16. continuous delivery pipeline 16

  17. CD !== CD 17

  18. Jenkins intro 18 master • stateful • management of jobs,

    credentials, ... • plugins (always run on master) slaves • actually run the jobs • stateless
  19. scaling a build infrastructure 19 jobs = number of developers

    * 3.333 masters = number of jobs/500 executors = number of jobs * 0.03 Source: https://jenkins.io/doc/book/architecting-for-scale/
  20. new in jenkins 2 • drop-in upgrade • three major

    changes • better out-of-the-box experience • revamped UI • pipeline as code 20
  21. 21 pipelines

  22. why should we use pipelines? • developer experience • self

    contained • fully automated and documented • reusable • durable • pausable • extensible 22
  23. advantages • can be reviewed, forked, iterated upon and audited

    • running pipelines survive master restart • can stop and wait for human input • support complex CI/CD requirements • DSL can be extended through shared libraries 23
  24. usage • directly in UI • Jenkinsfile 24

  25. declarative vs. scripted • declarative: validation => better error reporting

    • declarative: better GUI support (Blue Ocean) • scripted: rapid prototyping • scripted: nearly full power of Groovy (good and bad) 25
  26. declarative pipeline { agent any stages { stage('Build') { steps

    { echo 'Building...' } } } 26
  27. scripted node { stage('Build') { echo 'Building...' } } 27

  28. 28 development tools

  29. tools • Blue Ocean editor • command-line pipeline linter •

    “Replay” feature • Pipeline Unit Testing Framework (3rd Party) 29
  30. 30 demo time

  31. show case – Blue Ocean • sophisticated visualizations of continuous

    delivery (CD) Pipelines, allowing for fast and intuitive comprehension of pipeline’s status.
 • pipeline editor makes creation of Pipelines approachable by guiding the user through an intuitive and visual process to create a Pipeline.
 • personalization to suit the role-based needs of each member of the team.
 • pinpoint precision when intervention is needed and/or issues arise. Blue Ocean shows where in the pipeline attention is needed
 • native integration for branch and pull requests enables maximum developer productivity when collaborating on code with others in GitHub and Bitbucket.
 31
  32. show case – Blue Ocean 32

  33. show case – classic • first steps • string interpolation

    • environment • build parameters • tools • artifact archival • stages 33
  34. first steps 34

  35. string interpolation def singleQuoted = 'Jenkins' def doubleQuoted = "Pipeline"

    def trippleSingleQuoted = '''dkd''' def trippleDoubleQuoted = “""dkd""" 35 only the double quoted strings support string interpolation
  36. string interpolation 36

  37. environment variables 37

  38. build parameters 38

  39. tools • maven • jdk • gradle 39

  40. tools 40

  41. artefact archival 41

  42. stages 42

  43. dkd sagt Danke 43