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 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 Slide

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

    View Slide

  4. View Slide

  5. The rules
    Mike van Riel

    View Slide

  6. Feedback
    Feedback
    Feedback

    View Slide

  7. Versioning is
    key

    View Slide

  8. Build your artifacts
    once

    View Slide

  9. View Slide

  10. one
    deployment process for all
    environments

    View Slide

  11. Versioning
    Mike van Riel

    View Slide

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

    View Slide

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

    View Slide

  14. Concepts
    Mike van Riel

    View Slide

  15. Environments

    View Slide

  16. Deployment Pipeline

    View Slide

  17. Deployment Pipeline - optimized

    View Slide

  18. 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 Slide

  19. Aids
    Mike van Riel

    View Slide

  20. Continuous Integration Servers
    Jenkins TeamCity Thoughtworks
    Go

    View Slide

  21. Analysis tools

    PHPUnit

    Behat

    PhpDocumentor

    PHP_CodeSniffer

    PHP_Depend

    PHP_PMD

    phploc

    phpcpd

    View Slide

  22. Build and deployment tools

    Phing

    Ant

    Make

    Capistrano

    Webistrano

    Deployinator

    Maven

    View Slide

  23. More feedback

    Logstash

    Graphite

    Nagios

    View Slide

  24. Exercises
    Mike van Riel

    View Slide

  25. 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 Slide

  26. Exercise 1
    Determine your workflow

    View Slide

  27. Goal

    Think before you start

    Determine your process and workflow

    Does your current flow match with
    Continuous Deployment

    View Slide

  28. Think about the following

    Versioning your application

    Versioning your environment

    Version numbering

    Which tools to use

    How to react on a build failure

    View Slide

  29. 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 Slide

  30. Exercise 2
    Planning your deployment pipeline

    View Slide

  31. Goal

    Determine how to start automating your build
    and deployment process

    Review your deployment strategy

    Automate your deployment process using
    phing

    View Slide

  32. Stages

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

    Deploy stage
    – Upload your
    application
    – Switch symlink

    View Slide

  33. 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 Slide

  34. Exercise 3
    Apply Continuous Integration

    View Slide

  35. 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 Slide

  36. 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 Slide

  37. 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 Slide

  38. Exercise 4
    Adding support for environments
    using parameters

    View Slide

  39. Goal

    Extract all variable deployment options into
    parameters

    Learn how to switch between environments

    View Slide

  40. Exercise 5
    Adding a staging environment

    View Slide

  41. 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 Slide

  42. Exercise 6
    Switching to Continuous Delivery

    View Slide

  43. Goal

    Add a new view for our project

    Add a new deploy job

    Persist workspace between jobs

    Try out our new process

    View Slide

  44. 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 Slide

  45. Exercise 7
    Adding a UAT stage

    View Slide

  46. 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 Slide

  47. UAT Stage

    May run longer than 5 minutes

    Can trigger a deployment to staging for
    exploratory testing

    Automate!

    View Slide

  48. Bonus exercise 1
    Using the pipeline plugin

    View Slide

  49. Goal

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

    Walk through your process

    View Slide

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

    View Slide

  51. 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 Slide