102
© 2011 Mayflower GmbH One Click Deployment with Jenkins Thorsten Rinne I 12th October 2011, Mainz, Germany

One Click Deployment with Jenkins

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: One Click Deployment with Jenkins

© 2011 Mayflower GmbH

One Click Deployment with Jenkins

Thorsten Rinne I 12th October 2011, Mainz, Germany

Page 2: One Click Deployment with Jenkins

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

Team Lead / Scrum MasterHead of Open Source Labs

@ThorstenRinne2

Page 3: One Click Deployment with Jenkins

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

Who are you?

3

Page 4: One Click Deployment with Jenkins

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

Developers?

4

Page 5: One Click Deployment with Jenkins

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

Administrators?

5

Page 6: One Click Deployment with Jenkins

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

DevOps?

6

Page 7: One Click Deployment with Jenkins

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

Continuous Integration?

7

Page 8: One Click Deployment with Jenkins

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

How much time do you need for a release?

8

Page 9: One Click Deployment with Jenkins

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

More than a year?

9

Page 10: One Click Deployment with Jenkins

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

6 - 12 months?

10

Page 11: One Click Deployment with Jenkins

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

1 - 6 months?

11

Page 12: One Click Deployment with Jenkins

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

2 - 4 weeks?

12

Page 13: One Click Deployment with Jenkins

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

1 - 14 days?

13

Page 14: One Click Deployment with Jenkins

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

1 - 24 hours?

14

Page 15: One Click Deployment with Jenkins

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

Less than 15 minutes?

15

Page 16: One Click Deployment with Jenkins

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

15 Minutes!

16

Page 17: One Click Deployment with Jenkins

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

Why One Click Deployment?

17

Page 18: One Click Deployment with Jenkins

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

Everything is getting faster.

18

Page 19: One Click Deployment with Jenkins

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

Faster feedback from your customer / user

19

Page 20: One Click Deployment with Jenkins

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

Faster ROI (return on invest)

20

Page 21: One Click Deployment with Jenkins

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

Faster responseif the market changes

21

Page 22: One Click Deployment with Jenkins

Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 22Developers are lazy.

Page 23: One Click Deployment with Jenkins

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

Basic requirements

23

Page 24: One Click Deployment with Jenkins

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

Agile software development

24

Page 25: One Click Deployment with Jenkins

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

Scrum or Kanban

25

Page 26: One Click Deployment with Jenkins

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

Test Driven Development

26

Page 27: One Click Deployment with Jenkins

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

Page 28: One Click Deployment with Jenkins

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

Continuous Integration

28

Page 29: One Click Deployment with Jenkins

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

Continuous Inspection

29

Page 30: One Click Deployment with Jenkins

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

Refactoring

30

Page 31: One Click Deployment with Jenkins

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

Page 32: One Click Deployment with Jenkins

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

ScrumKanban

Page 33: One Click Deployment with Jenkins

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

ScrumKanban

ContinuousIntegration

Page 34: One Click Deployment with Jenkins

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

ScrumKanban

ContinuousIntegration

ContinuousInspection

Page 35: One Click Deployment with Jenkins

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

Continuous Deployment

31

ScrumKanban

ContinuousIntegration

ContinuousInspection

Page 36: One Click Deployment with Jenkins

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

Things you don‘t want.

32

Page 37: One Click Deployment with Jenkins

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

Having your SVN repo in your webserver‘s docroot.

33

Page 38: One Click Deployment with Jenkins

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

Using SSH and vi and your root account on the live

server. Never.

34

Page 39: One Click Deployment with Jenkins

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

Who‘s still doing this? :-)

35

Page 40: One Click Deployment with Jenkins

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

Page 41: One Click Deployment with Jenkins

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

What do we need?

37

Page 42: One Click Deployment with Jenkins

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

First: a central build server

38

Page 43: One Click Deployment with Jenkins

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

Page 44: One Click Deployment with Jenkins

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

Continous Testing with PHPUnit

40

Page 45: One Click Deployment with Jenkins

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

Advantages

41

Page 46: One Click Deployment with Jenkins

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

Test results at one central page

42

Page 47: One Click Deployment with Jenkins

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

Software metrics at one central page

43

Page 48: One Click Deployment with Jenkins

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

Errors can be identified fast and then fixed

44

Page 49: One Click Deployment with Jenkins

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

Awareness

45

Page 50: One Click Deployment with Jenkins

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

Awareness!

Page 51: One Click Deployment with Jenkins

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

Continuous Integration in PHP projects

47

Page 52: One Click Deployment with Jenkins

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

PHPUnitDocBlox

48

Page 53: One Click Deployment with Jenkins

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

