Title: Continuous Integration using Cruise Control
1Continuous Integration using Cruise Control
- Presented By
- Tom Grant
- PlatinumSolutions, Inc.
- Thursday, April 14th, 2005
2What is Integration?
- Definition the act of combining into an
integral whole - In software development, integration includes
- Combining source files
- Combining software and environment
- Combining software and data
- Combining software and requirements (tests)
- Combining developers
3Integration Testing in the SDLC
- Combine the applications components into working
software. - Historically done near the end of the project.
- Very risky! Software modules dont always work
together as expected - Best case Time to fix, time to retest that
module - Worst case Time to determine why, time to
redesign, time to fix, time to test all of the
modules affected by the redesign.
4Nightly Builds
- Practice became popular in the late 90s after
Microsoft published its development practices - Integrate all of the software on a nightly basis.
- Smoke Test run the application and conduct a
minimal set of tests to see if it catches fire.
5Take it to the Extreme
- Extreme Programming says
- if testing is good, test all the time
- if integration testing is important, integrate
and test all the time - if short iterations are good, make the iterations
really, really short (minutes and hours, not
weeks and months) - Continuous Integration is born.
6What is Continuous Integration?
- Integrates source code and runs tests after each
commit of code to the source repository. - Near-immediate feedback to the developer from the
authoritative source, the system itself.
7Nightly vs. Continuous Builds
- 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. - Continuous Integration builds dont 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. - Source http//www.stickyminds.com/BetterSoftware/
magazine.asp?fncifeaid58 - Use both.
8Benefits of Continuous Integration
- It minimizes integration risk.
- Easier defect diagnosis.
- It saves time creating releases.
- Encourages good testing habits
- It enables other good development practices
9C.I. Enables other Practices
- Test Driven Development
- Fewer bugs, less time debugging
- Confidence to refactor
- Executable Documentation
- Validation that you are complete
- Release Management
- Builds are centralized
- Builds are repeatable/re-creatable
- Modifications are clearly mapped to releases
- Issues are clearly mapped to releases and thus to
modifications - Releases are only created with committed code
- Digitally signed code
- Enforcement of Company Development Policy
- Automate policy tests with Checkstyle
- Less need for manual code reviews
10Continuous Integration Toolkits
- Cruise Control
- http//cruisecontrol.sourceforge.net
- Damage Control
- http//damagecontrol.codehaus.org/
- Anthill
- http//www.urbancode.com/projects/anthill/default.
jsp - Gump
- http//jakarta.apache.org/gump/
- Feature Comparison Matrix
- http//docs.codehaus.org/display/DAMAGECONTROL/Con
tinuousIntegrationServerFeatureMatrix
11Cruise Control
- Think of it as Cron for Ant.
- Simple design. Full featured, but not bloated.
- Adapts to your project, not the other way around.
- Can be completely customized.
12Cruise Controls Build Loop
- Executes every n seconds or schedulable at
particular times. - The process
- Bootstrap (setup)
- Check for modifications
- Run build
- Publish results
13The Build Loop
1. Bootstrap
2. Check for modifications
CVS
Cruise Control
3. Get the revision log
Build Artifacts Dir (Samba Share)
5. Publish Artifacts
SMTP Server
6. Send Emails
1. Get the latest source
4. Run Build
3. Tag source
Cruise Control to project adapter. (build-project
.xml) Ant script
Your projects Build file Ant, Maven, Make
2. Run Build
14Scheduling
- You can schedule continuous builds
- You can schedule builds at particular times
(nightly builds) - You can schedule builds at particular intervals
(hourly, weekly) - You can omit certain times or days (no builds on
Sunday) - You can run different targets for each iteration.
(do a complete test every 3rd run)
15Bootstrap
- Gives the developer a chance to run something
before a build. - Always runs, regardless of the existence of
modifications - Usually empty
16Check for Modifications
- Checks for the existence of modifications, and
retrieves the list of those modifications. - Version Control Systems
- cvs, pvcs, clearcase, visual source safe,
subversion, - Local files
- Http files
- Always or Force only
- Combinations of multiple types
- Custom
- 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.
17Run The Build
- Only runs if modifications were detected.
- It can run an ant script, maven or any other
system executable such as make. - Cruise Controls approach is that it will run
your applications build file. Your build file
should know how to do everything to build your
project.
18Publish Results
- Only runs if modifications were detected. Most
publishers can be disabled on a failure. - Build artifacts
- Copies files to a labeled release directory
- SCP, FTP
- Email
- Reports generated via XSL transforms
- XSL transforms exist for HTML, Email
- You can add your own
- Execute scripts or applications
- X10
- Sirens, lamps. Notification using your other
senses.
19Demonstrations
- Mike Clark (Pragmatic Project Automation)
- http//media.pragprog.com/movies/auto/CruiseContro
l_MikeClark.html - PS Project
20PS Project with Cruise
- Checkout the code with cvs.exe
- build-crs.xml The project specific adapter
between Cruise Control and the CRS build file. - config.xml The Cruise Control configuration
file.
21Cruise Control Setup
- Install required software
- Java SDK
- Ant
- Tomcat
- cvs.exe for cvs access
- Download the Cruise Control software
- Install the Cruise Control software
- Install the reporting WAR file
22Cruise Control Software
- Getting Started How-to
- http//cruisecontrol.sourceforge.net/gettingstarte
d.html - Pragmatic Project Automation
- http//www.pragmaticprogrammer.com/starter_kit/au/
scheduled.pdf - Installation Directory - C\Program
Files\CruiseControl\ - bin\cruisecontrol.bat
- Build Directory - C\builds\
- artifacts\ - files to be delivered
- checkout\ - the source to build
- logs\ - the details about each build
- config.xml the config file for Cruise Control
23Installation Tips
- Remember to do a cvs login before your cvs
checkout. Use the command line cvs.exe. - Run your projects ant script from the command
line to test it, not through your IDE. - Use a small Ant build script to wrap your
projects actual build script. - Share the artifacts directory.
- Run Cruise Control from the command line before
you set it up as a service. - Remember to change the user that the Windows
service runs under to be the same user that
executed the cvs login. - Plan for having multiple projects.
- Cruise Control does not make any assumptions
about directory structure, but the reporting
application does.
24Reporting Web-application
- Deploy it to any servlet container on the same
machine. - Modify two parameters in the web.xml file.
ltcontext-paramgt ltparam-namegtlogDirlt/param-na
megt ltparam-valuegtc\builds\logslt/param-value
gt lt/context-paramgt ltservletgt
ltservlet-namegtArtifactServletlt/servlet-namegt
ltservlet-classgtnet.sourceforge.cruisecontrol.se
rvlet.FileServletlt/servlet-classgt
ltinit-paramgt ltparam-namegtrootDirlt/para
m-namegt ltparam-valuegtc\builds\artifac
ts\lt/param-valuegt lt/init-paramgt lt/servletgt
25Cruise Control does
- It runs your build script whenever you commit a
change to your source repository. - It allows you to schedule nightly builds.
- It allows you to run on-demand builds.
- It notifies you of the results of those builds.
- It simplifies release management.
26Cruise Control does not
- It does not write your build script for you.
- It does not write your unit tests for you.
- It does not automatically resolve project
dependencies.
27What does it cost?
- Free, Open Source Software
- One time costs
- 500 for a dedicated build machine
- 4 hours configuration time for a first-timer, 2
hours for an experienced Cruise Control user. - Recurring costs
- 20 minutes to set up a new project
- Electricity
- Disk space
28The Bottom Line
- It takes practically nothing to set it up.
- At a minimum, use it for nightly builds.
- As the number of developers increases, it becomes
more valuable. - As the number of releases increases, it becomes
more valuable. - As the number of unit tests increases, it becomes
more valuable.
29Links
- Article by Jeffrey Fredrick on Continuous
Integration using Cruise Control - http//www.stickyminds.com/BetterSoftware/magazine
.asp?fncifeaid58 - Continuous Integration Toolkit comparison Matrix
- http//docs.codehaus.org/display/DAMAGECONTROL/Con
tinuousIntegrationServerFeatureMatrix - Cruise Control Website
- http//cruisecontrol.sourceforge.net
- Ant Website
- http//ant.apache.org
- Pragmatic Project Automation by Mike Clark
- http//www.pragmaticprogrammer.com/sk/auto/