Setting up a Continuous Delivery environment in 3 hours #zceu

Ba4801d2cbcf2e649f3aedbfcbfb3c36?s=47 Mike van Riel
November 18, 2013

Setting up a Continuous Delivery environment in 3 hours #zceu

The workshop slides for the talk 'Setting up a Continuous Delivery environment in 3 hours' at ZendCon Europe 2013

Ba4801d2cbcf2e649f3aedbfcbfb3c36?s=128

Mike van Riel

November 18, 2013
Tweet

Transcript

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

    Riel · @mvriel
  2. https://joind.in/9283 About me • I am Mike van Riel 

    @mvriel
  3. https://joind.in/9283 About me • I am Mike van Riel •

    Lead Developer for phpDocumentor
  4. https://joind.in/9283 About me • I am Mike van Riel •

    Lead Developer for phpDocumentor • Software Composer at Ingewikkeld
  5. https://joind.in/9283 About me • I am Mike van Riel •

    Lead Developer for phpDocumentor • Software Composer at Ingewikkeld • Foster father of two cute dogs
  6. https://joind.in/9283 What is Continuous Deployment, and what is Continuous Delivery?

  7. https://joind.in/9283

  8. https://joind.in/9283 The rules Mike van Riel

  9. https://joind.in/9283 Feedback Feedback Feedback

  10. https://joind.in/9283 Versioning is key

  11. https://joind.in/9283 Build your artifacts once

  12. https://joind.in/9283

  13. https://joind.in/9283 one deployment process to rule them all Environments

  14. https://joind.in/9283 Feedback Mike van Riel

  15. https://joind.in/9283

  16. https://joind.in/9283 Versioning Mike van Riel

  17. https://joind.in/9283 Your Code, Configuration and Environment must be in Version

    Control
  18. https://joind.in/9283 “To branch, or not to branch. That is the

    question.” - Bill Shakespeare*
  19. https://joind.in/9283 Concepts Mike van Riel

  20. https://joind.in/9283 Environments

  21. https://joind.in/9283 Deployment Pipeline

  22. https://joind.in/9283 Deployment Pipeline - optimized

  23. https://joind.in/9283 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
  24. https://joind.in/9283 Aids Mike van Riel

  25. https://joind.in/9283 Continuous Integration Servers Jenkins TeamCity Thoughtworks Go

  26. https://joind.in/9283 Analysis tools • PHPUnit • Behat • phpDocumentor •

    PHP_CodeSniffer • PHP_Depend • PHP_PMD • phploc • phpcpd
  27. https://joind.in/9283 Build and deployment tools • Phing • Ant •

    Make • Capistrano • Webistrano • Deployinator • Maven
  28. https://joind.in/9283 More feedback • Logstash • Graphite • Nagios

  29. https://joind.in/9283 Exercises Mike van Riel

  30. https://joind.in/9283 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
  31. https://joind.in/9283 Exercise 1 Determine your workflow

  32. https://joind.in/9283 Goal • Think before you start • Determine your

    process and workflow • Does your current flow match with Continuous Deployment
  33. https://joind.in/9283 Think about the following • Versioning your application •

    Versioning your environment • Version numbering • Which tools to use • How to react on a build failure
  34. https://joind.in/9283 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
  35. https://joind.in/9283 Exercise 2 Planning your deployment pipeline

  36. https://joind.in/9283 Goal • Determine how to start automating your build

    and deployment process • Review your deployment strategy • Automate your deployment process using phing
  37. https://joind.in/9283 Stages • Commit stage – Pull changes – Clean

    workspace – Initialize workspace – Run unit tests • Deploy stage – Upload your application – Switch symlink
  38. https://joind.in/9283 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`
  39. https://joind.in/9283 Exercise 3 Apply Continuous Integration

  40. https://joind.in/9283 Goal • Setup a job in Jenkins • Add

    deployment as a post-build action • Execute our first automated build and deployment
  41. https://joind.in/9283 Exercise 4 Adding support for environments using parameters

  42. https://joind.in/9283 Goal • Extract all variable deployment options into parameters

    • Learn how to switch between environments
  43. https://joind.in/9283 Exercise 5 Adding a staging environment

  44. https://joind.in/9283 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
  45. https://joind.in/9283 Exercise 6 Switching to Continuous Delivery

  46. https://joind.in/9283 Goal • Add a new view for our project

    • Add a new deploy job • Persist workspace between jobs • Try out our new process
  47. https://joind.in/9283 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
  48. https://joind.in/9283 Exercise 7 Adding a UAT stage

  49. https://joind.in/9283 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
  50. https://joind.in/9283 UAT Stage • May run longer than 5 minutes

    • Can trigger a deployment to staging for exploratory testing • Automate!
  51. https://joind.in/9283 Bonus exercise 1 Using the pipeline plugin

  52. https://joind.in/9283 Goal • Use the pipeline plugin to create a

    new view with your process • Walk through your process
  53. https://joind.in/9283 Questions? Please leave feedback on Joind.in, I'd appreciate it.

  54. https://joind.in/9283 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/ •
  55. https://joind.in/9283 Continuous Deployment in 3 hours Mike van Riel Mike

    van Riel · @mvriel
  56. https://joind.in/9283 About me • I am Mike van Riel 

    @mvriel
  57. https://joind.in/9283 About me • I am Mike van Riel •

    Lead Developer for phpDocumentor
  58. https://joind.in/9283 About me • I am Mike van Riel •

    Lead Developer for phpDocumentor • Software Composer at Ingewikkeld
  59. https://joind.in/9283 About me • I am Mike van Riel •

    Lead Developer for phpDocumentor • Software Composer at Ingewikkeld • Foster father of two cute dogs
  60. https://joind.in/9283 What is Continuous Deployment, and what is Continuous Delivery?

  61. https://joind.in/9283

  62. https://joind.in/9283 The rules Mike van Riel

  63. https://joind.in/9283 Feedback Feedback Feedback

  64. https://joind.in/9283 Versioning is key

  65. https://joind.in/9283 Build your artifacts once

  66. https://joind.in/9283

  67. https://joind.in/9283 one deployment process for all environments

  68. https://joind.in/9283 Versioning Mike van Riel

  69. https://joind.in/9283 Your Code, Configuration and Environment must be in Version

    Control
  70. https://joind.in/9283 “To branch, or not to branch. That is the

    question.” - Bill Shakespeare*
  71. https://joind.in/9283 Concepts Mike van Riel

  72. https://joind.in/9283 Environments

  73. https://joind.in/9283 Deployment Pipeline

  74. https://joind.in/9283 Deployment Pipeline - optimized

  75. https://joind.in/9283 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
  76. https://joind.in/9283 Aids Mike van Riel

  77. https://joind.in/9283 Continuous Integration Servers Jenkins TeamCity Thoughtworks Go

  78. https://joind.in/9283 Analysis tools • PHPUnit • Behat • phpDocumentor •

    PHP_CodeSniffer • PHP_Depend • PHP_PMD • phploc • phpcpd
  79. https://joind.in/9283 Build and deployment tools • Phing • Ant •

    Make • Capistrano • Webistrano • Deployinator • Maven
  80. https://joind.in/9283 More feedback • Logstash • Graphite • Nagios

  81. https://joind.in/9283 Exercises Mike van Riel

  82. https://joind.in/9283 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
  83. https://joind.in/9283 The Project - Blog • URL: http://dev.www.blog.com/index.php/blog/ • Jenkins:

    http://dev.www.blog.com:8080 • Path: /vagrant/app • Git: file:///vagrant/app
  84. https://joind.in/9283 Exercise 1 Determine your workflow

  85. https://joind.in/9283 Goal • Think before you start • Determine your

    process and workflow • Does your current flow match with Continuous Deployment
  86. https://joind.in/9283 Think about the following • Versioning your application •

    Versioning your environment • Version numbering • Which tools to use • How to react on a build failure
  87. https://joind.in/9283 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
  88. https://joind.in/9283 Exercise 2 Planning your deployment pipeline

  89. https://joind.in/9283 Goal • Determine how to start automating your build

    and deployment process • Review your deployment strategy • Automate your deployment process using phing
  90. https://joind.in/9283 Stages • Commit stage – Pull changes – Clean

    workspace – Initialize workspace – Run unit tests • Deploy stage – Upload your application – Switch symlink
  91. https://joind.in/9283 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`
  92. https://joind.in/9283 Exercise 3 Apply Continuous Integration

  93. https://joind.in/9283 Goal • Setup a job in Jenkins • Add

    deployment as a post-build action • Execute our first automated build and deployment
  94. https://joind.in/9283 Exercise 4 Adding support for environments using parameters

  95. https://joind.in/9283 Goal • Extract all variable deployment options into parameters

    • Learn how to switch between environments
  96. https://joind.in/9283 Exercise 5 Adding a staging environment

  97. https://joind.in/9283 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
  98. https://joind.in/9283 Exercise 6 Switching to Continuous Delivery

  99. https://joind.in/9283 Goal • Add a new view for our project

    • Add a new deploy job • Persist workspace between jobs • Try out our new process
  100. https://joind.in/9283 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
  101. https://joind.in/9283 Exercise 7 Adding a UAT stage

  102. https://joind.in/9283 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
  103. https://joind.in/9283 UAT Stage • May run longer than 5 minutes

    • Can trigger a deployment to staging for exploratory testing • Automate!
  104. https://joind.in/9283 Bonus exercise 1 Using the pipeline plugin

  105. https://joind.in/9283 Goal • Use the pipeline plugin to create a

    new view with your process • Walk through your process
  106. https://joind.in/9283 Questions? Please leave feedback on Joind.in, I'd appreciate it.

  107. https://joind.in/9283 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/ •