Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pipeline as Code

Pipeline as Code

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

Peter Foerger

July 14, 2017
Tweet

More Decks by Peter Foerger

Other Decks in Technology

Transcript

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

    View Slide

  2. 2
    agenda

    View Slide

  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

    View Slide

  4. 4
    who`s that guy?

    View Slide

  5. Peter Foerger
    • DevOps Engineer
    • dkd Internet Service GmbH
    • TCCI
    • TCCD
    • @bauschan
    5

    View Slide

  6. introduction
    6

    View Slide

  7. why a CI server?
    7

    View Slide

  8. continuous integration
    8

    View Slide

  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

    View Slide

  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

    View Slide

  11. continuous delivery
    11

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  16. continuous delivery pipeline
    16

    View Slide

  17. CD !== CD
    17

    View Slide

  18. Jenkins intro
    18
    master
    • stateful
    • management of jobs, credentials, ...
    • plugins (always run on master)
    slaves
    • actually run the jobs
    • stateless

    View Slide

  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/

    View Slide

  20. new in jenkins 2
    • drop-in upgrade
    • three major changes
    • better out-of-the-box experience
    • revamped UI
    • pipeline as code
    20

    View Slide

  21. 21
    pipelines

    View Slide

  22. why should we use pipelines?
    • developer experience
    • self contained
    • fully automated and documented
    • reusable
    • durable
    • pausable
    • extensible
    22

    View Slide

  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

    View Slide

  24. usage
    • directly in UI
    • Jenkinsfile
    24

    View Slide

  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

    View Slide

  26. declarative
    pipeline {
    agent any
    stages {
    stage('Build') {
    steps {
    echo 'Building...'
    }
    }
    }
    26

    View Slide

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

    View Slide

  28. 28
    development tools

    View Slide

  29. tools
    • Blue Ocean editor
    • command-line pipeline linter
    • “Replay” feature
    • Pipeline Unit Testing Framework (3rd Party)
    29

    View Slide

  30. 30
    demo time

    View Slide

  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

    View Slide

  32. show case – Blue Ocean
    32

    View Slide

  33. show case – classic
    • first steps
    • string interpolation
    • environment
    • build parameters
    • tools
    • artifact archival
    • stages
    33

    View Slide

  34. first steps
    34

    View Slide

  35. string interpolation
    def singleQuoted = 'Jenkins'
    def doubleQuoted = "Pipeline"
    def trippleSingleQuoted = '''dkd'''
    def trippleDoubleQuoted = “""dkd"""
    35
    only the double quoted strings support string interpolation

    View Slide

  36. string interpolation
    36

    View Slide

  37. environment variables
    37

    View Slide

  38. build parameters
    38

    View Slide

  39. tools
    • maven
    • jdk
    • gradle
    39

    View Slide

  40. tools
    40

    View Slide

  41. artefact archival
    41

    View Slide

  42. stages
    42

    View Slide

  43. dkd sagt Danke
    43

    View Slide