Continuous Inspection in PHP projects

49

Page 54: One Click Deployment with Jenkins

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

PHPCSPHP Depend

PHPMDphpcpd

jslint

50

Page 55: One Click Deployment with Jenkins

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

jslint?yes!

51

Page 56: One Click Deployment with Jenkins

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

Infrastructure

52

Page 57: One Click Deployment with Jenkins

Building a Cloud-based social network I Mayflower GmbH I 11th October 2011 I 53

http://www.flickr.com/photos/nirak/644337888/

Page 58: One Click Deployment with Jenkins

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

One Ubuntu package to rule them all.

54

Page 59: One Click Deployment with Jenkins

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

Development VMsJenkins CI ServerSelenium Server

Monitoring ServerTesting Server

55

Page 60: One Click Deployment with Jenkins

Building a Cloud-based social network I Mayflower GmbH I 11th October 2011 I

Only on production:Frontend Nodes 11.04

Backend Nodes 10.04 LTS

56

http://www.flickr.com/photos/nirak/644337888/

Page 61: One Click Deployment with Jenkins

Building a Cloud-based social network I Mayflower GmbH I 11th October 2011 I 57

☁☁ ☁

Mayflower DMZ

Eucalyptus Cloud

amazon AWS

http://www.flickr.com/photos/nirak/644337888/

Page 62: One Click Deployment with Jenkins

Building a Cloud-based social network I Mayflower GmbH I 11th October 2011 I 58

☁☁ ☁

Mayflower DMZ

Eucalyptus Cloud

amazon AWSDeveloper Laptopwith Ubuntu VM

(Git repo + completesoftware stack)

http://www.flickr.com/photos/nirak/644337888/

Page 63: One Click Deployment with Jenkins

Building a Cloud-based social network I Mayflower GmbH I 11th October 2011 I 59

☁☁ ☁

Mayflower DMZ

Eucalyptus Cloud

amazon AWSGitorious ServerJenkins CI Server

Puppet MasterSelenium Server

http://www.flickr.com/photos/nirak/644337888/

Page 64: One Click Deployment with Jenkins

Building a Cloud-based social network I Mayflower GmbH I 11th October 2011 I 60

☁☁ ☁

Mayflower DMZ

Eucalyptus Cloud

amazon AWS

2 Frontnodes3 Backendnodes

Development MonitorStaging Monitor

http://www.flickr.com/photos/nirak/644337888/

Page 65: One Click Deployment with Jenkins

Building a Cloud-based social network I Mayflower GmbH I 11th October 2011 I 61

☁☁ ☁

Mayflower DMZ

Eucalyptus Cloud

amazon AWS2 Frontnodes2 Backendnodes

DrupalLive Monitor

http://www.flickr.com/photos/nirak/644337888/

Page 66: One Click Deployment with Jenkins

Building a Cloud-based social network I Mayflower GmbH I 11th October 2011 I 62

Configuration Management done with

http://www.flickr.com/photos/nirak/644337888/

Page 67: One Click Deployment with Jenkins

Building a Cloud-based social network I Mayflower GmbH I 11th October 2011 I 63

Configuration changes are on every VM in 5 Minutes.

#WIN

http://www.flickr.com/photos/nirak/644337888/

Page 68: One Click Deployment with Jenkins

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

Frontnode 1Varnish nginx

PHP 5.3

Frontnode 2Varnish nginx

PHP 5.3

Backendnode 3RabbitMQ

Apache SolrPHP 5.3

Backendnode 2MySQL Slave

MogileFSMemcached

PHP 5.3

Backendnode 1MySQL Master

MogileFSMemcached

PHP 5.3

Page 69: One Click Deployment with Jenkins

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

Development workflow

65

Page 70: One Click Deployment with Jenkins

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

1. git workflow

66

$ git add Foo.php$ git commit -m ″Bar″$ ant jslint$ ant phpunit ...$ git push

Page 71: One Click Deployment with Jenkins

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

2. Post commit hook

67

Build triggered on Jenkins

Page 72: One Click Deployment with Jenkins

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

Jenkins build checks

68

Page 73: One Click Deployment with Jenkins

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

1. PHPUnit Build:Unittests

Controller Tests (Zend_Test)

69

Page 74: One Click Deployment with Jenkins

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

2. Debian Package Build

70

Page 75: One Click Deployment with Jenkins

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

3. Deploy to staging4. Deploy staging to live

71

Page 76: One Click Deployment with Jenkins

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

At midnight:DocBlox

Static code analysis

72

Page 77: One Click Deployment with Jenkins

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

What is a build process?

73

Page 78: One Click Deployment with Jenkins

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

ant syncant clean

