Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

JavaOne 2015: Scalable Continous Deployment with Maven

541 views

Published on

Slides from my presentation at JavaOne 2015. Useful even if you don't use maven! The ideas are applicable to other build systems as well.

Published in: Software
  • Login to see the comments

  • Be the first to like this

JavaOne 2015: Scalable Continous Deployment with Maven

  1. 1. Scalable Continuous Deployment with Maven fromfragiletoagile.com @AbrahamMarin
  2. 2. @AbrahamMarin
  3. 3. About Me @AbrahamMarin
  4. 4. About Me @AbrahamMarin
  5. 5. About Me @AbrahamMarin
  6. 6. Table of Contents • Continuous Deployment with Maven • Scaling Continuous Deployment • Analyse Data from the CI System • Automate Analysis and Visualisation @AbrahamMarin
  7. 7. Table of Contents • Continuous Deployment with Maven • Scaling Continuous Deployment • Analyse Data from the CI System • Automate Analysis and Visualisation @AbrahamMarin
  8. 8. What is Continuous Deployment? Continuous Integration: check everything is still working after every commit • • Continuous Deployment: every successful commit turns into a release • @AbrahamMarin
  9. 9. Why maven? • Just because… @AbrahamMarin
  10. 10. Other technologies @AbrahamMarin
  11. 11. To Caesar what is Caesar’s Based on John Ferguson Smart’s “Real-World Strategies for Continuous Delivery with maven and Jenkins” http://youtu.be/McTZtyb9M38 @AbrahamMarin
  12. 12. John’s approach Maven wasn’t built for Continuous Deployment commit commit commit ... 0.0.1-SNAPSHOT Release! 0.0.1 @AbrahamMarin
  13. 13. John’s approach Don’t use RELEASE plugin Use VERSIONS plugin Set version to <version scheme>.<build number> Run mvn deploy Commit pom file to repository @AbrahamMarin
  14. 14. John’s approach Set version to <version scheme>.<build number> mvn versions:set –DnewVersion=**your version** @AbrahamMarin
  15. 15. John’s approach Run mvn deploy mvn clean deploy @AbrahamMarin
  16. 16. John’s approach Commit pom file to repository <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-plugin</artifactId> <version>1.9.1</version> <executions> <execution> <id>commit</id> <phase>deploy</phase> <goals> <goal>checkin</goal> </goals> </execution> </executions> </plugin> @AbrahamMarin
  17. 17. John’s approach @AbrahamMarin
  18. 18. John’s approach 0.0.1.1 commit BUILD! 0.0.1.2 commit BUILD! 0.0.1.3 commit BUILD! @AbrahamMarin
  19. 19. Table of Contents • Continuous Deployment with Maven • Scaling Continuous Deployment • Analyse Data from the CI System • Automate Analysis and Visualisation @AbrahamMarin
  20. 20. How do you scale this? @AbrahamMarin
  21. 21. SUPER APP # Files: 75 # Tests: 800 Build Time: 4 min Output: superapp.war @AbrahamMarin
  22. 22. SUPER APP # Files: 113 # Tests: 1200 Build Time: 6 min Output: superapp.war @AbrahamMarin
  23. 23. SUPER APP # Files: 169 # Tests: 1800 Build Time: 9 min Output: superapp.war @AbrahamMarin
  24. 24. When Builds Get Too Big @AbrahamMarin "MAN Atlante fronte 1040572" by Lalupa - Own work. Licensed under GFDL via Commons - https://commons.wikimedia.org/wiki/File:MAN_Atlante_fronte_1040572.JPG#/media/File:MAN_Atlante_fronte_1040572.JPG
  25. 25. SUPER APP # Files: 169 # Tests: 1800 Build Time: 9 min Output: superapp.war APP BACKEND SUPER APP # Files: 115 # Tests: 1200 Build Time: 6 min Output: superapp.war # Files: 72 # Tests: 800 Build Time: 4 min Output: appbackend.jar @AbrahamMarin
  26. 26. <dependency> <groupId>com.superappfactory</groupId> <artifactId>appbackend</artifactId> <version>??????</version> </dependency> <dependency> <groupId>com.superappfactory</groupId> <artifactId>appbackend</artifactId> <version>LATEST</version> </dependency> Setting up dependencies APP BACKEND SUPER APP appbackend.jar superapp.war @AbrahamMarin
  27. 27. @AbrahamMarin
  28. 28. @AbrahamMarin
  29. 29. @AbrahamMarin
  30. 30. Setting up dependencies APP BACKEND SUPER APP appbackend.jar superapp.war @AbrahamMarin
  31. 31. Rebuilding old versions @AbrahamMarin
  32. 32. Rebuilding old versions Using “LATEST” makes it impossible to build old versions correctly @AbrahamMarin
  33. 33. <dependency> <groupId>com.superappfactory</groupId> <artifactId>appbackend</artifactId> <version>???????</version> </dependency> <dependency> <groupId>com.superappfactory</groupId> <artifactId>appbackend</artifactId> <version>1.5.3.1</version> </dependency> Rebuilding old versions APP BACKEND SUPER APP appbackend.jar superapp.war @AbrahamMarin
  34. 34. Update versions of dependencies mvn versions:use-latest-releases @AbrahamMarin
  35. 35. APP BACKEND SUPER APP APP BACKEND SUPER APP DATA MODEL SUPER APP DATA MODEL GUI APP BACKEND
  36. 36. Like it? @AbrahamMarin
  37. 37. Like it? @AbrahamMarin
  38. 38. Like it? @AbrahamMarin
  39. 39. Like it? @AbrahamMarin
  40. 40. Like it? @AbrahamMarin
  41. 41. @AbrahamMarin http://thechive.com/2014/02/26/your e-doing-it-wrong-31-photos-2/
  42. 42. I Can Help  @AbrahamMarin
  43. 43. Problem: Infinite Trigger commitbuild deploy commit @AbrahamMarin
  44. 44. @AbrahamMarin
  45. 45. @AbrahamMarin
  46. 46. Problem: Unnecessary rebuilds APP BACKEND SUPER APP commit @AbrahamMarin
  47. 47. @AbrahamMarin
  48. 48. Problem: Unnecessary rebuilds @AbrahamMarin
  49. 49. Problem: Unnecessary rebuilds Get last committer buildAgent? Proceed normally Don’t run build NO YES touch skip_build @AbrahamMarin
  50. 50. Problem: Unnecessary rebuilds <profiles> <!-- Plugins that need to be disabled when doing a no-run --> <profile> <id>do.nothing</id> <activation> <file> <exists>skip_build</exists> </file> </activation> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <skipMain>true</skipMain> <skip>true</skip> </configuration> </plugin> @AbrahamMarin
  51. 51. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> <configuration> <skip>true</skip> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> <configuration> <skip>true</skip> </configuration> </plugin> Problem: Unnecessary rebuilds @AbrahamMarin
  52. 52. Problem: Unnecessary rebuilds APP BACKEND SUPER APP commit @AbrahamMarin
  53. 53. Problem: Unnecessary rebuilds @AbrahamMarin
  54. 54. Problem: Necessary rebuilds APP BACKEND SUPER APP commit @AbrahamMarin
  55. 55. Get last committer buildAgent? Proceed normally Don’t run build NO YES Problem: Necessary rebuilds @AbrahamMarin
  56. 56. @AbrahamMarin
  57. 57. Get last committer buildAgent? Proceed normally NO YES Check dependencies Up to date? NO Don’t run build YES touch skip_build @AbrahamMarin
  58. 58. Problem: Necessary rebuilds @AbrahamMarin
  59. 59. Problem: Doomed Build build deploy commit commit commit pom.xml @AbrahamMarin
  60. 60. Get last committer buildAgent? Proceed normally NO YES Check dependencies Up to date? NO Don’t run build YES touch skip_build @AbrahamMarin
  61. 61. Get last committer buildAgent? Check pom.xml NO YES Check dependencies Up to date? NO Don’t run build YES touch skip_build Up to date? NO Proceed normally YES @AbrahamMarin
  62. 62. Problem: Doomed Build @AbrahamMarin
  63. 63. @AbrahamMarin
  64. 64. Table of Contents • Continuous Deployment with Maven • Scaling Continuous Deployment • Analyse Data from the CI System • Automate Analysis and Visualisation @AbrahamMarin
  65. 65. A real case scenario @AbrahamMarin
  66. 66. WAR file WAR file WAR file Parent POM Logging @AbrahamMarin
  67. 67. WAR file WAR file WAR file Parent POM Logging 28% @AbrahamMarin
  68. 68. WAR file WAR file WAR file Parent POM Logging 28% 28% 28% @AbrahamMarin
  69. 69. WAR file WAR file WAR file Parent POM Logging 28% 28% 28% 20% @AbrahamMarin
  70. 70. WAR file WAR file WAR file Parent POM Logging 48% 28% 28% 20% @AbrahamMarin
  71. 71. WAR file WAR file WAR file Parent POM Logging @AbrahamMarin
  72. 72. WAR file WAR file WAR file @AbrahamMarin
  73. 73. Build-Driven Architecture @AbrahamMarin
  74. 74. Table of Contents • Continuous Deployment with Maven • Scaling Continuous Deployment • Analyse Data from the CI System • Automate Analysis and Visualisation @AbrahamMarin
  75. 75. WAR file WAR file WAR file @AbrahamMarin
  76. 76. Manual processing takes time... @AbrahamMarin
  77. 77. Automating Build Analysis • Most CI systems provide an API • Calculations aren’t complex • Multiple graphical tools available @AbrahamMarin
  78. 78. Build Hotspots github.com/quiram/build-hotspots @AbrahamMarin
  79. 79. Automating Build Analysis • Add colour and size • Add support for other CI systems • Show subset of builds • Update data automatically (for build displays) • Anything else you may find useful! @AbrahamMarin
  80. 80. Summary • Setting up Continuous Deployment is possible • Scaling is challenging, but also possible • Build data can help you shape the architecture of your application • Still plenty to improve, please join me  @AbrahamMarin
  81. 81. Questions? @AbrahamMarin
  82. 82. fromfragiletoagile.com @AbrahamMarin Thank You!

×