Continuous Integration using Cruise Control


Published on

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Continuous Integration using Cruise Control

  1. 1. Continuous Integration using Cruise Control <ul><li>Presented By </li></ul><ul><li>Tom Grant </li></ul><ul><li>PlatinumSolutions, Inc. </li></ul><ul><li>Thursday, April 14 th , 2005 </li></ul>
  2. 2. What is Integration? <ul><li>Definition: “the act of combining into an integral whole” </li></ul><ul><li>In software development, integration includes… </li></ul><ul><ul><ul><li>Combining source files </li></ul></ul></ul><ul><ul><ul><li>Combining software and environment </li></ul></ul></ul><ul><ul><ul><li>Combining software and data </li></ul></ul></ul><ul><ul><ul><li>Combining software and requirements (tests) </li></ul></ul></ul><ul><ul><ul><li>Combining developers </li></ul></ul></ul>
  3. 3. Integration Testing in the SDLC <ul><li>Combine the application’s components into working software. </li></ul><ul><li>Historically done near the end of the project. </li></ul><ul><li>Very risky! Software modules don’t always work together as expected </li></ul><ul><ul><ul><li>Best case: Time to fix, time to retest that module </li></ul></ul></ul><ul><ul><ul><li>Worst case: Time to determine why, time to redesign, time to fix, time to test all of the modules affected by the redesign. </li></ul></ul></ul>
  4. 4. Nightly Builds <ul><li>Practice became popular in the late 90s after Microsoft published its development practices </li></ul><ul><li>Integrate all of the software on a nightly basis. </li></ul><ul><li>Smoke Test – run the application and conduct a minimal set of tests to see if it “catches fire”. </li></ul>
  5. 5. Take it to the Extreme <ul><li>Extreme Programming says… </li></ul><ul><ul><ul><li>if testing is good, test all the time </li></ul></ul></ul><ul><ul><ul><li>if integration testing is important, integrate and test all the time </li></ul></ul></ul><ul><ul><ul><li>if short iterations are good, make the iterations really, really short (minutes and hours, not weeks and months) </li></ul></ul></ul><ul><li>Continuous Integration is born. </li></ul>
  6. 6. What is Continuous Integration? <ul><li>Integrates source code and runs tests after each commit of code to the source repository. </li></ul><ul><li>Near-immediate feedback to the developer from the authoritative source, the system itself. </li></ul>
  7. 7. Nightly vs. Continuous Builds <ul><li>Nightly builds generate deliverables. They result in something tangible: something for QA to test, something for product managers to review, and something to reassure team members that they are in fact building a product. Because of the external audience, the nightly build is a formal event, a mini-milestone that your team should hit without fail. Breaking the nightly build is something that generates blame and often consequences, such as becoming the build mother or being awarded a dunce cap. </li></ul><ul><li>Continuous Integration builds don’t need durable build products to be beneficial. They are a way for a developer to have a conversation with the system to gain reassurance that they have done their part. </li></ul><ul><li>Source: </li></ul><ul><li>Use both . </li></ul>
  8. 8. Benefits of Continuous Integration <ul><li>It minimizes integration risk. </li></ul><ul><li>Easier defect diagnosis. </li></ul><ul><li>It saves time creating releases. </li></ul><ul><li>Encourages good testing habits </li></ul><ul><li>It enables other good development practices… </li></ul>
  9. 9. C.I. Enables other Practices <ul><li>Test Driven Development </li></ul><ul><ul><ul><li>Fewer bugs, less time debugging </li></ul></ul></ul><ul><ul><ul><li>Confidence to refactor </li></ul></ul></ul><ul><ul><ul><li>Executable Documentation </li></ul></ul></ul><ul><ul><ul><li>Validation that you are complete </li></ul></ul></ul><ul><li>Release Management </li></ul><ul><ul><ul><li>Builds are centralized </li></ul></ul></ul><ul><ul><ul><li>Builds are repeatable/re-creatable </li></ul></ul></ul><ul><ul><ul><li>Modifications are clearly mapped to releases </li></ul></ul></ul><ul><ul><ul><li>Issues are clearly mapped to releases and thus to modifications </li></ul></ul></ul><ul><ul><ul><li>Releases are only created with committed code </li></ul></ul></ul><ul><ul><ul><li>Digitally signed code </li></ul></ul></ul><ul><li>Enforcement of Company Development Policy </li></ul><ul><ul><ul><li>Automate policy tests with Checkstyle </li></ul></ul></ul><ul><ul><ul><li>Less need for manual code reviews </li></ul></ul></ul>
  10. 10. Continuous Integration Toolkits <ul><li>Cruise Control </li></ul><ul><li> </li></ul><ul><li>Damage Control </li></ul><ul><li> </li></ul><ul><li>Anthill </li></ul><ul><li> </li></ul><ul><li>Gump </li></ul><ul><li> </li></ul><ul><li>Feature Comparison Matrix </li></ul><ul><li> </li></ul>
  11. 11. Cruise Control <ul><li>Think of it as “Cron for Ant”. </li></ul><ul><li>Simple design. Full featured, but not bloated. </li></ul><ul><li>Adapts to your project, not the other way around. </li></ul><ul><li>Can be completely customized. </li></ul>
  12. 12. Cruise Control’s Build Loop <ul><li>Executes every “n” seconds or schedulable at particular times. </li></ul><ul><li>The process: </li></ul><ul><ul><ul><ul><li>Bootstrap (setup) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Check for modifications </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Run build </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Publish results </li></ul></ul></ul></ul>
  13. 13. The Build Loop CVS Build Artifacts Dir (Samba Share) SMTP Server 1. Bootstrap 2. Check for modifications 3. Get the revision log Cruise Control Your project’s Build file Ant, Maven, Make 2. Run Build 5. Publish Artifacts 6. Send Emails 1. Get the latest source 3. Tag source Cruise Control to project adapter. (build-project.xml) Ant script 4. Run Build
  14. 14. Scheduling <ul><li>You can schedule continuous builds </li></ul><ul><li>You can schedule builds at particular times (nightly builds) </li></ul><ul><li>You can schedule builds at particular intervals (hourly, weekly) </li></ul><ul><li>You can omit certain times or days (no builds on Sunday) </li></ul><ul><li>You can run different targets for each iteration. (do a complete test every 3 rd run) </li></ul>
  15. 15. Bootstrap <ul><li>Gives the developer a chance to run something before a build. </li></ul><ul><li>Always runs, regardless of the existence of modifications </li></ul><ul><li>Usually empty </li></ul>
  16. 16. Check for Modifications <ul><li>Checks for the existence of modifications, and retrieves the list of those modifications. </li></ul><ul><li>Version Control Systems </li></ul><ul><ul><li>cvs, pvcs, clearcase, visual source safe, subversion, … </li></ul></ul><ul><li>Local files </li></ul><ul><li>Http files </li></ul><ul><li>Always or “Force only” </li></ul><ul><li>Combinations of multiple types </li></ul><ul><li>Custom </li></ul><ul><li>Quiet Period –Makes sure that the repository is “quiet” for n seconds to prevent builds from kicking off in the middle of a multi step code commit. </li></ul>
  17. 17. Run The Build <ul><li>Only runs if modifications were detected. </li></ul><ul><li>It can run an ant script, maven or any other system executable such as make. </li></ul><ul><li>Cruise Control’s approach is that it will run your application’s build file. Your build file should know how to do everything to build your project. </li></ul>
  18. 18. Publish Results <ul><li>Only runs if modifications were detected. Most publishers can be disabled on a failure. </li></ul><ul><li>Build artifacts </li></ul><ul><ul><li>Copies files to a labeled release directory </li></ul></ul><ul><ul><li>SCP, FTP </li></ul></ul><ul><li>Email </li></ul><ul><li>Reports generated via XSL transforms </li></ul><ul><ul><li>XSL transforms exist for HTML, Email </li></ul></ul><ul><ul><li>You can add your own </li></ul></ul><ul><li>Execute scripts or applications </li></ul><ul><li>X10 </li></ul><ul><ul><li>Sirens, lamps. Notification using your other senses. </li></ul></ul>
  19. 19. Demonstrations <ul><li>Mike Clark (Pragmatic Project Automation) </li></ul><ul><ul><ul><ul><li> </li></ul></ul></ul></ul><ul><li>PS Project </li></ul>
  20. 20. PS Project with Cruise <ul><li>Checkout the code with cvs.exe </li></ul><ul><li>build-crs.xml – The project specific adapter between Cruise Control and the CRS build file. </li></ul><ul><li>config.xml – The Cruise Control configuration file. </li></ul>
  21. 21. Cruise Control Setup <ul><li>Install required software </li></ul><ul><ul><li>Java SDK </li></ul></ul><ul><ul><li>Ant </li></ul></ul><ul><ul><li>Tomcat </li></ul></ul><ul><ul><li>cvs.exe for cvs access </li></ul></ul><ul><li>Download the Cruise Control software </li></ul><ul><li>Install the Cruise Control software </li></ul><ul><li>Install the reporting WAR file </li></ul>
  22. 22. Cruise Control Software <ul><li>Getting Started How-to </li></ul><ul><ul><li> </li></ul></ul><ul><li>Pragmatic Project Automation </li></ul><ul><ul><li> </li></ul></ul><ul><li>Installation Directory - C:Program FilesCruiseControl </li></ul><ul><ul><ul><li>bincruisecontrol.bat </li></ul></ul></ul><ul><li>Build Directory - C:uilds </li></ul><ul><ul><ul><li>artifacts - files to be delivered </li></ul></ul></ul><ul><ul><ul><li>checkout - the source to build </li></ul></ul></ul><ul><ul><ul><li>logs - the details about each build </li></ul></ul></ul><ul><ul><ul><li>config.xml – the config file for Cruise Control </li></ul></ul></ul>
  23. 23. Installation Tips <ul><li>Remember to do a “cvs login” before your “cvs checkout”. Use the command line cvs.exe. </li></ul><ul><li>Run your project’s ant script from the command line to test it, not through your IDE. </li></ul><ul><li>Use a small Ant build script to wrap your project’s actual build script. </li></ul><ul><li>Share the artifacts directory. </li></ul><ul><li>Run Cruise Control from the command line before you set it up as a service. </li></ul><ul><li>Remember to change the user that the Windows service runs under to be the same user that executed the “cvs login”. </li></ul><ul><li>Plan for having multiple projects. </li></ul><ul><li>Cruise Control does not make any assumptions about directory structure, but the reporting application does. </li></ul>
  24. 24. Reporting Web-application <ul><li>Deploy it to any servlet container on the same machine. </li></ul><ul><li>Modify two parameters in the web.xml file. </li></ul><context-param> <param-name>logDir</param-name> <param-value> c:uildslogs </param-value> </context-param> <servlet> <servlet-name>ArtifactServlet</servlet-name> <servlet-class>net.sourceforge.cruisecontrol.servlet.FileServlet</servlet-class> <init-param> <param-name>rootDir</param-name> <param-value> c:uildsartifacts </param-value> </init-param> </servlet>
  25. 25. Cruise Control does… <ul><li>It runs your build script whenever you commit a change to your source repository. </li></ul><ul><li>It allows you to schedule nightly builds. </li></ul><ul><li>It allows you to run on-demand builds. </li></ul><ul><li>It notifies you of the results of those builds. </li></ul><ul><li>It simplifies release management. </li></ul>
  26. 26. Cruise Control does not… <ul><li>It does not write your build script for you. </li></ul><ul><li>It does not write your unit tests for you. </li></ul><ul><li>It does not automatically resolve project dependencies. </li></ul>
  27. 27. What does it cost? <ul><ul><li>Free, Open Source Software </li></ul></ul><ul><ul><li>One time costs </li></ul></ul><ul><ul><ul><li>$500 for a dedicated build machine </li></ul></ul></ul><ul><ul><ul><li>4 hours configuration time for a first-timer, 2 hours for an experienced Cruise Control user. </li></ul></ul></ul><ul><ul><li>Recurring costs </li></ul></ul><ul><ul><ul><li>20 minutes to set up a new project </li></ul></ul></ul><ul><ul><ul><li>Electricity </li></ul></ul></ul><ul><ul><ul><li>Disk space </li></ul></ul></ul>
  28. 28. The Bottom Line <ul><li>It takes practically nothing to set it up. </li></ul><ul><li>At a minimum, use it for nightly builds. </li></ul><ul><li>As the number of developers increases, it becomes more valuable. </li></ul><ul><li>As the number of releases increases, it becomes more valuable. </li></ul><ul><li>As the number of unit tests increases, it becomes more valuable. </li></ul>
  29. 29. Links <ul><li>Article by Jeffrey Fredrick on Continuous Integration using Cruise Control </li></ul><ul><li> </li></ul><ul><li>Continuous Integration Toolkit comparison Matrix </li></ul><ul><li> </li></ul><ul><li>Cruise Control Website </li></ul><ul><li> </li></ul><ul><li>Ant Website </li></ul><ul><li> </li></ul><ul><li>Pragmatic Project Automation by Mike Clark </li></ul><ul><li> </li></ul>