91
© Mayflower GmbH 2010 One-Click Deployment with Jenkins Florian Anderiasch I October 28, 2011

One-Click Deployment with Jenkins

Embed Size (px)

DESCRIPTION

PHP Barcelona 2011

Citation preview

Page 1: One-Click Deployment with Jenkins

© Mayflower GmbH 2010

One-Click Deployment with Jenkins

Florian Anderiasch I October 28, 2011

Page 2: One-Click Deployment with Jenkins

Mayflower GmbH I 2

Who am I?

Page 3: One-Click Deployment with Jenkins

Mayflower GmbH I 3

DeveloperEx-AdminDevOp?

„I rant a lot“

@anderiaschstay in touch!

Page 4: One-Click Deployment with Jenkins

Mayflower GmbH I 4

Who are you?

Page 5: One-Click Deployment with Jenkins

Mayflower GmbH I 5

Developers?

Page 6: One-Click Deployment with Jenkins

Mayflower GmbH I 6

Admins?

Page 7: One-Click Deployment with Jenkins

Mayflower GmbH I 7

Continuous Integration?

Page 8: One-Click Deployment with Jenkins

Mayflower GmbH I 8

How often

do yourelease?

Page 9: One-Click Deployment with Jenkins

Mayflower GmbH I 9

6-12 months?

Page 10: One-Click Deployment with Jenkins

Mayflower GmbH I 10

1-6 months?

Page 11: One-Click Deployment with Jenkins

Mayflower GmbH I 11

2-4 weeks?

Page 12: One-Click Deployment with Jenkins

Mayflower GmbH I 12

1-14 days?

Page 13: One-Click Deployment with Jenkins

Mayflower GmbH I 13

1-24 hours?

Page 14: One-Click Deployment with Jenkins

Mayflower GmbH I 14

Less than 15 minutes?

Page 15: One-Click Deployment with Jenkins

Mayflower GmbH I 15

15 minutes!

Page 16: One-Click Deployment with Jenkins

Mayflower GmbH I 16

Why One-ClickDeployment?

Page 17: One-Click Deployment with Jenkins

Mayflower GmbH I 17

Everything is moving faster.

Page 18: One-Click Deployment with Jenkins

Mayflower GmbH I 18

React faster touser feedback

React faster touser feedback

Page 19: One-Click Deployment with Jenkins

Mayflower GmbH I 19

Faster ROITime to market

Page 20: One-Click Deployment with Jenkins

20Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I

Developers are lazy.Developers are lazy.

Page 21: One-Click Deployment with Jenkins

Mayflower GmbH I 21

Basic requirements

Page 22: One-Click Deployment with Jenkins

Mayflower GmbH I 22

Agile softwaredevelopment

Page 23: One-Click Deployment with Jenkins

Mayflower GmbH I 23

Scrum or Kanban

Page 24: One-Click Deployment with Jenkins

Mayflower GmbH I 24

Test Driven Development

Page 25: One-Click Deployment with Jenkins

Mayflower GmbH I 25

Continuous Integration

Page 26: One-Click Deployment with Jenkins

Mayflower GmbH I 26

Integrating the freshparts of code into

the application

at least daily

Page 27: One-Click Deployment with Jenkins

Mayflower GmbH I 27

Continuous Inspection

Page 28: One-Click Deployment with Jenkins

Mayflower GmbH I 28

instantfeedback

Page 29: One-Click Deployment with Jenkins

Mayflower GmbH I 29

Refactoring

Page 30: One-Click Deployment with Jenkins

Mayflower GmbH I 30

ContinuousDeployment

Page 31: One-Click Deployment with Jenkins

Mayflower GmbH I 31

Reproducableresults

Page 32: One-Click Deployment with Jenkins

Mayflower GmbH I 32

There arepractices you wantto avoid

Page 33: One-Click Deployment with Jenkins

Mayflower GmbH I 33

Having your SVN repo in your

webserver's docroot.

Page 34: One-Click Deployment with Jenkins

Mayflower GmbH I 34

Using SSH and vi and your root account on

the live server.

Page 35: One-Click Deployment with Jenkins

Mayflower GmbH I 35

Who's still doing this? :-)

Page 36: One-Click Deployment with Jenkins

