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 full-size slide

  2. 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 full-size slide

  3. 4
    who`s that guy?

    View full-size slide

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

    View full-size slide

  5. introduction
    6

    View full-size slide

  6. why a CI server?
    7

    View full-size slide

  7. continuous integration
    8

    View full-size slide

  8. 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 full-size slide

  9. 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 full-size slide

  10. continuous delivery
    11

    View full-size slide

  11. 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 full-size slide

  12. 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 full-size slide

  13. 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 full-size slide

  14. 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 full-size slide

  15. continuous delivery pipeline
    16

    View full-size slide

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

    View full-size slide

  17. 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 full-size slide

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

    View full-size slide

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

    View full-size slide

  20. 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 full-size slide

  21. usage
    • directly in UI
    • Jenkinsfile
    24

    View full-size slide

  22. 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 full-size slide

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

    View full-size slide

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

    View full-size slide

  25. 28
    development tools

    View full-size slide

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

    View full-size slide

  27. 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 full-size slide

  28. show case – Blue Ocean
    32

    View full-size slide

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

    View full-size slide

  30. first steps
    34

    View full-size slide

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

    View full-size slide

  32. string interpolation
    36

    View full-size slide

  33. environment variables
    37

    View full-size slide

  34. build parameters
    38

    View full-size slide

  35. tools
    • maven
    • jdk
    • gradle
    39

    View full-size slide

  36. artefact archival
    41

    View full-size slide

  37. dkd sagt Danke
    43

    View full-size slide