ant db-updateparallelTasks:

ant phpunitant phpcbant deb

74

Page 79: One Click Deployment with Jenkins

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

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

75

ant phpunit

Page 80: One Click Deployment with Jenkins

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

parallelTasks:php_depend

phpmdphpunitphpcpdphpcsjslint

76

Page 81: One Click Deployment with Jenkins

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

Build Debian Packageant autoloaderant phpunitant clean

ant compilejsant compilecss

Page 82: One Click Deployment with Jenkins

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

<target name="deb" depends="autoloader,phpunit-coverage,clean,autoloader,compilejs,compilecss" description="Generate Debian package"> <exec executable="gpg"> <arg value="--armor" /> <arg value="--import" /> <arg value="scripts/build/deb/mapolis.mayflower.de.pgp" /> </exec> <buildnumber />

78

ant deb (I)

Page 83: One Click Deployment with Jenkins

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

<exec executable="git" outputproperty="githash"> <arg value="describe" /> <arg value="--always" /> <arg value="--match" /> <arg value="" /> </exec> <touch file="debian/changelog" /> <move file="debian/changelog" tofile="debian/changelog.old" />

79

ant deb (II)

Page 84: One Click Deployment with Jenkins

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

<exec executable="git" output="debian/changelog.new"> <arg value="log" /> <arg value="-n" /> <arg value="1" /> <arg value='--format=format:mapolis-web (${build.number}-${githash}) unstable; urgency=low%n%n * %s%n%n -- %an &lt;%ae&gt; %aD%n%n' /> </exec>

80

ant deb (III)

Page 85: One Click Deployment with Jenkins

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

<concat destfile="debian/changelog"> <fileset file="debian/changelog.new" /> <fileset file="debian/changelog.old" /> </concat> <delete file="debian/changelog.new" /> <delete file="debian/changelog.old" />

81

ant deb (IV)

Page 86: One Click Deployment with Jenkins

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

<exec executable="dpkg-buildpackage"> <arg value="-b" /> <arg value="-v${build.number}-${githash}" /> <arg value="-Zlzma" /> <arg value="-z9" /> <arg value="-k78532445" /> <arg value="-pgpg" /> <arg value="-sgpg" /> <arg value="-mMayflower Mapolis Team &lt;[email protected]&gt;" /> </exec>

82

ant deb (V)

Page 87: One Click Deployment with Jenkins

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

<move todir="build/deb/"> <fileset dir="${basedir}/../"> <include name="mapolis*.deb" /> <include name="mapolis*.changes" /> </fileset> </move> <exec executable="dpkg-buildpackage"> <arg value="-Tclean" /> </exec> </target>

83

ant deb (VI)

Page 88: One Click Deployment with Jenkins

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

Deploy Stagingant clean

ant deb-signant db-staging-upscp to all hosts

84

Page 89: One Click Deployment with Jenkins

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

Deploy Staging to livescp to all hosts

Page 90: One Click Deployment with Jenkins

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

Disadvantages and problems

86

Page 91: One Click Deployment with Jenkins

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

Build time15 min on harddisk

massive disk i/o4 min on ramdisk :-)

87

Page 92: One Click Deployment with Jenkins

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

Complexity beginning such a infrastructure

88

Page 93: One Click Deployment with Jenkins

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

Jenkins:Single point of failure!

89

Page 94: One Click Deployment with Jenkins

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

Cool stuff which is now possible

90

Page 95: One Click Deployment with Jenkins

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

Deploy by customer. :-)

Page 96: One Click Deployment with Jenkins

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

Jenkins Chuck Norris Plugin

Page 97: One Click Deployment with Jenkins

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

git bisect start $BAD $GOOD

93

Page 98: One Click Deployment with Jenkins

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

Minimum time from bugreport to deploy:

30 minutes

94

Page 99: One Click Deployment with Jenkins

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

$ git branch hotfix-2011-08-22$ git checkout hotfix-2011-08-22$ git reset --hard "last stable sha-1"$ git cherry-pick "hotfix sha-1"$ echo build.number=23 > build.number$ ant deb$ scp build/deb/*.deb xyz.amazonaws.com:/opt/repository/$ git checkout master$ git push origin hotfix-2011-08-10

95

Page 100: One Click Deployment with Jenkins

LiveDemo

Page 101: One Click Deployment with Jenkins

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

Questions?

97

Page 102: One Click Deployment with Jenkins

Thank you very much for your attention!

© 2011 Mayflower GmbH

Contact Thorsten [email protected]+49 89 242054-31

Mayflower GmbHMannhardtstr. 680538 MünchenGermany

Please rate me @ http://joind.in/talk/view/3904