Mayflower GmbH I 36

Page 37: One-Click Deployment with Jenkins

Mayflower GmbH I 37

What do we need?

Page 38: One-Click Deployment with Jenkins

Mayflower GmbH I 38

First of all:centralizedbuild server

Page 39: One-Click Deployment with Jenkins

Mayflower GmbH I 39

There are plenty:

CruiseControl/phpUCBamboobuildbot

Page 40: One-Click Deployment with Jenkins

Mayflower GmbH I 40

tests are running

all the time

Page 41: One-Click Deployment with Jenkins

Mayflower GmbH I 41

Page 42: One-Click Deployment with Jenkins

Mayflower GmbH I 42

Repeatedlyrunning

tests

Page 43: One-Click Deployment with Jenkins

Mayflower GmbH I 43

Advantages

Page 44: One-Click Deployment with Jenkins

Mayflower GmbH I 44

Informationavailable

at onesingle point

Page 45: One-Click Deployment with Jenkins

Mayflower GmbH I 45

find errors

Page 46: One-Click Deployment with Jenkins

Mayflower GmbH I 46

andfix themquickly

Page 47: One-Click Deployment with Jenkins

Mayflower GmbH I 47

Metrics

Page 48: One-Click Deployment with Jenkins

Mayflower GmbH I 48

Dashboards

Page 49: One-Click Deployment with Jenkins

Mayflower GmbH I 49

Awareness

Page 50: One-Click Deployment with Jenkins

Mayflower GmbH I 50

Awareness!

Page 51: One-Click Deployment with Jenkins

Mayflower GmbH I 51

Continuous integrationin

PHP projects

Page 52: One-Click Deployment with Jenkins

Mayflower GmbH I 52

Continuous Integrationin

PHP projects

Page 53: One-Click Deployment with Jenkins

Mayflower GmbH I 53

PHPUnitDocBlox

Page 54: One-Click Deployment with Jenkins

Mayflower GmbH I 54

Continuous Inspectionin

PHP projects

Page 55: One-Click Deployment with Jenkins

Mayflower GmbH I 55

PHP_CodeSnifferPHP_Depend

PHPMDphpcpd

jslint

Page 56: One-Click Deployment with Jenkins

Mayflower GmbH I 56

Infrastructure

Page 57: One-Click Deployment with Jenkins

Mayflower GmbH I 57

Page 58: One-Click Deployment with Jenkins

Mayflower GmbH I 58

Page 59: One-Click Deployment with Jenkins

59Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I

One Ubuntu package to rule them all.

Page 60: One-Click Deployment with Jenkins

Mayflower GmbH I 60

Developer VMUbuntu 11.04

Page 61: One-Click Deployment with Jenkins

Mayflower GmbH I 61

Jenkins: Dev-VMTesting: Dev-VM

Ubuntu 11.04

Page 62: One-Click Deployment with Jenkins

Mayflower GmbH I 62

Staging VMs:Frontend: Ubuntu 11.04

Backend: Ubuntu 10.04 LTS

(bad idea, use one version)

Page 63: One-Click Deployment with Jenkins

Mayflower GmbH I 63

Amazon AWS live:Frontend: Ubuntu 11.04

Backend: Ubuntu 10.04 LTS

Page 64: One-Click Deployment with Jenkins

Mayflower GmbH I 64

Frontend NodesVarnishnginx

PHP 5.3 with APCZend Framework 1.11

Dojo 1.6Doctrine2.1

Page 65: One-Click Deployment with Jenkins

Mayflower GmbH I 65

Backend NodesMySQL Master/Slave

Apache SolrGearman/RabbitMQ

memcachedejabberd

Page 66: One-Click Deployment with Jenkins

Mayflower GmbH I 66

Development workflow

Page 67: One-Click Deployment with Jenkins

Mayflower GmbH I 67

1. developer commits code2. post commit hook: build3. checks4. packaging a .deb5. (deploy to STAGING)6. (deploy to LIVE)

Page 68: One-Click Deployment with Jenkins

Mayflower GmbH I 68

<project> <property /> <target name=“build“></target> <target name=“clean“></target> <target name=“phpunit“></target> <target name=“deploy-to-staging“></target></project>

