Continuous Deployment in 3 hours

Continuous Deployment in 3 hours

Ba4801d2cbcf2e649f3aedbfcbfb3c36?s=128

Mike van Riel

October 11, 2013
Tweet

Transcript

  1. Continuous Deployment in 3 hours Mike van Riel Mike van

    Riel · @mvriel
  2. About me • Lead Developer of phpDocumentor • Software Composer

    at Ingewikkeld • Foster father of 2 happy dogs • 11 years of experience with PHP
  3. What is Continuous Deployment, and what is Continuous Delivery?

  4. None
  5. The rules Mike van Riel

  6. Feedback Feedback Feedback

  7. Versioning is key

  8. Build your artifacts once

  9. None
  10. one deployment process for all environments

  11. Versioning Mike van Riel

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

  13. “To branch, or not to branch. That is the question.”

    - Bill Shakespeare*
  14. Concepts Mike van Riel

  15. Environments

  16. Deployment Pipeline

  17. Deployment Pipeline - optimized

  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
  19. Aids Mike van Riel

  20. Continuous Integration Servers Jenkins TeamCity Thoughtworks Go

  21. Analysis tools • PHPUnit • Behat • PhpDocumentor • PHP_CodeSniffer

    • PHP_Depend • PHP_PMD • phploc • phpcpd
  22. Build and deployment tools • Phing • Ant • Make

    • Capistrano • Webistrano • Deployinator • Maven
  23. More feedback • Logstash • Graphite • Nagios

  24. Exercises Mike van Riel

  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
  26. Exercise 1 Determine your workflow

  27. Goal • Think before you start • Determine your process

    and workflow • Does your current flow match with Continuous Deployment
  28. Think about the following • Versioning your application • Versioning

    your environment • Version numbering • Which tools to use • How to react on a build failure
  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
  30. Exercise 2 Planning your deployment pipeline

  31. Goal • Determine how to start automating your build and

    deployment process • Review your deployment strategy • Automate your deployment process using phing
  32. Stages • Commit stage – Pull changes – Clean workspace

    – Initialize workspace – Run unit tests • Deploy stage – Upload your application – Switch symlink
  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`
  34. Exercise 3 Apply Continuous Integration

  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
  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
  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
  38. Exercise 4 Adding support for environments using parameters

  39. Goal • Extract all variable deployment options into parameters •

    Learn how to switch between environments
  40. Exercise 5 Adding a staging environment

  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
  42. Exercise 6 Switching to Continuous Delivery

  43. Goal • Add a new view for our project •

    Add a new deploy job • Persist workspace between jobs • Try out our new process
  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
  45. Exercise 7 Adding a UAT stage

  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
  47. UAT Stage • May run longer than 5 minutes •

    Can trigger a deployment to staging for exploratory testing • Automate!
  48. Bonus exercise 1 Using the pipeline plugin

  49. Goal • Use the pipeline plugin to create a new

    view with your process • Walk through your process
  50. Questions? Please leave feedback on Joind.in, I'd appreciate it.

  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/