One Click Deployment with Jenkins - PHP Unconference 2011
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
5,614
On Slideshare
5,596
From Embeds
18
Number of Embeds
5

Actions

Shares
Downloads
58
Comments
0
Likes
9

Embeds 18

http://paper.li 8
http://a0.twimg.com 4
http://bsv-confluence01 4
https://twitter.com 1
https://extranet.ausschnitt.de 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. One Click Deployment with JenkinsFlorian Anderiasch / Thorsten RinnePHP Unconference 201 Hamburg 1, © 201 Mayflower GmbH 1
  • 2. DevOp„I rant a lot“@anderiasch Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 2
  • 3. Team Lead / Scrum MasterHead of Open Source Labs@ThorstenRinne Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 3
  • 4. Who are you? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 4
  • 5. Developers? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 5
  • 6. Administrators? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 6
  • 7. DevOps? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 7
  • 8. Continuous Integration? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 8
  • 9. How much time do you need for a release? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 9
  • 10. More than a year? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 10
  • 11. 6 - 12 months? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 11
  • 12. 1 - 6 months? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 12
  • 13. 2 - 4 weeks? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 13
  • 14. 1 - 14 days? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 14
  • 15. 1 - 24 hours? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 15
  • 16. Less than 15 minutes? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 16
  • 17. 15 Minutes! Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 17
  • 18. Why One ClickDeployment? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 18
  • 19. Everything is getting faster. Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 19
  • 20. Faster feedback fromyour customer / user Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 20
  • 21. Faster ROI(return on invest) Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 21
  • 22. Faster responseif the market changes Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 22
  • 23. Developers are lazy. Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 23
  • 24. Basic requirements Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 24
  • 25. Agile software development Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 25
  • 26. Scrum or Kanban Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 26
  • 27. Test Driven Development Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 27
  • 28. Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 28
  • 29. Continuous Integration Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 29
  • 30. Continuous Inspection Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 30
  • 31. Refactoring Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 31
  • 32. Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 32
  • 33. ScrumKanban Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 32
  • 34. Scrum ContinuousKanban Integration Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 32
  • 35. Scrum Continuous ContinuousKanban Integration Inspection Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 32
  • 36. Scrum Continuous ContinuousKanban Integration InspectionContinuous Deployment Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 32
  • 37. Things you don‘t want. Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 33
  • 38. Having your SVN repo inyour webserver‘s docroot. Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 34
  • 39. Using SSH and vi and your root account on the live server. Never. Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 35
  • 40. Who‘s still doing this? :-) Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 36
  • 41. Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 37
  • 42. What do we need? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 38
  • 43. First: a central build server Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 39
  • 44. Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 40
  • 45. Continous Testing with PHPUnit Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 41
  • 46. Advantages Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 42
  • 47. Test results at one central page Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 43
  • 48. Software metrics at one central page Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 44
  • 49. Errors can be identified fast and then fixed Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 45
  • 50. Awareness Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 46
  • 51. Awareness! Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 47
  • 52. Continuous Integration in PHP projects Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 48
  • 53. PHPUnitDocBlox Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 49
  • 54. Continuous Inspection in PHP projects Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 50
  • 55. PHPCSPHP Depend PHPMD phpcpd jslint Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 51
  • 56. jslint? yes! Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 52
  • 57. Infrastructure Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 53
  • 58. Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 54
  • 59. Developer VMUbuntu 11.04 Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 55
  • 60. Testing VM + Jenkins VM: Ubuntu 11.04 Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 56
  • 61. Staging VMs: Frontend: Ubuntu 11.04Backend: Ubuntu 10.04 LTS Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 57
  • 62. amazon AWS live: Frontend: Ubuntu 11.04Backend: Ubuntu 10.04 LTS Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 58
  • 63. Front Nodes Varnish nginx PHP 5.3 with APCZend Framework 1.1 1 dojo toolkit 1.6 Doctrine 2.1 Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 59
  • 64. Backend NodesMySQL Master/Slave Apache Solr PHP 5.3 with APC RabbitMQ ejabberd Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 60
  • 65. Development workflow Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 61
  • 66. 1. git workflow$ git add Foo.php$ git commit -m ″Bar″$ ant jslint$ ant phpunit ...$ git push Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 62
  • 67. 2. Post commit hookBuild triggered on Jenkins Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 63
  • 68. Jenkins build checks Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 64
  • 69. 1. PHPUnit Build: UnittestsController Tests (Zend_Test) PHP Code Coverage Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 65
  • 70. 2. Debian Package Build Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 66
  • 71. 3. Deploy to staging4. Deploy staging to live Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 67
  • 72. What is a build process? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 68
  • 73. ant sync ant cleanant db-update parallelTasks: ant phpunit ant phpcb ant deb Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 69
  • 74. ant phpunit<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> Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 70
  • 75. parallelTasks:php_depend phpmd phpunit phpcpd phpcs jslint Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 71
  • 76. Build Debian Packageant autoloader ant phpunit ant clean ant compilejsant compilecss Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 72
  • 77. ant deb (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 /> Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 73
  • 78. ant deb (II)<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" /> Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 74
  • 79. ant deb (III) <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> Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 75
  • 80. ant deb (IV)<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" /> Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 76
  • 81. ant deb (V) <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;mapolis@mayflower.de&gt;" /> </exec> Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 77
  • 82. ant deb (VI) <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> Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 78
  • 83. Deploy Staging ant clean ant deb-signant db-staging-upscp to all hosts Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 79
  • 84. Deploy Staging to livescp to all hosts Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 80
  • 85. Disadvantages and problems Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 81
  • 86. Build time15 min on harddisk massive disk i/o4 min on ramdisk :-) Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 82
  • 87. Complexity beginning such a infrastructure Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 83
  • 88. Jenkins:Single point of failure! Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 84
  • 89. Cool stuffwhich is now possible Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 85
  • 90. Deploy by customer. :-) Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 86
  • 91. Jenkins Chuck Norris Plugin Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 87
  • 92. git bisect start $BAD $GOOD Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 88
  • 93. Minimum time frombugreport to deploy: 30 minutes Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 89
  • 94. $ 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 Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 90
  • 95. Questions? Continuous Improvement in PHP Projects I Mayflower GmbH I 25th February I 91
  • 96. Thank you very much for your attention!Contact Florian Anderiasch Thorsten Rinne florian.anderiasch@mayflower.de thorsten.rinne@mayflower.de +49 89 242054-1 134 +49 89 242054-31 Mayflower GmbH Mayflower GmbH Mannhardtstr. 6 Mannhardtstr. 6 80538 München 80538 München Germany Germany © 201 Mayflower GmbH 1