Page 69: One-Click Deployment with Jenkins

Mayflower GmbH I 69

<target name="phpunit" depends="db-test" description="Run all tests"> <exec executable="phpunit" failonerror="true"> <arg line="--configuration${basedir}/tests/phpunit-verbose.xml${basedir}/tests/AllTests.php" /> </exec> </target>

Page 70: One-Click Deployment with Jenkins

Mayflower GmbH I 70

„ant build“

ant syncant cleanant db-up

ant parallelTasksant parallelTasksant phpunitant phpcb

ant build-debant build-deb

Page 71: One-Click Deployment with Jenkins

Mayflower GmbH I 71

„ant parallelTasks“

ant phpmdant phpdocant phpcpdant phpcsant jslint

Page 72: One-Click Deployment with Jenkins

Mayflower GmbH I 72

„build-deb“

git pullant phpunitant clean

ant compilejsant compilecss

Page 73: One-Click Deployment with Jenkins

Mayflower GmbH I 73

„deploy-to-staging“

ant deb-signant db-staging-up

scp to all hosts

Page 74: One-Click Deployment with Jenkins

Mayflower GmbH I 74

„deploy-to-live“

fetch known-good .debscp to all hosts

there is no step 3

Page 75: One-Click Deployment with Jenkins

Mayflower GmbH I 75

Disadvantagesand

problems

Page 76: One-Click Deployment with Jenkins

Mayflower GmbH I 76

Build time15 min on harddisk

massive disk i/o4 min on ramdisk

Page 77: One-Click Deployment with Jenkins

Mayflower GmbH I 77

Complex setup

Page 78: One-Click Deployment with Jenkins

Mayflower GmbH I 78

Jenkins:Single point of failure!

Page 79: One-Click Deployment with Jenkins

Mayflower GmbH I 79

Goodies

Page 80: One-Click Deployment with Jenkins

Mayflower GmbH I 80

everyonecan deploy

(including theproduct owner)

Page 81: One-Click Deployment with Jenkins

Mayflower GmbH I 81

git bisect start$BAD $GOOD

Page 82: One-Click Deployment with Jenkins

Mayflower GmbH I 82

30min frombugreport to

deploy

Page 83: One-Click Deployment with Jenkins

Mayflower GmbH I 83

We can still do hotfixes in thisenvironment

Page 84: One-Click Deployment with Jenkins

Mayflower GmbH I 84

plotting plugin (gitstats)

Page 85: One-Click Deployment with Jenkins

Mayflower GmbH I 85

Page 86: One-Click Deployment with Jenkins

Mayflower GmbH I 86

echo $(olddir=`pwd`;cd /media/ram/PROJECT;

git log --oneline --after=$(date +%Y-%m-%d -d yesterday) --shortstat

| grep --color=none "^ " | sed 's,^ *,,' | awk 'NF==7 {p+=$4;m+=$6;diff+=$4;diff-=$6;} END {printf("%d %d %d\n", p, m, diff)}';cd

$olddir;) > gitnum.properties.all

echo YVALUE=$(cat gitnum.properties.all | cut -d' ' -f1) >> gitnum.properties.plus

Page 87: One-Click Deployment with Jenkins

Mayflower GmbH I 87

Jenkins Plugin: Chuck Norris

Page 88: One-Click Deployment with Jenkins

Mayflower GmbH I 88

Questions?

Page 89: One-Click Deployment with Jenkins

29.10.11 Mayflower GmbH 89

Thanks for listening!

Contact Florian Anderiasch

[email protected]

+49 89 242054 1134

@anderiasch

Mayflower GmbH

Mannhardtstrasse 6

80538 München

Page 90: One-Click Deployment with Jenkins

Mayflower GmbH I 90

ImagesVader (42), Sebastian Bergmann, CC-BY-SA

http://www.flickr.com/photos/sebastian_bergmann/2282734669

Clouds (52), John Mueller, CC-BY-NC-NDhttp://www.flickr.com/photos/johnmueller/52621490/

Page 91: One-Click Deployment with Jenkins

Mayflower GmbH I 91

CinderConnecting CI server and IDE

Help is welcomehttp://github.com/winks/cinder

needs XML from phpuc/hudson/bamboo

and nothing else :)