Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

About me ● Lead Developer of phpDocumentor ● Software Composer at Ingewikkeld ● Foster father of 2 happy dogs ● 11 years of experience with PHP

Slide 3

Slide 3 text

What is Continuous Deployment, and what is Continuous Delivery?

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

The rules Mike van Riel

Slide 6

Slide 6 text

Feedback Feedback Feedback

Slide 7

Slide 7 text

Versioning is key

Slide 8

Slide 8 text

Build your artifacts once

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

one deployment process for all environments

Slide 11

Slide 11 text

Versioning Mike van Riel

Slide 12

Slide 12 text

Your Code, Configuration and Environment must be in Version Control

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

Concepts Mike van Riel

Slide 15

Slide 15 text

Environments

Slide 16

Slide 16 text

Deployment Pipeline

Slide 17

Slide 17 text

Deployment Pipeline - optimized

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

Aids Mike van Riel

Slide 20

Slide 20 text

Continuous Integration Servers Jenkins TeamCity Thoughtworks Go

Slide 21

Slide 21 text

Analysis tools ● PHPUnit ● Behat ● PhpDocumentor ● PHP_CodeSniffer ● PHP_Depend ● PHP_PMD ● phploc ● phpcpd

Slide 22

Slide 22 text

Build and deployment tools ● Phing ● Ant ● Make ● Capistrano ● Webistrano ● Deployinator ● Maven

Slide 23

Slide 23 text

More feedback ● Logstash ● Graphite ● Nagios

Slide 24

Slide 24 text

Exercises Mike van Riel

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

Exercise 1 Determine your workflow

Slide 27

Slide 27 text

Goal ● Think before you start ● Determine your process and workflow ● Does your current flow match with Continuous Deployment

Slide 28

Slide 28 text

Think about the following ● Versioning your application ● Versioning your environment ● Version numbering ● Which tools to use ● How to react on a build failure

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

Exercise 2 Planning your deployment pipeline

Slide 31

Slide 31 text

Goal ● Determine how to start automating your build and deployment process ● Review your deployment strategy ● Automate your deployment process using phing

Slide 32

Slide 32 text

Stages ● Commit stage – Pull changes – Clean workspace – Initialize workspace – Run unit tests ● Deploy stage – Upload your application – Switch symlink

Slide 33

Slide 33 text

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`

Slide 34

Slide 34 text

Exercise 3 Apply Continuous Integration

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

Exercise 4 Adding support for environments using parameters

Slide 39

Slide 39 text

Goal ● Extract all variable deployment options into parameters ● Learn how to switch between environments

Slide 40

Slide 40 text

Exercise 5 Adding a staging environment

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

Exercise 6 Switching to Continuous Delivery

Slide 43

Slide 43 text

Goal ● Add a new view for our project ● Add a new deploy job ● Persist workspace between jobs ● Try out our new process

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

Exercise 7 Adding a UAT stage

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

UAT Stage ● May run longer than 5 minutes ● Can trigger a deployment to staging for exploratory testing ● Automate!

Slide 48

Slide 48 text

Bonus exercise 1 Using the pipeline plugin

Slide 49

Slide 49 text

Goal ● Use the pipeline plugin to create a new view with your process ● Walk through your process

Slide 50

Slide 50 text

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

Slide 51

Slide 51 text

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/ ●