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

Continuous Deployment in 3 hours

Continuous Deployment in 3 hours

Mike van Riel

October 11, 2013
Tweet

More Decks by Mike van Riel

Other Decks in Technology

Transcript

  1. Continuous Deployment
    in 3 hours
    Mike van Riel
    Mike van Riel · @mvriel

    View full-size slide

  2. About me

    Lead Developer of
    phpDocumentor

    Software Composer
    at Ingewikkeld

    Foster father of 2
    happy dogs

    11 years of
    experience with PHP

    View full-size slide

  3. What is Continuous Deployment,
    and what is Continuous Delivery?

    View full-size slide

  4. The rules
    Mike van Riel

    View full-size slide

  5. Feedback
    Feedback
    Feedback

    View full-size slide

  6. Versioning is
    key

    View full-size slide

  7. Build your artifacts
    once

    View full-size slide

  8. one
    deployment process for all
    environments

    View full-size slide

  9. Versioning
    Mike van Riel

    View full-size slide

  10. Your Code, Configuration
    and Environment must be
    in Version Control

    View full-size slide

  11. “To branch, or not to branch.
    That is the question.”
    - Bill Shakespeare*

    View full-size slide

  12. Concepts
    Mike van Riel

    View full-size slide

  13. Environments

    View full-size slide

  14. Deployment Pipeline

    View full-size slide

  15. Deployment Pipeline - optimized

    View full-size slide

  16. Config flags

    Toggles features on and off

    Allows a team to continuously integrate

    Can be used for Canary testing

    Provides a rollback in case of flawed
    functionality

    View full-size slide

  17. Aids
    Mike van Riel

    View full-size slide

  18. Continuous Integration Servers
    Jenkins TeamCity Thoughtworks
    Go

    View full-size slide

  19. Analysis tools

    PHPUnit

    Behat

    PhpDocumentor

    PHP_CodeSniffer

    PHP_Depend

    PHP_PMD

    phploc

    phpcpd

    View full-size slide

  20. Build and deployment tools

    Phing

    Ant

    Make

    Capistrano

    Webistrano

    Deployinator

    Maven

    View full-size slide

  21. More feedback

    Logstash

    Graphite

    Nagios

    View full-size slide

  22. Exercises
    Mike van Riel

    View full-size slide

  23. Environment

    Ubuntu 12.04

    Apache

    MySQL

    PHP 5.3

    XDebug

    One vhost
    – dev.www.blog.com

    Packages
    – Git
    – Augeas-tools
    – Libaugeas-dev
    – Libaugeas-ruby
    – Jenkins

    View full-size slide

  24. Exercise 1
    Determine your workflow

    View full-size slide

  25. Goal

    Think before you start

    Determine your process and workflow

    Does your current flow match with
    Continuous Deployment

    View full-size slide

  26. Think about the following

    Versioning your application

    Versioning your environment

    Version numbering

    Which tools to use

    How to react on a build failure

    View full-size slide

  27. Versioning

    Master/trunk should always be deployable

    Any change in master / trunk should result in
    a release candidate

    Release branches, develop mainlines and
    other constructs do not play a role with
    Continuous Deployment
    – There are exceptions

    View full-size slide

  28. Exercise 2
    Planning your deployment pipeline

    View full-size slide

  29. Goal

    Determine how to start automating your build
    and deployment process

    Review your deployment strategy

    Automate your deployment process using
    phing

    View full-size slide

  30. Stages

    Commit stage
    – Pull changes
    – Clean workspace
    – Initialize workspace
    – Run unit tests

    Deploy stage
    – Upload your
    application
    – Switch symlink

    View full-size slide

  31. Deployment strategy

    Have a symlink representing your current
    release

    Upload your new release to a separate folder

    Integrate configuration in the new folder

    Create symlink of the new release

    Move the symlink of the new release over the
    current using `mv -Tf`

    View full-size slide

  32. Exercise 3
    Apply Continuous Integration

    View full-size slide

  33. Goal

    Update jenkins and add phing plugin

    Setup a job in Jenkins

    Add deployment as a post-build action

    Execute our first automated build and
    deployment

    View full-size slide

  34. Update Jenkins
    $ wget ­q ­O ­
    http://pkg.jenkins­ci.org/debian­stable/jenkins­ci.org.ke
    y | sudo apt­key add ­
    Add to /etc/apt/sources/list:
    deb http://pkg.jenkins­ci.org/debian­stable binary/
    And run:
    $ sudo apt­get update
    $ sudo apt­get install jenkins

    View full-size slide

  35. Install phing plugin
    $ java ­jar jenkins­cli.jar ­s
    http://localhost:8080 install­plugin checkstyle
    cloverphp dry htmlpublisher jdepend plot pmd
    violations xunit git clone­workspace­scm
    build­pipeline­plugin
    $ java ­jar
    /vagrant/puppet/manifests/jenkins­cli.jar ­s
    http://localhost:8080 install­plugin phing
    credentials

    View full-size slide

  36. Exercise 4
    Adding support for environments
    using parameters

    View full-size slide

  37. Goal

    Extract all variable deployment options into
    parameters

    Learn how to switch between environments

    View full-size slide

  38. Exercise 5
    Adding a staging environment

    View full-size slide

  39. Goal

    Add a new staging environment to puppet

    Change our deployment action to deploy to
    staging instead of production
    – using the changes of last exercise

    View full-size slide

  40. Exercise 6
    Switching to Continuous Delivery

    View full-size slide

  41. Goal

    Add a new view for our project

    Add a new deploy job

    Persist workspace between jobs

    Try out our new process

    View full-size slide

  42. Adding a new Deploy job

    Add a new job `blog-deploy`

    Configure `blog` job to archive the build

    Configure `blog-deploy` job to use the
    archived build

    View full-size slide

  43. Exercise 7
    Adding a UAT stage

    View full-size slide

  44. Goal

    Create a Behat test

    Alter our build file and add a UAT stage

    Add a new UAT job

    Persist workspace between jobs

    Automatically trigger UAT job after `blog` job

    Move deployment to staging from `blog` to UAT job

    Test our new process

    View full-size slide

  45. UAT Stage

    May run longer than 5 minutes

    Can trigger a deployment to staging for
    exploratory testing

    Automate!

    View full-size slide

  46. Bonus exercise 1
    Using the pipeline plugin

    View full-size slide

  47. Goal

    Use the pipeline plugin to create a new view
    with your process

    Walk through your process

    View full-size slide

  48. Questions?
    Please leave feedback on Joind.in, I'd appreciate it.

    View full-size slide

  49. Credits

    http://www.flickr.com/photos/joebenjamin/5009411920/

    http://en.wikipedia.org/wiki/Continuous_delivery

    http://www.flickr.com/photos/robertlemke/4383863479

    http://continuousdelivery.com/2010/09/deployment-pipeline-
    anti-patterns/

    View full-size slide