release buildbot-0.7.7
[buildbot.git] / docs / buildbot.texinfo
blobe37b615ddedcdd8c3677dc96a92203df27f7e438
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename buildbot.info
4 @settitle BuildBot Manual 0.7.7
5 @defcodeindex cs
6 @defcodeindex sl
7 @defcodeindex bf
8 @defcodeindex bs
9 @defcodeindex st
10 @defcodeindex bc
11 @c %**end of header
13 @c these indices are for classes useful in a master.cfg config file
14 @c @csindex : Change Sources
15 @c @slindex : Schedulers and Locks
16 @c @bfindex : Build Factories
17 @c @bsindex : Build Steps
18 @c @stindex : Status Targets
20 @c @bcindex : keys that make up BuildmasterConfig
22 @copying
23 This is the BuildBot manual.
25 Copyright (C) 2005,2006 Brian Warner
27 Copying and distribution of this file, with or without
28 modification, are permitted in any medium without royalty
29 provided the copyright notice and this notice are preserved.
31 @end copying
33 @titlepage
34 @title BuildBot
35 @page
36 @vskip 0pt plus 1filll
37 @insertcopying
38 @end titlepage
40 @c Output the table of the contents at the beginning.
41 @contents
43 @ifnottex
44 @node Top, Introduction, (dir), (dir)
45 @top BuildBot
47 @insertcopying
48 @end ifnottex
50 @menu
51 * Introduction::                What the BuildBot does.
52 * Installation::                Creating a buildmaster and buildslaves,
53                                 running them.
54 * Concepts::                    What goes on in the buildbot's little mind.
55 * Configuration::               Controlling the buildbot.
56 * Getting Source Code Changes::  Discovering when to run a build.
57 * Build Process::               Controlling how each build is run.
58 * Status Delivery::             Telling the world about the build's results.
59 * Command-line tool::           
60 * Resources::                   Getting help.
61 * Developer's Appendix::        
62 * Index of Useful Classes::     
63 * Index of master.cfg keys::    
64 * Index::                       Complete index.
66 @detailmenu
67  --- The Detailed Node Listing ---
69 Introduction
71 * History and Philosophy::      
72 * System Architecture::         
73 * Control Flow::                
75 System Architecture
77 * BuildSlave Connections::      
78 * Buildmaster Architecture::    
79 * Status Delivery Architecture::  
81 Installation
83 * Requirements::                
84 * Installing the code::         
85 * Creating a buildmaster::      
86 * Upgrading an Existing Buildmaster::  
87 * Creating a buildslave::       
88 * Launching the daemons::       
89 * Logfiles::                    
90 * Shutdown::                    
91 * Maintenance::                 
92 * Troubleshooting::             
94 Creating a buildslave
96 * Buildslave Options::          
98 Troubleshooting
100 * Starting the buildslave::     
101 * Connecting to the buildmaster::  
102 * Forcing Builds::              
104 Concepts
106 * Version Control Systems::     
107 * Schedulers::                  
108 * BuildSet::                    
109 * BuildRequest::                
110 * Builder::                     
111 * Users::                       
113 Version Control Systems
115 * Generalizing VC Systems::     
116 * Source Tree Specifications::  
117 * How Different VC Systems Specify Sources::  
118 * Attributes of Changes::       
120 Users
122 * Doing Things With Users::     
123 * Email Addresses::             
124 * IRC Nicknames::               
125 * Live Status Clients::         
127 Configuration
129 * Config File Format::          
130 * Loading the Config File::     
131 * Testing the Config File::     
132 * Defining the Project::        
133 * Listing Change Sources and Schedulers::  
134 * Setting the slaveport::       
135 * Buildslave Specifiers::       
136 * Defining Builders::           
137 * Defining Status Targets::     
138 * Debug options::               
140 Listing Change Sources and Schedulers
142 * Scheduler Types::             
143 * Build Dependencies::          
145 Buildslave Specifiers
147 * When Buildslaves Go Missing::  
149 Getting Source Code Changes
151 * Change Sources::              
152 * Choosing ChangeSources::      
153 * CVSToys - PBService::         
154 * Mail-parsing ChangeSources::  
155 * PBChangeSource::              
156 * P4Source::                    
157 * BonsaiPoller::                
158 * SVNPoller::                   
159 * MercurialHook::               
161 Mail-parsing ChangeSources
163 * Subscribing the Buildmaster::  
164 * Using Maildirs::              
165 * Parsing Email Change Messages::  
167 Parsing Email Change Messages
169 * FCMaildirSource::             
170 * SyncmailMaildirSource::       
171 * BonsaiMaildirSource::         
172 * SVNCommitEmailMaildirSource::  
174 Build Process
176 * Build Steps::                 
177 * Interlocks::                  
178 * Build Factories::             
180 Build Steps
182 * Common Parameters::           
183 * Source Checkout::             
184 * ShellCommand::                
185 * Simple ShellCommand Subclasses::  
186 * Python BuildSteps::           
187 * Transferring Files::          
188 * Triggering Schedulers::       
189 * Writing New BuildSteps::      
191 Source Checkout
193 * CVS::                         
194 * SVN::                         
195 * Darcs::                       
196 * Mercurial::                   
197 * Arch::                        
198 * Bazaar::                      
199 * Bzr::                         
200 * P4::                          
201 * Git::                         
203 Simple ShellCommand Subclasses
205 * Configure::                   
206 * Compile::                     
207 * Test::                        
208 * TreeSize::                    
209 * Build Properties::            
211 Python BuildSteps
213 * BuildEPYDoc::                 
214 * PyFlakes::                    
216 Writing New BuildSteps
218 * BuildStep LogFiles::          
219 * Reading Logfiles::            
220 * Adding LogObservers::         
221 * BuildStep URLs::              
223 Build Factories
225 * BuildStep Objects::           
226 * BuildFactory::                
227 * Process-Specific build factories::  
229 BuildStep Objects
231 * BuildFactory Attributes::     
232 * Quick builds::                
234 BuildFactory
236 * BuildFactory Attributes::     
237 * Quick builds::                
239 Process-Specific build factories
241 * GNUAutoconf::                 
242 * CPAN::                        
243 * Python distutils::            
244 * Python/Twisted/trial projects::  
246 Status Delivery
248 * WebStatus::                   
249 * MailNotifier::                
250 * IRC Bot::                     
251 * PBListener::                  
252 * Writing New Status Plugins::  
254 WebStatus
256 * WebStatus Configuration Parameters::  
257 * Buildbot Web Resources::      
258 * XMLRPC server::               
259 * HTML Waterfall::              
261 Command-line tool
263 * Administrator Tools::         
264 * Developer Tools::             
265 * Other Tools::                 
266 * .buildbot config directory::  
268 Developer Tools
270 * statuslog::                   
271 * statusgui::                   
272 * try::                         
274 waiting for results
276 * try --diff::                  
278 Other Tools
280 * sendchange::                  
281 * debugclient::                 
283 @end detailmenu
284 @end menu
286 @node Introduction, Installation, Top, Top
287 @chapter Introduction
289 @cindex introduction
291 The BuildBot is a system to automate the compile/test cycle required by most
292 software projects to validate code changes. By automatically rebuilding and
293 testing the tree each time something has changed, build problems are
294 pinpointed quickly, before other developers are inconvenienced by the
295 failure. The guilty developer can be identified and harassed without human
296 intervention. By running the builds on a variety of platforms, developers
297 who do not have the facilities to test their changes everywhere before
298 checkin will at least know shortly afterwards whether they have broken the
299 build or not. Warning counts, lint checks, image size, compile time, and
300 other build parameters can be tracked over time, are more visible, and
301 are therefore easier to improve.
303 The overall goal is to reduce tree breakage and provide a platform to
304 run tests or code-quality checks that are too annoying or pedantic for
305 any human to waste their time with. Developers get immediate (and
306 potentially public) feedback about their changes, encouraging them to
307 be more careful about testing before checkin.
309 Features:
311 @itemize @bullet
312 @item
313 run builds on a variety of slave platforms
314 @item
315 arbitrary build process: handles projects using C, Python, whatever
316 @item
317 minimal host requirements: python and Twisted
318 @item
319 slaves can be behind a firewall if they can still do checkout
320 @item
321 status delivery through web page, email, IRC, other protocols
322 @item
323 track builds in progress, provide estimated completion time
324 @item
325 flexible configuration by subclassing generic build process classes
326 @item
327 debug tools to force a new build, submit fake Changes, query slave status
328 @item
329 released under the GPL
330 @end itemize
332 @menu
333 * History and Philosophy::      
334 * System Architecture::         
335 * Control Flow::                
336 @end menu
339 @node History and Philosophy, System Architecture, Introduction, Introduction
340 @section History and Philosophy
342 @cindex Philosophy of operation
344 The Buildbot was inspired by a similar project built for a development
345 team writing a cross-platform embedded system. The various components
346 of the project were supposed to compile and run on several flavors of
347 unix (linux, solaris, BSD), but individual developers had their own
348 preferences and tended to stick to a single platform. From time to
349 time, incompatibilities would sneak in (some unix platforms want to
350 use @code{string.h}, some prefer @code{strings.h}), and then the tree
351 would compile for some developers but not others. The buildbot was
352 written to automate the human process of walking into the office,
353 updating a tree, compiling (and discovering the breakage), finding the
354 developer at fault, and complaining to them about the problem they had
355 introduced. With multiple platforms it was difficult for developers to
356 do the right thing (compile their potential change on all platforms);
357 the buildbot offered a way to help.
359 Another problem was when programmers would change the behavior of a
360 library without warning its users, or change internal aspects that
361 other code was (unfortunately) depending upon. Adding unit tests to
362 the codebase helps here: if an application's unit tests pass despite
363 changes in the libraries it uses, you can have more confidence that
364 the library changes haven't broken anything. Many developers
365 complained that the unit tests were inconvenient or took too long to
366 run: having the buildbot run them reduces the developer's workload to
367 a minimum.
369 In general, having more visibility into the project is always good,
370 and automation makes it easier for developers to do the right thing.
371 When everyone can see the status of the project, developers are
372 encouraged to keep the tree in good working order. Unit tests that
373 aren't run on a regular basis tend to suffer from bitrot just like
374 code does: exercising them on a regular basis helps to keep them
375 functioning and useful.
377 The current version of the Buildbot is additionally targeted at
378 distributed free-software projects, where resources and platforms are
379 only available when provided by interested volunteers. The buildslaves
380 are designed to require an absolute minimum of configuration, reducing
381 the effort a potential volunteer needs to expend to be able to
382 contribute a new test environment to the project. The goal is for
383 anyone who wishes that a given project would run on their favorite
384 platform should be able to offer that project a buildslave, running on
385 that platform, where they can verify that their portability code
386 works, and keeps working.
388 @node System Architecture, Control Flow, History and Philosophy, Introduction
389 @comment  node-name,  next,  previous,  up
390 @section System Architecture
392 The Buildbot consists of a single @code{buildmaster} and one or more
393 @code{buildslaves}, connected in a star topology. The buildmaster
394 makes all decisions about what, when, and how to build. It sends
395 commands to be run on the build slaves, which simply execute the
396 commands and return the results. (certain steps involve more local
397 decision making, where the overhead of sending a lot of commands back
398 and forth would be inappropriate, but in general the buildmaster is
399 responsible for everything).
401 The buildmaster is usually fed @code{Changes} by some sort of version
402 control system (@pxref{Change Sources}), which may cause builds to be
403 run. As the builds are performed, various status messages are
404 produced, which are then sent to any registered Status Targets
405 (@pxref{Status Delivery}).
407 @c @image{FILENAME, WIDTH, HEIGHT, ALTTEXT, EXTENSION}
408 @image{images/overview,,,Overview Diagram,}
410 The buildmaster is configured and maintained by the ``buildmaster
411 admin'', who is generally the project team member responsible for
412 build process issues. Each buildslave is maintained by a ``buildslave
413 admin'', who do not need to be quite as involved. Generally slaves are
414 run by anyone who has an interest in seeing the project work well on
415 their favorite platform.
417 @menu
418 * BuildSlave Connections::      
419 * Buildmaster Architecture::    
420 * Status Delivery Architecture::  
421 @end menu
423 @node BuildSlave Connections, Buildmaster Architecture, System Architecture, System Architecture
424 @subsection BuildSlave Connections
426 The buildslaves are typically run on a variety of separate machines,
427 at least one per platform of interest. These machines connect to the
428 buildmaster over a TCP connection to a publically-visible port. As a
429 result, the buildslaves can live behind a NAT box or similar
430 firewalls, as long as they can get to buildmaster. The TCP connections
431 are initiated by the buildslave and accepted by the buildmaster, but
432 commands and results travel both ways within this connection. The
433 buildmaster is always in charge, so all commands travel exclusively
434 from the buildmaster to the buildslave.
436 To perform builds, the buildslaves must typically obtain source code
437 from a CVS/SVN/etc repository. Therefore they must also be able to
438 reach the repository. The buildmaster provides instructions for
439 performing builds, but does not provide the source code itself.
441 @image{images/slaves,,,BuildSlave Connections,}
443 @node Buildmaster Architecture, Status Delivery Architecture, BuildSlave Connections, System Architecture
444 @subsection Buildmaster Architecture
446 The Buildmaster consists of several pieces:
448 @image{images/master,,,BuildMaster Architecture,}
450 @itemize @bullet
452 @item
453 Change Sources, which create a Change object each time something is
454 modified in the VC repository. Most ChangeSources listen for messages
455 from a hook script of some sort. Some sources actively poll the
456 repository on a regular basis. All Changes are fed to the Schedulers.
458 @item
459 Schedulers, which decide when builds should be performed. They collect
460 Changes into BuildRequests, which are then queued for delivery to
461 Builders until a buildslave is available.
463 @item
464 Builders, which control exactly @emph{how} each build is performed
465 (with a series of BuildSteps, configured in a BuildFactory). Each
466 Build is run on a single buildslave.
468 @item
469 Status plugins, which deliver information about the build results
470 through protocols like HTTP, mail, and IRC.
472 @end itemize
474 @image{images/slavebuilder,,,SlaveBuilders,}
476 Each Builder is configured with a list of BuildSlaves that it will use
477 for its builds. These buildslaves are expected to behave identically:
478 the only reason to use multiple BuildSlaves for a single Builder is to
479 provide a measure of load-balancing.
481 Within a single BuildSlave, each Builder creates its own SlaveBuilder
482 instance. These SlaveBuilders operate independently from each other.
483 Each gets its own base directory to work in. It is quite common to
484 have many Builders sharing the same buildslave. For example, there
485 might be two buildslaves: one for i386, and a second for PowerPC.
486 There may then be a pair of Builders that do a full compile/test run,
487 one for each architecture, and a lone Builder that creates snapshot
488 source tarballs if the full builders complete successfully. The full
489 builders would each run on a single buildslave, whereas the tarball
490 creation step might run on either buildslave (since the platform
491 doesn't matter when creating source tarballs). In this case, the
492 mapping would look like:
494 @example
495 Builder(full-i386)  ->  BuildSlaves(slave-i386)
496 Builder(full-ppc)   ->  BuildSlaves(slave-ppc)
497 Builder(source-tarball) -> BuildSlaves(slave-i386, slave-ppc)
498 @end example
500 and each BuildSlave would have two SlaveBuilders inside it, one for a
501 full builder, and a second for the source-tarball builder.
503 Once a SlaveBuilder is available, the Builder pulls one or more
504 BuildRequests off its incoming queue. (It may pull more than one if it
505 determines that it can merge the requests together; for example, there
506 may be multiple requests to build the current HEAD revision). These
507 requests are merged into a single Build instance, which includes the
508 SourceStamp that describes what exact version of the source code
509 should be used for the build. The Build is then randomly assigned to a
510 free SlaveBuilder and the build begins.
513 @node Status Delivery Architecture,  , Buildmaster Architecture, System Architecture
514 @subsection Status Delivery Architecture
516 The buildmaster maintains a central Status object, to which various
517 status plugins are connected. Through this Status object, a full
518 hierarchy of build status objects can be obtained.
520 @image{images/status,,,Status Delivery,}
522 The configuration file controls which status plugins are active. Each
523 status plugin gets a reference to the top-level Status object. From
524 there they can request information on each Builder, Build, Step, and
525 LogFile. This query-on-demand interface is used by the html.Waterfall
526 plugin to create the main status page each time a web browser hits the
527 main URL.
529 The status plugins can also subscribe to hear about new Builds as they
530 occur: this is used by the MailNotifier to create new email messages
531 for each recently-completed Build.
533 The Status object records the status of old builds on disk in the
534 buildmaster's base directory. This allows it to return information
535 about historical builds.
537 There are also status objects that correspond to Schedulers and
538 BuildSlaves. These allow status plugins to report information about
539 upcoming builds, and the online/offline status of each buildslave.
542 @node Control Flow,  , System Architecture, Introduction
543 @comment  node-name,  next,  previous,  up
544 @section Control Flow
546 A day in the life of the buildbot:
548 @itemize @bullet
550 @item
551 A developer commits some source code changes to the repository. A hook
552 script or commit trigger of some sort sends information about this
553 change to the buildmaster through one of its configured Change
554 Sources. This notification might arrive via email, or over a network
555 connection (either initiated by the buildmaster as it ``subscribes''
556 to changes, or by the commit trigger as it pushes Changes towards the
557 buildmaster). The Change contains information about who made the
558 change, what files were modified, which revision contains the change,
559 and any checkin comments.
561 @item
562 The buildmaster distributes this change to all of its configured
563 Schedulers. Any ``important'' changes cause the ``tree-stable-timer''
564 to be started, and the Change is added to a list of those that will go
565 into a new Build. When the timer expires, a Build is started on each
566 of a set of configured Builders, all compiling/testing the same source
567 code. Unless configured otherwise, all Builds run in parallel on the
568 various buildslaves.
570 @item
571 The Build consists of a series of Steps. Each Step causes some number
572 of commands to be invoked on the remote buildslave associated with
573 that Builder. The first step is almost always to perform a checkout of
574 the appropriate revision from the same VC system that produced the
575 Change. The rest generally perform a compile and run unit tests. As
576 each Step runs, the buildslave reports back command output and return
577 status to the buildmaster.
579 @item
580 As the Build runs, status messages like ``Build Started'', ``Step
581 Started'', ``Build Finished'', etc, are published to a collection of
582 Status Targets. One of these targets is usually the HTML ``Waterfall''
583 display, which shows a chronological list of events, and summarizes
584 the results of the most recent build at the top of each column.
585 Developers can periodically check this page to see how their changes
586 have fared. If they see red, they know that they've made a mistake and
587 need to fix it. If they see green, they know that they've done their
588 duty and don't need to worry about their change breaking anything.
590 @item
591 If a MailNotifier status target is active, the completion of a build
592 will cause email to be sent to any developers whose Changes were
593 incorporated into this Build. The MailNotifier can be configured to
594 only send mail upon failing builds, or for builds which have just
595 transitioned from passing to failing. Other status targets can provide
596 similar real-time notification via different communication channels,
597 like IRC.
599 @end itemize
602 @node Installation, Concepts, Introduction, Top
603 @chapter Installation
605 @menu
606 * Requirements::                
607 * Installing the code::         
608 * Creating a buildmaster::      
609 * Upgrading an Existing Buildmaster::  
610 * Creating a buildslave::       
611 * Launching the daemons::       
612 * Logfiles::                    
613 * Shutdown::                    
614 * Maintenance::                 
615 * Troubleshooting::             
616 @end menu
618 @node Requirements, Installing the code, Installation, Installation
619 @section Requirements
621 At a bare minimum, you'll need the following (for both the buildmaster
622 and a buildslave):
624 @itemize @bullet
625 @item
626 Python: http://www.python.org
628 Buildbot requires python-2.3 or later, and is primarily developed
629 against python-2.4. It is also tested against python-2.5 .
631 @item
632 Twisted: http://twistedmatrix.com
634 Both the buildmaster and the buildslaves require Twisted-2.0.x or
635 later. It has been tested against all releases of Twisted up to
636 Twisted-2.5.0 (the most recent as of this writing). As always, the
637 most recent version is recommended.
639 Twisted is delivered as a collection of subpackages. You'll need at
640 least "Twisted" (the core package), and you'll also want TwistedMail,
641 TwistedWeb, and TwistedWords (for sending email, serving a web status
642 page, and delivering build status via IRC, respectively). You might
643 also want TwistedConch (for the encrypted Manhole debug port). Note
644 that Twisted requires ZopeInterface to be installed as well.
646 @end itemize
648 Certain other packages may be useful on the system running the
649 buildmaster:
651 @itemize @bullet
652 @item
653 CVSToys: http://purl.net/net/CVSToys
655 If your buildmaster uses FreshCVSSource to receive change notification
656 from a cvstoys daemon, it will require CVSToys be installed (tested
657 with CVSToys-1.0.10). If the it doesn't use that source (i.e. if you
658 only use a mail-parsing change source, or the SVN notification
659 script), you will not need CVSToys.
661 @end itemize
663 And of course, your project's build process will impose additional
664 requirements on the buildslaves. These hosts must have all the tools
665 necessary to compile and test your project's source code.
668 @node Installing the code, Creating a buildmaster, Requirements, Installation
669 @section Installing the code
671 @cindex installation
673 The Buildbot is installed using the standard python @code{distutils}
674 module. After unpacking the tarball, the process is:
676 @example
677 python setup.py build
678 python setup.py install
679 @end example
681 where the install step may need to be done as root. This will put the
682 bulk of the code in somewhere like
683 /usr/lib/python2.3/site-packages/buildbot . It will also install the
684 @code{buildbot} command-line tool in /usr/bin/buildbot.
686 To test this, shift to a different directory (like /tmp), and run:
688 @example
689 buildbot --version
690 @end example
692 If it shows you the versions of Buildbot and Twisted, the install went
693 ok. If it says @code{no such command} or it gets an @code{ImportError}
694 when it tries to load the libaries, then something went wrong.
695 @code{pydoc buildbot} is another useful diagnostic tool.
697 Windows users will find these files in other places. You will need to
698 make sure that python can find the libraries, and will probably find
699 it convenient to have @code{buildbot} on your PATH.
701 If you wish, you can run the buildbot unit test suite like this:
703 @example
704 PYTHONPATH=. trial buildbot.test
705 @end example
707 This should run up to 192 tests, depending upon what VC tools you have
708 installed. On my desktop machine it takes about five minutes to
709 complete. Nothing should fail, a few might be skipped. If any of the
710 tests fail, you should stop and investigate the cause before
711 continuing the installation process, as it will probably be easier to
712 track down the bug early.
714 If you cannot or do not wish to install the buildbot into a site-wide
715 location like @file{/usr} or @file{/usr/local}, you can also install
716 it into the account's home directory. Do the install command like
717 this:
719 @example
720 python setup.py install --home=~
721 @end example
723 That will populate @file{~/lib/python} and create
724 @file{~/bin/buildbot}. Make sure this lib directory is on your
725 @code{PYTHONPATH}.
728 @node Creating a buildmaster, Upgrading an Existing Buildmaster, Installing the code, Installation
729 @section Creating a buildmaster
731 As you learned earlier (@pxref{System Architecture}), the buildmaster
732 runs on a central host (usually one that is publically visible, so
733 everybody can check on the status of the project), and controls all
734 aspects of the buildbot system. Let us call this host
735 @code{buildbot.example.org}.
737 You may wish to create a separate user account for the buildmaster,
738 perhaps named @code{buildmaster}. This can help keep your personal
739 configuration distinct from that of the buildmaster and is useful if
740 you have to use a mail-based notification system (@pxref{Change
741 Sources}). However, the Buildbot will work just fine with your regular
742 user account.
744 You need to choose a directory for the buildmaster, called the
745 @code{basedir}. This directory will be owned by the buildmaster, which
746 will use configuration files therein, and create status files as it
747 runs. @file{~/Buildbot} is a likely value. If you run multiple
748 buildmasters in the same account, or if you run both masters and
749 slaves, you may want a more distinctive name like
750 @file{~/Buildbot/master/gnomovision} or
751 @file{~/Buildmasters/fooproject}. If you are using a separate user
752 account, this might just be @file{~buildmaster/masters/fooproject}.
754 Once you've picked a directory, use the @command{buildbot
755 create-master} command to create the directory and populate it with
756 startup files:
758 @example
759 buildbot create-master @var{basedir}
760 @end example
762 You will need to create a configuration file (@pxref{Configuration})
763 before starting the buildmaster. Most of the rest of this manual is
764 dedicated to explaining how to do this. A sample configuration file is
765 placed in the working directory, named @file{master.cfg.sample}, which
766 can be copied to @file{master.cfg} and edited to suit your purposes.
768 (Internal details: This command creates a file named
769 @file{buildbot.tac} that contains all the state necessary to create
770 the buildmaster. Twisted has a tool called @code{twistd} which can use
771 this .tac file to create and launch a buildmaster instance. twistd
772 takes care of logging and daemonization (running the program in the
773 background). @file{/usr/bin/buildbot} is a front end which runs twistd
774 for you.)
776 In addition to @file{buildbot.tac}, a small @file{Makefile.sample} is
777 installed. This can be used as the basis for customized daemon startup,
778 @xref{Launching the daemons}.
780 @node Upgrading an Existing Buildmaster, Creating a buildslave, Creating a buildmaster, Installation
781 @section Upgrading an Existing Buildmaster
783 If you have just installed a new version of the Buildbot code, and you
784 have buildmasters that were created using an older version, you'll
785 need to upgrade these buildmasters before you can use them. The
786 upgrade process adds and modifies files in the buildmaster's base
787 directory to make it compatible with the new code.
789 @example
790 buildbot upgrade-master @var{basedir}
791 @end example
793 This command will also scan your @file{master.cfg} file for
794 incompatbilities (by loading it and printing any errors or deprecation
795 warnings that occur). Each buildbot release tries to be compatible
796 with configurations that worked cleanly (i.e. without deprecation
797 warnings) on the previous release: any functions or classes that are
798 to be removed will first be deprecated in a release, to give users a
799 chance to start using their replacement.
801 The 0.7.6 release introduced the @file{public_html/} directory, which
802 contains @file{index.html} and other files served by the
803 @code{WebStatus} and @code{Waterfall} status displays. The
804 @code{upgrade-master} command will create these files if they do not
805 already exist. It will not modify existing copies, but it will write a
806 new copy in e.g. @file{index.html.new} if the new version differs from
807 the version that already exists.
809 The @code{upgrade-master} command is idempotent. It is safe to run it
810 multiple times. After each upgrade of the buildbot code, you should
811 use @code{upgrade-master} on all your buildmasters.
814 @node Creating a buildslave, Launching the daemons, Upgrading an Existing Buildmaster, Installation
815 @section Creating a buildslave
817 Typically, you will be adding a buildslave to an existing buildmaster,
818 to provide additional architecture coverage. The buildbot
819 administrator will give you several pieces of information necessary to
820 connect to the buildmaster. You should also be somewhat familiar with
821 the project being tested, so you can troubleshoot build problems
822 locally.
824 The buildbot exists to make sure that the project's stated ``how to
825 build it'' process actually works. To this end, the buildslave should
826 run in an environment just like that of your regular developers.
827 Typically the project build process is documented somewhere
828 (@file{README}, @file{INSTALL}, etc), in a document that should
829 mention all library dependencies and contain a basic set of build
830 instructions. This document will be useful as you configure the host
831 and account in which the buildslave runs.
833 Here's a good checklist for setting up a buildslave:
835 @enumerate
836 @item
837 Set up the account
839 It is recommended (although not mandatory) to set up a separate user
840 account for the buildslave. This account is frequently named
841 @code{buildbot} or @code{buildslave}. This serves to isolate your
842 personal working environment from that of the slave's, and helps to
843 minimize the security threat posed by letting possibly-unknown
844 contributors run arbitrary code on your system. The account should
845 have a minimum of fancy init scripts.
847 @item
848 Install the buildbot code
850 Follow the instructions given earlier (@pxref{Installing the code}).
851 If you use a separate buildslave account, and you didn't install the
852 buildbot code to a shared location, then you will need to install it
853 with @code{--home=~} for each account that needs it.
855 @item
856 Set up the host
858 Make sure the host can actually reach the buildmaster. Usually the
859 buildmaster is running a status webserver on the same machine, so
860 simply point your web browser at it and see if you can get there.
861 Install whatever additional packages or libraries the project's
862 INSTALL document advises. (or not: if your buildslave is supposed to
863 make sure that building without optional libraries still works, then
864 don't install those libraries).
866 Again, these libraries don't necessarily have to be installed to a
867 site-wide shared location, but they must be available to your build
868 process. Accomplishing this is usually very specific to the build
869 process, so installing them to @file{/usr} or @file{/usr/local} is
870 usually the best approach.
872 @item
873 Test the build process
875 Follow the instructions in the INSTALL document, in the buildslave's
876 account. Perform a full CVS (or whatever) checkout, configure, make,
877 run tests, etc. Confirm that the build works without manual fussing.
878 If it doesn't work when you do it by hand, it will be unlikely to work
879 when the buildbot attempts to do it in an automated fashion.
881 @item
882 Choose a base directory
884 This should be somewhere in the buildslave's account, typically named
885 after the project which is being tested. The buildslave will not touch
886 any file outside of this directory. Something like @file{~/Buildbot}
887 or @file{~/Buildslaves/fooproject} is appropriate.
889 @item
890 Get the buildmaster host/port, botname, and password
892 When the buildbot admin configures the buildmaster to accept and use
893 your buildslave, they will provide you with the following pieces of
894 information:
896 @itemize @bullet
897 @item
898 your buildslave's name
899 @item
900 the password assigned to your buildslave
901 @item
902 the hostname and port number of the buildmaster, i.e. buildbot.example.org:8007
903 @end itemize
905 @item
906 Create the buildslave
908 Now run the 'buildbot' command as follows:
910 @example
911 buildbot create-slave @var{BASEDIR} @var{MASTERHOST}:@var{PORT} @var{SLAVENAME} @var{PASSWORD}
912 @end example
914 This will create the base directory and a collection of files inside,
915 including the @file{buildbot.tac} file that contains all the
916 information you passed to the @code{buildbot} command.
918 @item
919 Fill in the hostinfo files
921 When it first connects, the buildslave will send a few files up to the
922 buildmaster which describe the host that it is running on. These files
923 are presented on the web status display so that developers have more
924 information to reproduce any test failures that are witnessed by the
925 buildbot. There are sample files in the @file{info} subdirectory of
926 the buildbot's base directory. You should edit these to correctly
927 describe you and your host.
929 @file{BASEDIR/info/admin} should contain your name and email address.
930 This is the ``buildslave admin address'', and will be visible from the
931 build status page (so you may wish to munge it a bit if
932 address-harvesting spambots are a concern).
934 @file{BASEDIR/info/host} should be filled with a brief description of
935 the host: OS, version, memory size, CPU speed, versions of relevant
936 libraries installed, and finally the version of the buildbot code
937 which is running the buildslave.
939 If you run many buildslaves, you may want to create a single
940 @file{~buildslave/info} file and share it among all the buildslaves
941 with symlinks.
943 @end enumerate
945 @menu
946 * Buildslave Options::          
947 @end menu
949 @node Buildslave Options,  , Creating a buildslave, Creating a buildslave
950 @subsection Buildslave Options
952 There are a handful of options you might want to use when creating the
953 buildslave with the @command{buildbot create-slave <options> DIR <params>}
954 command. You can type @command{buildbot create-slave --help} for a summary.
955 To use these, just include them on the @command{buildbot create-slave}
956 command line, like this:
958 @example
959 buildbot create-slave --umask=022 ~/buildslave buildmaster.example.org:42012 myslavename mypasswd
960 @end example
962 @table @code
963 @item --usepty
964 This is a boolean flag that tells the buildslave whether to launch
965 child processes in a PTY (the default) or with regular pipes. The
966 advantage of using a PTY is that ``grandchild'' processes are more
967 likely to be cleaned up if the build is interrupted or times out
968 (since it enables the use of a ``process group'' in which all child
969 processes will be placed). The disadvantages: some forms of Unix have
970 problems with PTYs, some of your unit tests may behave differently
971 when run under a PTY (generally those which check to see if they are
972 being run interactively), and PTYs will merge the stdout and stderr
973 streams into a single output stream (which means the red-vs-black
974 coloring in the logfiles will be lost). If you encounter problems, you
975 can add @code{--usepty=0} to disable the use of PTYs. Note that
976 windows buildslaves never use PTYs.
978 @item --umask
979 This is a string (generally an octal representation of an integer)
980 which will cause the buildslave process' ``umask'' value to be set
981 shortly after initialization. The ``twistd'' daemonization utility
982 forces the umask to 077 at startup (which means that all files created
983 by the buildslave or its child processes will be unreadable by any
984 user other than the buildslave account). If you want build products to
985 be readable by other accounts, you can add @code{--umask=022} to tell
986 the buildslave to fix the umask after twistd clobbers it. If you want
987 build products to be @emph{writable} by other accounts too, use
988 @code{--umask=000}, but this is likely to be a security problem.
990 @item --keepalive
991 This is a number that indicates how frequently ``keepalive'' messages
992 should be sent from the buildslave to the buildmaster, expressed in
993 seconds. The default (600) causes a message to be sent to the
994 buildmaster at least once every 10 minutes. To set this to a lower
995 value, use e.g. @code{--keepalive=120}.
997 If the buildslave is behind a NAT box or stateful firewall, these
998 messages may help to keep the connection alive: some NAT boxes tend to
999 forget about a connection if it has not been used in a while. When
1000 this happens, the buildmaster will think that the buildslave has
1001 disappeared, and builds will time out. Meanwhile the buildslave will
1002 not realize than anything is wrong.
1004 @end table
1007 @node Launching the daemons, Logfiles, Creating a buildslave, Installation
1008 @section Launching the daemons
1010 Both the buildmaster and the buildslave run as daemon programs. To
1011 launch them, pass the working directory to the @code{buildbot}
1012 command:
1014 @example
1015 buildbot start @var{BASEDIR}
1016 @end example
1018 This command will start the daemon and then return, so normally it
1019 will not produce any output. To verify that the programs are indeed
1020 running, look for a pair of files named @file{twistd.log} and
1021 @file{twistd.pid} that should be created in the working directory.
1022 @file{twistd.pid} contains the process ID of the newly-spawned daemon.
1024 When the buildslave connects to the buildmaster, new directories will
1025 start appearing in its base directory. The buildmaster tells the slave
1026 to create a directory for each Builder which will be using that slave.
1027 All build operations are performed within these directories: CVS
1028 checkouts, compiles, and tests.
1030 Once you get everything running, you will want to arrange for the
1031 buildbot daemons to be started at boot time. One way is to use
1032 @code{cron}, by putting them in a @@reboot crontab entry@footnote{this
1033 @@reboot syntax is understood by Vixie cron, which is the flavor
1034 usually provided with linux systems. Other unices may have a cron that
1035 doesn't understand @@reboot}:
1037 @example
1038 @@reboot buildbot start @var{BASEDIR}
1039 @end example
1041 When you run @command{crontab} to set this up, remember to do it as
1042 the buildmaster or buildslave account! If you add this to your crontab
1043 when running as your regular account (or worse yet, root), then the
1044 daemon will run as the wrong user, quite possibly as one with more
1045 authority than you intended to provide.
1047 It is important to remember that the environment provided to cron jobs
1048 and init scripts can be quite different that your normal runtime.
1049 There may be fewer environment variables specified, and the PATH may
1050 be shorter than usual. It is a good idea to test out this method of
1051 launching the buildslave by using a cron job with a time in the near
1052 future, with the same command, and then check @file{twistd.log} to
1053 make sure the slave actually started correctly. Common problems here
1054 are for @file{/usr/local} or @file{~/bin} to not be on your
1055 @code{PATH}, or for @code{PYTHONPATH} to not be set correctly.
1056 Sometimes @code{HOME} is messed up too.
1058 To modify the way the daemons are started (perhaps you want to set
1059 some environment variables first, or perform some cleanup each time),
1060 you can create a file named @file{Makefile.buildbot} in the base
1061 directory. When the @file{buildbot} front-end tool is told to
1062 @command{start} the daemon, and it sees this file (and
1063 @file{/usr/bin/make} exists), it will do @command{make -f
1064 Makefile.buildbot start} instead of its usual action (which involves
1065 running @command{twistd}). When the buildmaster or buildslave is
1066 installed, a @file{Makefile.sample} is created which implements the
1067 same behavior as the the @file{buildbot} tool uses, so if you want to
1068 customize the process, just copy @file{Makefile.sample} to
1069 @file{Makefile.buildbot} and edit it as necessary.
1071 @node Logfiles, Shutdown, Launching the daemons, Installation
1072 @section Logfiles
1074 @cindex logfiles
1076 While a buildbot daemon runs, it emits text to a logfile, named
1077 @file{twistd.log}. A command like @code{tail -f twistd.log} is useful
1078 to watch the command output as it runs.
1080 The buildmaster will announce any errors with its configuration file
1081 in the logfile, so it is a good idea to look at the log at startup
1082 time to check for any problems. Most buildmaster activities will cause
1083 lines to be added to the log.
1085 @node Shutdown, Maintenance, Logfiles, Installation
1086 @section Shutdown
1088 To stop a buildmaster or buildslave manually, use:
1090 @example
1091 buildbot stop @var{BASEDIR}
1092 @end example
1094 This simply looks for the @file{twistd.pid} file and kills whatever
1095 process is identified within.
1097 At system shutdown, all processes are sent a @code{SIGKILL}. The
1098 buildmaster and buildslave will respond to this by shutting down
1099 normally.
1101 The buildmaster will respond to a @code{SIGHUP} by re-reading its
1102 config file. Of course, this only works on unix-like systems with
1103 signal support, and won't work on Windows. The following shortcut is
1104 available:
1106 @example
1107 buildbot reconfig @var{BASEDIR}
1108 @end example
1110 When you update the Buildbot code to a new release, you will need to
1111 restart the buildmaster and/or buildslave before it can take advantage
1112 of the new code. You can do a @code{buildbot stop @var{BASEDIR}} and
1113 @code{buildbot start @var{BASEDIR}} in quick succession, or you can
1114 use the @code{restart} shortcut, which does both steps for you:
1116 @example
1117 buildbot restart @var{BASEDIR}
1118 @end example
1120 There are certain configuration changes that are not handled cleanly
1121 by @code{buildbot reconfig}. If this occurs, @code{buildbot restart}
1122 is a more robust tool to fully switch over to the new configuration.
1125 @node Maintenance, Troubleshooting, Shutdown, Installation
1126 @section Maintenance
1128 It is a good idea to check the buildmaster's status page every once in
1129 a while, to see if your buildslave is still online. Eventually the
1130 buildbot will probably be enhanced to send you email (via the
1131 @file{info/admin} email address) when the slave has been offline for
1132 more than a few hours.
1134 If you find you can no longer provide a buildslave to the project, please
1135 let the project admins know, so they can put out a call for a
1136 replacement.
1138 The Buildbot records status and logs output continually, each time a
1139 build is performed. The status tends to be small, but the build logs
1140 can become quite large. Each build and log are recorded in a separate
1141 file, arranged hierarchically under the buildmaster's base directory.
1142 To prevent these files from growing without bound, you should
1143 periodically delete old build logs. A simple cron job to delete
1144 anything older than, say, two weeks should do the job. The only trick
1145 is to leave the @file{buildbot.tac} and other support files alone, for
1146 which find's @code{-mindepth} argument helps skip everything in the
1147 top directory. You can use something like the following:
1149 @example
1150 @@weekly cd BASEDIR && find . -mindepth 2 -type f -mtime +14 -exec rm @{@} \;
1151 @@weekly cd BASEDIR && find twistd.log* -mtime +14 -exec rm @{@} \;
1152 @end example
1154 @node Troubleshooting,  , Maintenance, Installation
1155 @section Troubleshooting
1157 Here are a few hints on diagnosing common problems.
1159 @menu
1160 * Starting the buildslave::     
1161 * Connecting to the buildmaster::  
1162 * Forcing Builds::              
1163 @end menu
1165 @node Starting the buildslave, Connecting to the buildmaster, Troubleshooting, Troubleshooting
1166 @subsection Starting the buildslave
1168 Cron jobs are typically run with a minimal shell (@file{/bin/sh}, not
1169 @file{/bin/bash}), and tilde expansion is not always performed in such
1170 commands. You may want to use explicit paths, because the @code{PATH}
1171 is usually quite short and doesn't include anything set by your
1172 shell's startup scripts (@file{.profile}, @file{.bashrc}, etc). If
1173 you've installed buildbot (or other python libraries) to an unusual
1174 location, you may need to add a @code{PYTHONPATH} specification (note
1175 that python will do tilde-expansion on @code{PYTHONPATH} elements by
1176 itself). Sometimes it is safer to fully-specify everything:
1178 @example
1179 @@reboot PYTHONPATH=~/lib/python /usr/local/bin/buildbot start /usr/home/buildbot/basedir
1180 @end example
1182 Take the time to get the @@reboot job set up. Otherwise, things will work
1183 fine for a while, but the first power outage or system reboot you have will
1184 stop the buildslave with nothing but the cries of sorrowful developers to
1185 remind you that it has gone away.
1187 @node Connecting to the buildmaster, Forcing Builds, Starting the buildslave, Troubleshooting
1188 @subsection Connecting to the buildmaster
1190 If the buildslave cannot connect to the buildmaster, the reason should
1191 be described in the @file{twistd.log} logfile. Some common problems
1192 are an incorrect master hostname or port number, or a mistyped bot
1193 name or password. If the buildslave loses the connection to the
1194 master, it is supposed to attempt to reconnect with an
1195 exponentially-increasing backoff. Each attempt (and the time of the
1196 next attempt) will be logged. If you get impatient, just manually stop
1197 and re-start the buildslave.
1199 When the buildmaster is restarted, all slaves will be disconnected,
1200 and will attempt to reconnect as usual. The reconnect time will depend
1201 upon how long the buildmaster is offline (i.e. how far up the
1202 exponential backoff curve the slaves have travelled). Again,
1203 @code{buildbot stop @var{BASEDIR}; buildbot start @var{BASEDIR}} will
1204 speed up the process.
1206 @node Forcing Builds,  , Connecting to the buildmaster, Troubleshooting
1207 @subsection Forcing Builds
1209 From the buildmaster's main status web page, you can force a build to
1210 be run on your build slave. Figure out which column is for a builder
1211 that runs on your slave, click on that builder's name, and the page
1212 that comes up will have a ``Force Build'' button. Fill in the form,
1213 hit the button, and a moment later you should see your slave's
1214 @file{twistd.log} filling with commands being run. Using @code{pstree}
1215 or @code{top} should also reveal the cvs/make/gcc/etc processes being
1216 run by the buildslave. Note that the same web page should also show
1217 the @file{admin} and @file{host} information files that you configured
1218 earlier.
1220 @node Concepts, Configuration, Installation, Top
1221 @chapter Concepts
1223 This chapter defines some of the basic concepts that the Buildbot
1224 uses. You'll need to understand how the Buildbot sees the world to
1225 configure it properly.
1227 @menu
1228 * Version Control Systems::     
1229 * Schedulers::                  
1230 * BuildSet::                    
1231 * BuildRequest::                
1232 * Builder::                     
1233 * Users::                       
1234 @end menu
1236 @node Version Control Systems, Schedulers, Concepts, Concepts
1237 @section Version Control Systems
1239 @cindex Version Control
1241 These source trees come from a Version Control System of some kind.
1242 CVS and Subversion are two popular ones, but the Buildbot supports
1243 others. All VC systems have some notion of an upstream
1244 @code{repository} which acts as a server@footnote{except Darcs, but
1245 since the Buildbot never modifies its local source tree we can ignore
1246 the fact that Darcs uses a less centralized model}, from which clients
1247 can obtain source trees according to various parameters. The VC
1248 repository provides source trees of various projects, for different
1249 branches, and from various points in time. The first thing we have to
1250 do is to specify which source tree we want to get.
1252 @menu
1253 * Generalizing VC Systems::     
1254 * Source Tree Specifications::  
1255 * How Different VC Systems Specify Sources::  
1256 * Attributes of Changes::       
1257 @end menu
1259 @node Generalizing VC Systems, Source Tree Specifications, Version Control Systems, Version Control Systems
1260 @subsection Generalizing VC Systems
1262 For the purposes of the Buildbot, we will try to generalize all VC
1263 systems as having repositories that each provide sources for a variety
1264 of projects. Each project is defined as a directory tree with source
1265 files. The individual files may each have revisions, but we ignore
1266 that and treat the project as a whole as having a set of revisions
1267 (CVS is really the only VC system still in widespread use that has
1268 per-file revisions.. everything modern has moved to atomic tree-wide
1269 changesets). Each time someone commits a change to the project, a new
1270 revision becomes available. These revisions can be described by a
1271 tuple with two items: the first is a branch tag, and the second is
1272 some kind of revision stamp or timestamp. Complex projects may have
1273 multiple branch tags, but there is always a default branch. The
1274 timestamp may be an actual timestamp (such as the -D option to CVS),
1275 or it may be a monotonically-increasing transaction number (such as
1276 the change number used by SVN and P4, or the revision number used by
1277 Arch/Baz/Bazaar, or a labeled tag used in CVS)@footnote{many VC
1278 systems provide more complexity than this: in particular the local
1279 views that P4 and ClearCase can assemble out of various source
1280 directories are more complex than we're prepared to take advantage of
1281 here}. The SHA1 revision ID used by Monotone, Mercurial, and Git is
1282 also a kind of revision stamp, in that it specifies a unique copy of
1283 the source tree, as does a Darcs ``context'' file.
1285 When we aren't intending to make any changes to the sources we check out
1286 (at least not any that need to be committed back upstream), there are two
1287 basic ways to use a VC system:
1289 @itemize @bullet
1290 @item
1291 Retrieve a specific set of source revisions: some tag or key is used
1292 to index this set, which is fixed and cannot be changed by subsequent
1293 developers committing new changes to the tree. Releases are built from
1294 tagged revisions like this, so that they can be rebuilt again later
1295 (probably with controlled modifications).
1296 @item
1297 Retrieve the latest sources along a specific branch: some tag is used
1298 to indicate which branch is to be used, but within that constraint we want
1299 to get the latest revisions.
1300 @end itemize
1302 Build personnel or CM staff typically use the first approach: the
1303 build that results is (ideally) completely specified by the two
1304 parameters given to the VC system: repository and revision tag. This
1305 gives QA and end-users something concrete to point at when reporting
1306 bugs. Release engineers are also reportedly fond of shipping code that
1307 can be traced back to a concise revision tag of some sort.
1309 Developers are more likely to use the second approach: each morning
1310 the developer does an update to pull in the changes committed by the
1311 team over the last day. These builds are not easy to fully specify: it
1312 depends upon exactly when you did a checkout, and upon what local
1313 changes the developer has in their tree. Developers do not normally
1314 tag each build they produce, because there is usually significant
1315 overhead involved in creating these tags. Recreating the trees used by
1316 one of these builds can be a challenge. Some VC systems may provide
1317 implicit tags (like a revision number), while others may allow the use
1318 of timestamps to mean ``the state of the tree at time X'' as opposed
1319 to a tree-state that has been explicitly marked.
1321 The Buildbot is designed to help developers, so it usually works in
1322 terms of @emph{the latest} sources as opposed to specific tagged
1323 revisions. However, it would really prefer to build from reproducible
1324 source trees, so implicit revisions are used whenever possible.
1326 @node Source Tree Specifications, How Different VC Systems Specify Sources, Generalizing VC Systems, Version Control Systems
1327 @subsection Source Tree Specifications
1329 So for the Buildbot's purposes we treat each VC system as a server
1330 which can take a list of specifications as input and produce a source
1331 tree as output. Some of these specifications are static: they are
1332 attributes of the builder and do not change over time. Others are more
1333 variable: each build will have a different value. The repository is
1334 changed over time by a sequence of Changes, each of which represents a
1335 single developer making changes to some set of files. These Changes
1336 are cumulative@footnote{Monotone's @emph{multiple heads} feature
1337 violates this assumption of cumulative Changes, but in most situations
1338 the changes don't occur frequently enough for this to be a significant
1339 problem}.
1341 For normal builds, the Buildbot wants to get well-defined source trees
1342 that contain specific Changes, and exclude other Changes that may have
1343 occurred after the desired ones. We assume that the Changes arrive at
1344 the buildbot (through one of the mechanisms described in @pxref{Change
1345 Sources}) in the same order in which they are committed to the
1346 repository. The Buildbot waits for the tree to become ``stable''
1347 before initiating a build, for two reasons. The first is that
1348 developers frequently make multiple related commits in quick
1349 succession, even when the VC system provides ways to make atomic
1350 transactions involving multiple files at the same time. Running a
1351 build in the middle of these sets of changes would use an inconsistent
1352 set of source files, and is likely to fail (and is certain to be less
1353 useful than a build which uses the full set of changes). The
1354 tree-stable-timer is intended to avoid these useless builds that
1355 include some of the developer's changes but not all. The second reason
1356 is that some VC systems (i.e. CVS) do not provide repository-wide
1357 transaction numbers, so that timestamps are the only way to refer to
1358 a specific repository state. These timestamps may be somewhat
1359 ambiguous, due to processing and notification delays. By waiting until
1360 the tree has been stable for, say, 10 minutes, we can choose a
1361 timestamp from the middle of that period to use for our source
1362 checkout, and then be reasonably sure that any clock-skew errors will
1363 not cause the build to be performed on an inconsistent set of source
1364 files.
1366 The Schedulers always use the tree-stable-timer, with a timeout that
1367 is configured to reflect a reasonable tradeoff between build latency
1368 and change frequency. When the VC system provides coherent
1369 repository-wide revision markers (such as Subversion's revision
1370 numbers, or in fact anything other than CVS's timestamps), the
1371 resulting Build is simply performed against a source tree defined by
1372 that revision marker. When the VC system does not provide this, a
1373 timestamp from the middle of the tree-stable period is used to
1374 generate the source tree@footnote{this @code{checkoutDelay} defaults
1375 to half the tree-stable timer, but it can be overridden with an
1376 argument to the Source Step}.
1378 @node How Different VC Systems Specify Sources, Attributes of Changes, Source Tree Specifications, Version Control Systems
1379 @subsection How Different VC Systems Specify Sources
1381 For CVS, the static specifications are @code{repository} and
1382 @code{module}. In addition to those, each build uses a timestamp (or
1383 omits the timestamp to mean @code{the latest}) and @code{branch tag}
1384 (which defaults to HEAD). These parameters collectively specify a set
1385 of sources from which a build may be performed.
1387 @uref{http://subversion.tigris.org, Subversion} combines the
1388 repository, module, and branch into a single @code{Subversion URL}
1389 parameter. Within that scope, source checkouts can be specified by a
1390 numeric @code{revision number} (a repository-wide
1391 monotonically-increasing marker, such that each transaction that
1392 changes the repository is indexed by a different revision number), or
1393 a revision timestamp. When branches are used, the repository and
1394 module form a static @code{baseURL}, while each build has a
1395 @code{revision number} and a @code{branch} (which defaults to a
1396 statically-specified @code{defaultBranch}). The @code{baseURL} and
1397 @code{branch} are simply concatenated together to derive the
1398 @code{svnurl} to use for the checkout.
1400 @uref{http://www.perforce.com/, Perforce} is similar. The server
1401 is specified through a @code{P4PORT} parameter. Module and branch
1402 are specified in a single depot path, and revisions are
1403 depot-wide. When branches are used, the @code{p4base} and
1404 @code{defaultBranch} are concatenated together to produce the depot
1405 path.
1407 @uref{http://wiki.gnuarch.org/, Arch} and
1408 @uref{http://bazaar.canonical.com/, Bazaar} specify a repository by
1409 URL, as well as a @code{version} which is kind of like a branch name.
1410 Arch uses the word @code{archive} to represent the repository. Arch
1411 lets you push changes from one archive to another, removing the strict
1412 centralization required by CVS and SVN. It retains the distinction
1413 between repository and working directory that most other VC systems
1414 use. For complex multi-module directory structures, Arch has a
1415 built-in @code{build config} layer with which the checkout process has
1416 two steps. First, an initial bootstrap checkout is performed to
1417 retrieve a set of build-config files. Second, one of these files is
1418 used to figure out which archives/modules should be used to populate
1419 subdirectories of the initial checkout.
1421 Builders which use Arch and Bazaar therefore have a static archive
1422 @code{url}, and a default ``branch'' (which is a string that specifies
1423 a complete category--branch--version triple). Each build can have its
1424 own branch (the category--branch--version string) to override the
1425 default, as well as a revision number (which is turned into a
1426 --patch-NN suffix when performing the checkout).
1429 @uref{http://bazaar-vcs.org, Bzr} (which is a descendant of
1430 Arch/Bazaar, and is frequently referred to as ``Bazaar'') has the same
1431 sort of repository-vs-workspace model as Arch, but the repository data
1432 can either be stored inside the working directory or kept elsewhere
1433 (either on the same machine or on an entirely different machine). For
1434 the purposes of Buildbot (which never commits changes), the repository
1435 is specified with a URL and a revision number.
1437 The most common way to obtain read-only access to a bzr tree is via
1438 HTTP, simply by making the repository visible through a web server
1439 like Apache. Bzr can also use FTP and SFTP servers, if the buildslave
1440 process has sufficient privileges to access them. Higher performance
1441 can be obtained by running a special Bazaar-specific server. None of
1442 these matter to the buildbot: the repository URL just has to match the
1443 kind of server being used. The @code{repoURL} argument provides the
1444 location of the repository.
1446 Branches are expressed as subdirectories of the main central
1447 repository, which means that if branches are being used, the BZR step
1448 is given a @code{baseURL} and @code{defaultBranch} instead of getting
1449 the @code{repoURL} argument.
1452 @uref{http://darcs.net/, Darcs} doesn't really have the
1453 notion of a single master repository. Nor does it really have
1454 branches. In Darcs, each working directory is also a repository, and
1455 there are operations to push and pull patches from one of these
1456 @code{repositories} to another. For the Buildbot's purposes, all you
1457 need to do is specify the URL of a repository that you want to build
1458 from. The build slave will then pull the latest patches from that
1459 repository and build them. Multiple branches are implemented by using
1460 multiple repositories (possibly living on the same server).
1462 Builders which use Darcs therefore have a static @code{repourl} which
1463 specifies the location of the repository. If branches are being used,
1464 the source Step is instead configured with a @code{baseURL} and a
1465 @code{defaultBranch}, and the two strings are simply concatenated
1466 together to obtain the repository's URL. Each build then has a
1467 specific branch which replaces @code{defaultBranch}, or just uses the
1468 default one. Instead of a revision number, each build can have a
1469 ``context'', which is a string that records all the patches that are
1470 present in a given tree (this is the output of @command{darcs changes
1471 --context}, and is considerably less concise than, e.g. Subversion's
1472 revision number, but the patch-reordering flexibility of Darcs makes
1473 it impossible to provide a shorter useful specification).
1475 @uref{http://selenic.com/mercurial, Mercurial} is like Darcs, in that
1476 each branch is stored in a separate repository. The @code{repourl},
1477 @code{baseURL}, and @code{defaultBranch} arguments are all handled the
1478 same way as with Darcs. The ``revision'', however, is the hash
1479 identifier returned by @command{hg identify}.
1481 @uref{http://git.or.cz/, Git} also follows a decentralized model, and
1482 each repository can have several branches and tags. The source Step is
1483 configured with a static @code{repourl} which specifies the location
1484 of the repository. In addition, an optional @code{branch} parameter
1485 can be specified to check out code from a specific branch instead of
1486 the default ``master'' branch. The ``revision'' is specified as a SHA1
1487 hash as returned by e.g. @command{git rev-parse}. No attempt is made
1488 to ensure that the specified revision is actually a subset of the
1489 specified branch.
1492 @node Attributes of Changes,  , How Different VC Systems Specify Sources, Version Control Systems
1493 @subsection Attributes of Changes
1495 @heading Who
1497 Each Change has a @code{who} attribute, which specifies which
1498 developer is responsible for the change. This is a string which comes
1499 from a namespace controlled by the VC repository. Frequently this
1500 means it is a username on the host which runs the repository, but not
1501 all VC systems require this (Arch, for example, uses a fully-qualified
1502 @code{Arch ID}, which looks like an email address, as does Darcs).
1503 Each StatusNotifier will map the @code{who} attribute into something
1504 appropriate for their particular means of communication: an email
1505 address, an IRC handle, etc.
1507 @heading Files
1509 It also has a list of @code{files}, which are just the tree-relative
1510 filenames of any files that were added, deleted, or modified for this
1511 Change. These filenames are used by the @code{isFileImportant}
1512 function (in the Scheduler) to decide whether it is worth triggering a
1513 new build or not, e.g. the function could use
1514 @code{filename.endswith(".c")} to only run a build if a C file were
1515 checked in. Certain BuildSteps can also use the list of changed files
1516 to run a more targeted series of tests, e.g. the
1517 @code{python_twisted.Trial} step can run just the unit tests that
1518 provide coverage for the modified .py files instead of running the
1519 full test suite.
1521 @heading Comments
1523 The Change also has a @code{comments} attribute, which is a string
1524 containing any checkin comments.
1526 @heading Revision
1528 Each Change can have a @code{revision} attribute, which describes how
1529 to get a tree with a specific state: a tree which includes this Change
1530 (and all that came before it) but none that come after it. If this
1531 information is unavailable, the @code{.revision} attribute will be
1532 @code{None}. These revisions are provided by the ChangeSource, and
1533 consumed by the @code{computeSourceRevision} method in the appropriate
1534 @code{step.Source} class.
1536 @table @samp
1537 @item CVS
1538 @code{revision} is an int, seconds since the epoch
1539 @item SVN
1540 @code{revision} is an int, a transation number (r%d)
1541 @item Darcs
1542 @code{revision} is a large string, the output of @code{darcs changes --context}
1543 @item Mercurial
1544 @code{revision} is a short string (a hash ID), the output of @code{hg identify}
1545 @item Arch/Bazaar
1546 @code{revision} is the full revision ID (ending in --patch-%d)
1547 @item P4
1548 @code{revision} is an int, the transaction number
1549 @item Git
1550 @code{revision} is a short string (a SHA1 hash), the output of e.g.
1551 @code{git rev-parse}
1552 @end table
1554 @heading Branches
1556 The Change might also have a @code{branch} attribute. This indicates
1557 that all of the Change's files are in the same named branch. The
1558 Schedulers get to decide whether the branch should be built or not.
1560 For VC systems like CVS, Arch, Monotone, and Git, the @code{branch}
1561 name is unrelated to the filename. (that is, the branch name and the
1562 filename inhabit unrelated namespaces). For SVN, branches are
1563 expressed as subdirectories of the repository, so the file's
1564 ``svnurl'' is a combination of some base URL, the branch name, and the
1565 filename within the branch. (In a sense, the branch name and the
1566 filename inhabit the same namespace). Darcs branches are
1567 subdirectories of a base URL just like SVN. Mercurial branches are the
1568 same as Darcs.
1570 @table @samp
1571 @item CVS
1572 branch='warner-newfeature', files=['src/foo.c']
1573 @item SVN
1574 branch='branches/warner-newfeature', files=['src/foo.c']
1575 @item Darcs
1576 branch='warner-newfeature', files=['src/foo.c']
1577 @item Mercurial
1578 branch='warner-newfeature', files=['src/foo.c']
1579 @item Arch/Bazaar
1580 branch='buildbot--usebranches--0', files=['buildbot/master.py']
1581 @item Git
1582 branch='warner-newfeature', files=['src/foo.c']
1583 @end table
1585 @heading Links
1587 @c TODO: who is using 'links'? how is it being used?
1589 Finally, the Change might have a @code{links} list, which is intended
1590 to provide a list of URLs to a @emph{viewcvs}-style web page that
1591 provides more detail for this Change, perhaps including the full file
1592 diffs.
1595 @node Schedulers, BuildSet, Version Control Systems, Concepts
1596 @section Schedulers
1598 @cindex Scheduler
1600 Each Buildmaster has a set of @code{Scheduler} objects, each of which
1601 gets a copy of every incoming Change. The Schedulers are responsible
1602 for deciding when Builds should be run. Some Buildbot installations
1603 might have a single Scheduler, while others may have several, each for
1604 a different purpose.
1606 For example, a ``quick'' scheduler might exist to give immediate
1607 feedback to developers, hoping to catch obvious problems in the code
1608 that can be detected quickly. These typically do not run the full test
1609 suite, nor do they run on a wide variety of platforms. They also
1610 usually do a VC update rather than performing a brand-new checkout
1611 each time. You could have a ``quick'' scheduler which used a 30 second
1612 timeout, and feeds a single ``quick'' Builder that uses a VC
1613 @code{mode='update'} setting.
1615 A separate ``full'' scheduler would run more comprehensive tests a
1616 little while later, to catch more subtle problems. This scheduler
1617 would have a longer tree-stable-timer, maybe 30 minutes, and would
1618 feed multiple Builders (with a @code{mode=} of @code{'copy'},
1619 @code{'clobber'}, or @code{'export'}).
1621 The @code{tree-stable-timer} and @code{isFileImportant} decisions are
1622 made by the Scheduler. Dependencies are also implemented here.
1623 Periodic builds (those which are run every N seconds rather than after
1624 new Changes arrive) are triggered by a special @code{Periodic}
1625 Scheduler subclass. The default Scheduler class can also be told to
1626 watch for specific branches, ignoring Changes on other branches. This
1627 may be useful if you have a trunk and a few release branches which
1628 should be tracked, but when you don't want to have the Buildbot pay
1629 attention to several dozen private user branches.
1631 Some Schedulers may trigger builds for other reasons, other than
1632 recent Changes. For example, a Scheduler subclass could connect to a
1633 remote buildmaster and watch for builds of a library to succeed before
1634 triggering a local build that uses that library.
1636 Each Scheduler creates and submits @code{BuildSet} objects to the
1637 @code{BuildMaster}, which is then responsible for making sure the
1638 individual @code{BuildRequests} are delivered to the target
1639 @code{Builders}.
1641 @code{Scheduler} instances are activated by placing them in the
1642 @code{c['schedulers']} list in the buildmaster config file. Each
1643 Scheduler has a unique name.
1646 @node BuildSet, BuildRequest, Schedulers, Concepts
1647 @section BuildSet
1649 @cindex BuildSet
1651 A @code{BuildSet} is the name given to a set of Builds that all
1652 compile/test the same version of the tree on multiple Builders. In
1653 general, all these component Builds will perform the same sequence of
1654 Steps, using the same source code, but on different platforms or
1655 against a different set of libraries.
1657 The @code{BuildSet} is tracked as a single unit, which fails if any of
1658 the component Builds have failed, and therefore can succeed only if
1659 @emph{all} of the component Builds have succeeded. There are two kinds
1660 of status notification messages that can be emitted for a BuildSet:
1661 the @code{firstFailure} type (which fires as soon as we know the
1662 BuildSet will fail), and the @code{Finished} type (which fires once
1663 the BuildSet has completely finished, regardless of whether the
1664 overall set passed or failed).
1666 A @code{BuildSet} is created with a @emph{source stamp} tuple of
1667 (branch, revision, changes, patch), some of which may be None, and a
1668 list of Builders on which it is to be run. They are then given to the
1669 BuildMaster, which is responsible for creating a separate
1670 @code{BuildRequest} for each Builder.
1672 There are a couple of different likely values for the
1673 @code{SourceStamp}:
1675 @table @code
1676 @item (revision=None, changes=[CHANGES], patch=None)
1677 This is a @code{SourceStamp} used when a series of Changes have
1678 triggered a build. The VC step will attempt to check out a tree that
1679 contains CHANGES (and any changes that occurred before CHANGES, but
1680 not any that occurred after them).
1682 @item (revision=None, changes=None, patch=None)
1683 This builds the most recent code on the default branch. This is the
1684 sort of @code{SourceStamp} that would be used on a Build that was
1685 triggered by a user request, or a Periodic scheduler. It is also
1686 possible to configure the VC Source Step to always check out the
1687 latest sources rather than paying attention to the Changes in the
1688 SourceStamp, which will result in same behavior as this.
1690 @item (branch=BRANCH, revision=None, changes=None, patch=None)
1691 This builds the most recent code on the given BRANCH. Again, this is
1692 generally triggered by a user request or Periodic build.
1694 @item (revision=REV, changes=None, patch=(LEVEL, DIFF))
1695 This checks out the tree at the given revision REV, then applies a
1696 patch (using @code{diff -pLEVEL <DIFF}). The @ref{try} feature uses
1697 this kind of @code{SourceStamp}. If @code{patch} is None, the patching
1698 step is bypassed.
1700 @end table
1702 The buildmaster is responsible for turning the @code{BuildSet} into a
1703 set of @code{BuildRequest} objects and queueing them on the
1704 appropriate Builders.
1707 @node BuildRequest, Builder, BuildSet, Concepts
1708 @section BuildRequest
1710 @cindex BuildRequest
1712 A @code{BuildRequest} is a request to build a specific set of sources
1713 on a single specific Builder. Each Builder runs the
1714 @code{BuildRequest} as soon as it can (i.e. when an associated
1715 buildslave becomes free).
1717 The @code{BuildRequest} contains the @code{SourceStamp} specification.
1718 The actual process of running the build (the series of Steps that will
1719 be executed) is implemented by the @code{Build} object. In this future
1720 this might be changed, to have the @code{Build} define @emph{what}
1721 gets built, and a separate @code{BuildProcess} (provided by the
1722 Builder) to define @emph{how} it gets built.
1724 The @code{BuildRequest} may be mergeable with other compatible
1725 @code{BuildRequest}s. Builds that are triggered by incoming Changes
1726 will generally be mergeable. Builds that are triggered by user
1727 requests are generally not, unless they are multiple requests to build
1728 the @emph{latest sources} of the same branch.
1730 @node Builder, Users, BuildRequest, Concepts
1731 @section Builder
1733 @cindex Builder
1735 The @code{Builder} is a long-lived object which controls all Builds of
1736 a given type. Each one is created when the config file is first
1737 parsed, and lives forever (or rather until it is removed from the
1738 config file). It mediates the connections to the buildslaves that do
1739 all the work, and is responsible for creating the @code{Build} objects
1740 that decide @emph{how} a build is performed (i.e., which steps are
1741 executed in what order).
1743 Each @code{Builder} gets a unique name, and the path name of a
1744 directory where it gets to do all its work (there is a
1745 buildmaster-side directory for keeping status information, as well as
1746 a buildslave-side directory where the actual checkout/compile/test
1747 commands are executed). It also gets a @code{BuildFactory}, which is
1748 responsible for creating new @code{Build} instances: because the
1749 @code{Build} instance is what actually performs each build, choosing
1750 the @code{BuildFactory} is the way to specify what happens each time a
1751 build is done.
1753 Each @code{Builder} is associated with one of more @code{BuildSlaves}.
1754 A @code{Builder} which is used to perform OS-X builds (as opposed to
1755 Linux or Solaris builds) should naturally be associated with an
1756 OS-X-based buildslave.
1759 @node Users,  , Builder, Concepts
1760 @section Users
1762 @cindex Users
1764 Buildbot has a somewhat limited awareness of @emph{users}. It assumes
1765 the world consists of a set of developers, each of whom can be
1766 described by a couple of simple attributes. These developers make
1767 changes to the source code, causing builds which may succeed or fail.
1769 Each developer is primarily known through the source control system. Each
1770 Change object that arrives is tagged with a @code{who} field that
1771 typically gives the account name (on the repository machine) of the user
1772 responsible for that change. This string is the primary key by which the
1773 User is known, and is displayed on the HTML status pages and in each Build's
1774 ``blamelist''.
1776 To do more with the User than just refer to them, this username needs to
1777 be mapped into an address of some sort. The responsibility for this mapping
1778 is left up to the status module which needs the address. The core code knows
1779 nothing about email addresses or IRC nicknames, just user names.
1781 @menu
1782 * Doing Things With Users::     
1783 * Email Addresses::             
1784 * IRC Nicknames::               
1785 * Live Status Clients::         
1786 @end menu
1788 @node Doing Things With Users, Email Addresses, Users, Users
1789 @subsection Doing Things With Users
1791 Each Change has a single User who is responsible for that Change. Most
1792 Builds have a set of Changes: the Build represents the first time these
1793 Changes have been built and tested by the Buildbot. The build has a
1794 ``blamelist'' that consists of a simple union of the Users responsible
1795 for all the Build's Changes.
1797 The Build provides (through the IBuildStatus interface) a list of Users
1798 who are ``involved'' in the build. For now this is equal to the
1799 blamelist, but in the future it will be expanded to include a ``build
1800 sheriff'' (a person who is ``on duty'' at that time and responsible for
1801 watching over all builds that occur during their shift), as well as
1802 per-module owners who simply want to keep watch over their domain (chosen by
1803 subdirectory or a regexp matched against the filenames pulled out of the
1804 Changes). The Involved Users are those who probably have an interest in the
1805 results of any given build.
1807 In the future, Buildbot will acquire the concept of ``Problems'',
1808 which last longer than builds and have beginnings and ends. For example, a
1809 test case which passed in one build and then failed in the next is a
1810 Problem. The Problem lasts until the test case starts passing again, at
1811 which point the Problem is said to be ``resolved''.
1813 If there appears to be a code change that went into the tree at the
1814 same time as the test started failing, that Change is marked as being
1815 resposible for the Problem, and the user who made the change is added
1816 to the Problem's ``Guilty'' list. In addition to this user, there may
1817 be others who share responsibility for the Problem (module owners,
1818 sponsoring developers). In addition to the Responsible Users, there
1819 may be a set of Interested Users, who take an interest in the fate of
1820 the Problem.
1822 Problems therefore have sets of Users who may want to be kept aware of
1823 the condition of the problem as it changes over time. If configured, the
1824 Buildbot can pester everyone on the Responsible list with increasing
1825 harshness until the problem is resolved, with the most harshness reserved
1826 for the Guilty parties themselves. The Interested Users may merely be told
1827 when the problem starts and stops, as they are not actually responsible for
1828 fixing anything.
1830 @node Email Addresses, IRC Nicknames, Doing Things With Users, Users
1831 @subsection Email Addresses
1833 The @code{buildbot.status.mail.MailNotifier} class
1834 (@pxref{MailNotifier}) provides a status target which can send email
1835 about the results of each build. It accepts a static list of email
1836 addresses to which each message should be delivered, but it can also
1837 be configured to send mail to the Build's Interested Users. To do
1838 this, it needs a way to convert User names into email addresses.
1840 For many VC systems, the User Name is actually an account name on the
1841 system which hosts the repository. As such, turning the name into an
1842 email address is a simple matter of appending
1843 ``@@repositoryhost.com''. Some projects use other kinds of mappings
1844 (for example the preferred email address may be at ``project.org''
1845 despite the repository host being named ``cvs.project.org''), and some
1846 VC systems have full separation between the concept of a user and that
1847 of an account on the repository host (like Perforce). Some systems
1848 (like Arch) put a full contact email address in every change.
1850 To convert these names to addresses, the MailNotifier uses an EmailLookup
1851 object. This provides a .getAddress method which accepts a name and
1852 (eventually) returns an address. The default @code{MailNotifier}
1853 module provides an EmailLookup which simply appends a static string,
1854 configurable when the notifier is created. To create more complex behaviors
1855 (perhaps using an LDAP lookup, or using ``finger'' on a central host to
1856 determine a preferred address for the developer), provide a different object
1857 as the @code{lookup} argument.
1859 In the future, when the Problem mechanism has been set up, the Buildbot
1860 will need to send mail to arbitrary Users. It will do this by locating a
1861 MailNotifier-like object among all the buildmaster's status targets, and
1862 asking it to send messages to various Users. This means the User-to-address
1863 mapping only has to be set up once, in your MailNotifier, and every email
1864 message the buildbot emits will take advantage of it.
1866 @node IRC Nicknames, Live Status Clients, Email Addresses, Users
1867 @subsection IRC Nicknames
1869 Like MailNotifier, the @code{buildbot.status.words.IRC} class
1870 provides a status target which can announce the results of each build. It
1871 also provides an interactive interface by responding to online queries
1872 posted in the channel or sent as private messages.
1874 In the future, the buildbot can be configured map User names to IRC
1875 nicknames, to watch for the recent presence of these nicknames, and to
1876 deliver build status messages to the interested parties. Like
1877 @code{MailNotifier} does for email addresses, the @code{IRC} object
1878 will have an @code{IRCLookup} which is responsible for nicknames. The
1879 mapping can be set up statically, or it can be updated by online users
1880 themselves (by claiming a username with some kind of ``buildbot: i am
1881 user warner'' commands).
1883 Once the mapping is established, the rest of the buildbot can ask the
1884 @code{IRC} object to send messages to various users. It can report on
1885 the likelihood that the user saw the given message (based upon how long the
1886 user has been inactive on the channel), which might prompt the Problem
1887 Hassler logic to send them an email message instead.
1889 @node Live Status Clients,  , IRC Nicknames, Users
1890 @subsection Live Status Clients
1892 The Buildbot also offers a PB-based status client interface which can
1893 display real-time build status in a GUI panel on the developer's desktop.
1894 This interface is normally anonymous, but it could be configured to let the
1895 buildmaster know @emph{which} developer is using the status client. The
1896 status client could then be used as a message-delivery service, providing an
1897 alternative way to deliver low-latency high-interruption messages to the
1898 developer (like ``hey, you broke the build'').
1901 @node Configuration, Getting Source Code Changes, Concepts, Top
1902 @chapter Configuration
1904 @cindex Configuration
1906 The buildbot's behavior is defined by the ``config file'', which
1907 normally lives in the @file{master.cfg} file in the buildmaster's base
1908 directory (but this can be changed with an option to the
1909 @code{buildbot create-master} command). This file completely specifies
1910 which Builders are to be run, which slaves they should use, how
1911 Changes should be tracked, and where the status information is to be
1912 sent. The buildmaster's @file{buildbot.tac} file names the base
1913 directory; everything else comes from the config file.
1915 A sample config file was installed for you when you created the
1916 buildmaster, but you will need to edit it before your buildbot will do
1917 anything useful.
1919 This chapter gives an overview of the format of this file and the
1920 various sections in it. You will need to read the later chapters to
1921 understand how to fill in each section properly.
1923 @menu
1924 * Config File Format::          
1925 * Loading the Config File::     
1926 * Testing the Config File::     
1927 * Defining the Project::        
1928 * Listing Change Sources and Schedulers::  
1929 * Setting the slaveport::       
1930 * Buildslave Specifiers::       
1931 * Defining Builders::           
1932 * Defining Status Targets::     
1933 * Debug options::               
1934 @end menu
1936 @node Config File Format, Loading the Config File, Configuration, Configuration
1937 @section Config File Format
1939 The config file is, fundamentally, just a piece of Python code which
1940 defines a dictionary named @code{BuildmasterConfig}, with a number of
1941 keys that are treated specially. You don't need to know Python to do
1942 basic configuration, though, you can just copy the syntax of the
1943 sample file. If you @emph{are} comfortable writing Python code,
1944 however, you can use all the power of a full programming language to
1945 achieve more complicated configurations.
1947 The @code{BuildmasterConfig} name is the only one which matters: all
1948 other names defined during the execution of the file are discarded.
1949 When parsing the config file, the Buildmaster generally compares the
1950 old configuration with the new one and performs the minimum set of
1951 actions necessary to bring the buildbot up to date: Builders which are
1952 not changed are left untouched, and Builders which are modified get to
1953 keep their old event history.
1955 Basic Python syntax: comments start with a hash character (``#''),
1956 tuples are defined with @code{(parenthesis, pairs)}, arrays are
1957 defined with @code{[square, brackets]}, tuples and arrays are mostly
1958 interchangeable. Dictionaries (data structures which map ``keys'' to
1959 ``values'') are defined with curly braces: @code{@{'key1': 'value1',
1960 'key2': 'value2'@} }. Function calls (and object instantiation) can use
1961 named parameters, like @code{w = html.Waterfall(http_port=8010)}.
1963 The config file starts with a series of @code{import} statements,
1964 which make various kinds of Steps and Status targets available for
1965 later use. The main @code{BuildmasterConfig} dictionary is created,
1966 then it is populated with a variety of keys. These keys are broken
1967 roughly into the following sections, each of which is documented in
1968 the rest of this chapter:
1970 @itemize @bullet
1971 @item
1972 Project Definitions
1973 @item
1974 Change Sources / Schedulers
1975 @item
1976 Slaveport
1977 @item
1978 Buildslave Configuration
1979 @item
1980 Builders / Interlocks
1981 @item
1982 Status Targets
1983 @item
1984 Debug options
1985 @end itemize
1987 The config file can use a few names which are placed into its namespace:
1989 @table @code
1990 @item basedir
1991 the base directory for the buildmaster. This string has not been
1992 expanded, so it may start with a tilde. It needs to be expanded before
1993 use. The config file is located in
1994 @code{os.path.expanduser(os.path.join(basedir, 'master.cfg'))}
1996 @end table
1999 @node Loading the Config File, Testing the Config File, Config File Format, Configuration
2000 @section Loading the Config File
2002 The config file is only read at specific points in time. It is first
2003 read when the buildmaster is launched. Once it is running, there are
2004 various ways to ask it to reload the config file. If you are on the
2005 system hosting the buildmaster, you can send a @code{SIGHUP} signal to
2006 it: the @command{buildbot} tool has a shortcut for this:
2008 @example
2009 buildbot reconfig @var{BASEDIR}
2010 @end example
2012 This command will show you all of the lines from @file{twistd.log}
2013 that relate to the reconfiguration. If there are any problems during
2014 the config-file reload, they will be displayed in these lines.
2016 The debug tool (@code{buildbot debugclient --master HOST:PORT}) has a
2017 ``Reload .cfg'' button which will also trigger a reload. In the
2018 future, there will be other ways to accomplish this step (probably a
2019 password-protected button on the web page, as well as a privileged IRC
2020 command).
2022 When reloading the config file, the buildmaster will endeavor to
2023 change as little as possible about the running system. For example,
2024 although old status targets may be shut down and new ones started up,
2025 any status targets that were not changed since the last time the
2026 config file was read will be left running and untouched. Likewise any
2027 Builders which have not been changed will be left running. If a
2028 Builder is modified (say, the build process is changed) while a Build
2029 is currently running, that Build will keep running with the old
2030 process until it completes. Any previously queued Builds (or Builds
2031 which get queued after the reconfig) will use the new process.
2033 @node Testing the Config File, Defining the Project, Loading the Config File, Configuration
2034 @section Testing the Config File
2036 To verify that the config file is well-formed and contains no
2037 deprecated or invalid elements, use the ``checkconfig'' command:
2039 @example
2040 % buildbot checkconfig master.cfg
2041 Config file is good!
2042 @end example
2044 If the config file has deprecated features (perhaps because you've
2045 upgraded the buildmaster and need to update the config file to match),
2046 they will be announced by checkconfig. In this case, the config file
2047 will work, but you should really remove the deprecated items and use
2048 the recommended replacements instead:
2050 @example
2051 % buildbot checkconfig master.cfg
2052 /usr/lib/python2.4/site-packages/buildbot/master.py:559: DeprecationWarning: c['sources'] is deprecated as of 0.7.6 and will be removed by 0.8.0 . Please use c['change_source'] instead.
2053   warnings.warn(m, DeprecationWarning)
2054 Config file is good!
2055 @end example
2057 If the config file is simply broken, that will be caught too:
2059 @example
2060 % buildbot checkconfig master.cfg
2061 Traceback (most recent call last):
2062   File "/usr/lib/python2.4/site-packages/buildbot/scripts/runner.py", line 834, in doCheckConfig
2063     ConfigLoader(configFile)
2064   File "/usr/lib/python2.4/site-packages/buildbot/scripts/checkconfig.py", line 31, in __init__
2065     self.loadConfig(configFile)
2066   File "/usr/lib/python2.4/site-packages/buildbot/master.py", line 480, in loadConfig
2067     exec f in localDict
2068   File "/home/warner/BuildBot/master/foolscap/master.cfg", line 90, in ?
2069     c[bogus] = "stuff"
2070 NameError: name 'bogus' is not defined
2071 @end example
2074 @node Defining the Project, Listing Change Sources and Schedulers, Testing the Config File, Configuration
2075 @section Defining the Project
2077 There are a couple of basic settings that you use to tell the buildbot
2078 what project it is working on. This information is used by status
2079 reporters to let users find out more about the codebase being
2080 exercised by this particular Buildbot installation.
2082 @example
2083 c['projectName'] = "Buildbot"
2084 c['projectURL'] = "http://buildbot.sourceforge.net/"
2085 c['buildbotURL'] = "http://localhost:8010/"
2086 @end example
2088 @bcindex c['projectName']
2089 @code{projectName} is a short string will be used to describe the
2090 project that this buildbot is working on. For example, it is used as
2091 the title of the waterfall HTML page. 
2093 @bcindex c['projectURL']
2094 @code{projectURL} is a string that gives a URL for the project as a
2095 whole. HTML status displays will show @code{projectName} as a link to
2096 @code{projectURL}, to provide a link from buildbot HTML pages to your
2097 project's home page.
2099 @bcindex c['buildbotURL']
2100 The @code{buildbotURL} string should point to the location where the
2101 buildbot's internal web server (usually the @code{html.Waterfall}
2102 page) is visible. This typically uses the port number set when you
2103 create the @code{Waterfall} object: the buildbot needs your help to
2104 figure out a suitable externally-visible host name.
2106 When status notices are sent to users (either by email or over IRC),
2107 @code{buildbotURL} will be used to create a URL to the specific build
2108 or problem that they are being notified about. It will also be made
2109 available to queriers (over IRC) who want to find out where to get
2110 more information about this buildbot.
2113 @node Listing Change Sources and Schedulers, Setting the slaveport, Defining the Project, Configuration
2114 @section Listing Change Sources and Schedulers
2116 @bcindex c['sources']
2117 @bcindex c['change_source']
2119 The @code{c['change_source']} key is the ChangeSource
2120 instance@footnote{To be precise, it is an object or a list of objects
2121 which all implement the @code{buildbot.interfaces.IChangeSource}
2122 Interface. It is unusual to have multiple ChangeSources, so this key
2123 accepts either a single ChangeSource or a sequence of them.} that
2124 defines how the buildmaster learns about source code changes. More
2125 information about what goes here is available in @xref{Getting Source
2126 Code Changes}.
2128 @example
2129 from buildbot.changes.pb import PBChangeSource
2130 c['change_source'] = PBChangeSource()
2131 @end example
2133 (note: in buildbot-0.7.5 and earlier, this key was named
2134 @code{c['sources']}, and required a list. @code{c['sources']} is
2135 deprecated as of buildbot-0.7.6 and is scheduled to be removed in a
2136 future release).
2138 @bcindex c['schedulers']
2139 @code{c['schedulers']} is a list of Scheduler instances, each of which
2140 causes builds to be started on a particular set of Builders. The two
2141 basic Scheduler classes you are likely to start with are
2142 @code{Scheduler} and @code{Periodic}, but you can write a customized
2143 subclass to implement more complicated build scheduling.
2145 The docstring for @code{buildbot.scheduler.Scheduler} is the best
2146 place to see all the options that can be used. Type @code{pydoc
2147 buildbot.scheduler.Scheduler} to see it, or look in
2148 @file{buildbot/scheduler.py} directly.
2150 The basic Scheduler takes four arguments:
2152 @table @code
2153 @item name
2154 Each Scheduler must have a unique name. This is only used in status
2155 displays.
2157 @item branch
2158 This Scheduler will pay attention to a single branch, ignoring Changes
2159 that occur on other branches. Setting @code{branch} equal to the
2160 special value of @code{None} means it should only pay attention to the
2161 default branch. Note that @code{None} is a keyword, not a string, so
2162 you want to use @code{None} and not @code{"None"}.
2164 @item treeStableTimer
2165 The Scheduler will wait for this many seconds before starting the
2166 build. If new changes are made during this interval, the timer will be
2167 restarted, so really the build will be started after a change and then
2168 after this many seconds of inactivity.
2170 @item builderNames
2171 When the tree-stable-timer finally expires, builds will be started on
2172 these Builders. Each Builder gets a unique name: these strings must
2173 match.
2175 @end table
2177 @example
2178 from buildbot import scheduler
2179 quick = scheduler.Scheduler("quick", None, 60,
2180                             ["quick-linux", "quick-netbsd"])
2181 full = scheduler.Scheduler("full", None, 5*60,
2182                            ["full-linux", "full-netbsd", "full-OSX"])
2183 nightly = scheduler.Periodic("nightly", ["full-solaris"], 24*60*60)
2184 c['schedulers'] = [quick, full, nightly]
2185 @end example
2187 In this example, the two ``quick'' builds are triggered 60 seconds
2188 after the tree has been changed. The ``full'' builds do not run quite
2189 so quickly (they wait 5 minutes), so hopefully if the quick builds
2190 fail due to a missing file or really simple typo, the developer can
2191 discover and fix the problem before the full builds are started. Both
2192 Schedulers only pay attention to the default branch: any changes on
2193 other branches are ignored by these Schedulers. Each Scheduler
2194 triggers a different set of Builders, referenced by name.
2196 The third Scheduler in this example just runs the full solaris build
2197 once per day. (note that this Scheduler only lets you control the time
2198 between builds, not the absolute time-of-day of each Build, so this
2199 could easily wind up a ``daily'' or ``every afternoon'' scheduler
2200 depending upon when it was first activated).
2202 @menu
2203 * Scheduler Types::             
2204 * Build Dependencies::          
2205 @end menu
2207 @node Scheduler Types, Build Dependencies, Listing Change Sources and Schedulers, Listing Change Sources and Schedulers
2208 @subsection Scheduler Types
2210 @slindex buildbot.scheduler.Scheduler
2211 @slindex buildbot.scheduler.AnyBranchScheduler
2212 @slindex buildbot.scheduler.Periodic
2213 @slindex buildbot.scheduler.Nightly
2215 Here is a brief catalog of the available Scheduler types. All these
2216 Schedulers are classes in @code{buildbot.scheduler}, and the
2217 docstrings there are the best source of documentation on the arguments
2218 taken by each one.
2220 @table @code
2221 @item Scheduler
2222 This is the default Scheduler class. It follows exactly one branch,
2223 and starts a configurable tree-stable-timer after each change on that
2224 branch. When the timer expires, it starts a build on some set of
2225 Builders. The Scheduler accepts a @code{fileIsImportant} function
2226 which can be used to ignore some Changes if they do not affect any
2227 ``important'' files.
2229 @item AnyBranchScheduler
2230 This scheduler uses a tree-stable-timer like the default one, but
2231 follows multiple branches at once. Each branch gets a separate timer.
2233 @item Dependent
2234 This scheduler watches an ``upstream'' Scheduler. When all the
2235 Builders launched by that Scheduler successfully finish, the Dependent
2236 scheduler is triggered. The next section (@pxref{Build Dependencies})
2237 describes this scheduler in more detail.
2239 @item Triggerable
2240 This scheduler does nothing until it is triggered by a Trigger
2241 step in another build.  This facilitates a more general form of
2242 build dependencies, as described in the next section (@pxref{Build
2243 Dependencies}).
2245 @item Periodic
2246 This simple scheduler just triggers a build every N seconds.
2248 @item Nightly
2249 This is highly configurable periodic build scheduler, which triggers a
2250 build at particular times of day, week, month, or year. The
2251 configuration syntax is very similar to the well-known @code{crontab}
2252 format, in which you provide values for minute, hour, day, and month
2253 (some of which can be wildcards), and a build is triggered whenever
2254 the current time matches the given constraints. This can run a build
2255 every night, every morning, every weekend, alternate Thursdays, on
2256 your boss's birthday, etc.
2258 @item Try_Jobdir / Try_Userpass
2259 This scheduler allows developers to use the @code{buildbot try}
2260 command to trigger builds of code they have not yet committed. See
2261 @ref{try} for complete details.
2263 @end table
2265 @node Build Dependencies,  , Scheduler Types, Listing Change Sources and Schedulers
2266 @subsection Build Dependencies
2268 @cindex Dependent
2269 @cindex Dependencies
2270 @slindex buildbot.scheduler.Dependent
2271 @slindex buildbot.scheduler.Triggerable
2273 It is common to wind up with one kind of build which should only be
2274 performed if the same source code was successfully handled by some
2275 other kind of build first. An example might be a packaging step: you
2276 might only want to produce .deb or RPM packages from a tree that was
2277 known to compile successfully and pass all unit tests. You could put
2278 the packaging step in the same Build as the compile and testing steps,
2279 but there might be other reasons to not do this (in particular you
2280 might have several Builders worth of compiles/tests, but only wish to
2281 do the packaging once). Another example is if you want to skip the
2282 ``full'' builds after a failing ``quick'' build of the same source
2283 code. Or, if one Build creates a product (like a compiled library)
2284 that is used by some other Builder, you'd want to make sure the
2285 consuming Build is run @emph{after} the producing one.
2287 You can use @code{Dependencies} to express this relationship to the
2288 Buildbot. There is a special kind of Scheduler named
2289 @code{scheduler.Dependent} that will watch an ``upstream'' Scheduler
2290 for builds to complete successfully (on all of its Builders). Each
2291 time that happens, the same source code (i.e. the same
2292 @code{SourceStamp}) will be used to start a new set of builds, on a
2293 different set of Builders. This ``downstream'' scheduler doesn't pay
2294 attention to Changes at all, it only pays attention to the upstream
2295 scheduler.
2297 If the SourceStamp fails on any of the Builders in the upstream set,
2298 the downstream builds will not fire.
2300 @example
2301 from buildbot import scheduler
2302 tests = scheduler.Scheduler("tests", None, 5*60,
2303                             ["full-linux", "full-netbsd", "full-OSX"])
2304 package = scheduler.Dependent("package",
2305                               tests, # upstream scheduler
2306                               ["make-tarball", "make-deb", "make-rpm"])
2307 c['schedulers'] = [tests, package]
2308 @end example
2310 Note that @code{Dependent}'s upstream scheduler argument is given as a
2311 @code{Scheduler} @emph{instance}, not a name. This makes it impossible
2312 to create circular dependencies in the config file.
2314 A more general way to coordinate builds is by ``triggering''
2315 schedulers from builds. The Triggerable waits to be triggered by a
2316 Trigger step (@pxref{Triggering Schedulers}) in another build. That
2317 step can optionally wait for the scheduler's builds to complete. This
2318 provides two advantages over Dependent schedulers. First, the same
2319 scheduler can be triggered from multiple builds. Second, the ability
2320 to wait for a Triggerable's builds to complete provides a form of
2321 "subroutine call", where one or more builds can "call" a scheduler to
2322 perform some work for them, perhaps on other buildslaves.
2324 @example
2325 from buildbot import scheduler
2326 from buildbot.steps import trigger
2328 checkin = scheduler.Scheduler("checkin", None, 5*60, ["checkin"])
2329 nightly = scheduler.Scheduler("nightly", ... , ["nightly"])
2331 mktarball = scheduler.Triggerable("mktarball",
2332                                   ["mktarball"])
2333 build = scheduler.Triggerable("build-all-platforms",
2334                               ["build-all-platforms"])
2335 test = scheduler.Triggerable("distributed-test",
2336                              ["distributed-test"])
2337 package = scheduler.Triggerable("package-all-platforms",
2338                                 ["package-all-platforms"])
2340 c['schedulers'] = [checkin, nightly, build, test, package]
2342 checkin_factory = factory.BuildFactory()
2343 f.addStep(trigger.Trigger('mktarball', schedulers=['mktarball'],
2344                                        waitForFinish=True)
2345 f.addStep(trigger.Trigger('build', schedulers=['build-all-platforms'],
2346                                    waitForFinish=True)
2347 f.addStep(trigger.Trigger('test', schedulers=['distributed-test'],
2348                                   waitForFinish=True)
2350 nightly_factory = factory.BuildFactory()
2351 f.addStep(trigger.Trigger('mktarball', schedulers=['mktarball'],
2352                                        waitForFinish=True)
2353 f.addStep(trigger.Trigger('build', schedulers=['build-all-platforms'],
2354                                    waitForFinish=True)
2355 f.addStep(trigger.Trigger('package', schedulers=['package-all-platforms'],
2356                                      waitForFinish=True)
2357 @end example
2359 @node Setting the slaveport, Buildslave Specifiers, Listing Change Sources and Schedulers, Configuration
2360 @section Setting the slaveport
2362 @bcindex c['slavePortnum']
2364 The buildmaster will listen on a TCP port of your choosing for
2365 connections from buildslaves. It can also use this port for
2366 connections from remote Change Sources, status clients, and debug
2367 tools. This port should be visible to the outside world, and you'll
2368 need to tell your buildslave admins about your choice.
2370 It does not matter which port you pick, as long it is externally
2371 visible, however you should probably use something larger than 1024,
2372 since most operating systems don't allow non-root processes to bind to
2373 low-numbered ports. If your buildmaster is behind a firewall or a NAT
2374 box of some sort, you may have to configure your firewall to permit
2375 inbound connections to this port.
2377 @example
2378 c['slavePortnum'] = 10000
2379 @end example
2381 @code{c['slavePortnum']} is a @emph{strports} specification string,
2382 defined in the @code{twisted.application.strports} module (try
2383 @command{pydoc twisted.application.strports} to get documentation on
2384 the format). This means that you can have the buildmaster listen on a
2385 localhost-only port by doing:
2387 @example
2388 c['slavePortnum'] = "tcp:10000:interface=127.0.0.1"
2389 @end example
2391 This might be useful if you only run buildslaves on the same machine,
2392 and they are all configured to contact the buildmaster at
2393 @code{localhost:10000}.
2396 @node Buildslave Specifiers, Defining Builders, Setting the slaveport, Configuration
2397 @section Buildslave Specifiers
2399 @bcindex c['slaves']
2401 The @code{c['slaves']} key is a list of known buildslaves. Each
2402 buildslave is defined by an instance of the BuildSlave class, created
2403 with two values: (slavename, slavepassword). These are the same two
2404 values that need to be provided to the buildslave administrator when
2405 they create the buildslave.
2407 @example
2408 from buildbot.buildslave import BuildSlave
2409 c['slaves'] = [BuildSlave('bot-solaris', 'solarispasswd'),
2410                BuildSlave('bot-bsd', 'bsdpasswd'),
2411               ]
2412 @end example
2414 The slavenames must be unique, of course. The password exists to
2415 prevent evildoers from interfering with the buildbot by inserting
2416 their own (broken) buildslaves into the system and thus displacing the
2417 real ones.
2419 Buildslaves with an unrecognized slavename or a non-matching password
2420 will be rejected when they attempt to connect, and a message
2421 describing the problem will be put in the log file (see @ref{Logfiles}).
2423 The @code{BuildSlave} constructor can take an optional
2424 @code{max_builds} parameter to limit the number of builds that it will
2425 execute simultaneously:
2427 @example
2428 from buildbot.buildslave import BuildSlave
2429 c['slaves'] = [BuildSlave("bot-linux", "linuxpassword", max_builds=2)]
2430 @end example
2432 Historical note: in buildbot-0.7.5 and earlier, the @code{c['bots']}
2433 key was used instead, and it took a list of (name, password) tuples.
2434 This key is accepted for backwards compatibility, but is deprecated as
2435 of 0.7.6 and will go away in some future release.
2437 @menu
2438 * When Buildslaves Go Missing::  
2439 @end menu
2441 @node When Buildslaves Go Missing,  , Buildslave Specifiers, Buildslave Specifiers
2442 @subsection When Buildslaves Go Missing
2444 Sometimes, the buildslaves go away. One very common reason for this is
2445 when the buildslave process is started once (manually) and left
2446 running, but then later the machine reboots and the process is not
2447 automatically restarted.
2449 If you'd like to have the administrator of the buildslave (or other
2450 people) be notified by email when the buildslave has been missing for
2451 too long, just add the @code{notify_on_missing=} argument to the
2452 @code{BuildSlave} definition:
2454 @example
2455 c['slaves'] = [BuildSlave('bot-solaris', 'solarispasswd',
2456                           notify_on_missing="bob@@example.com"),
2457               ]
2458 @end example
2460 By default, this will send email when the buildslave has been
2461 disconnected for more than one hour. Only one email per
2462 connection-loss event will be sent. To change the timeout, use
2463 @code{missing_timeout=} and give it a number of seconds (the default
2464 is 3600).
2466 You can have the buildmaster send email to multiple recipients: just
2467 provide a list of addresses instead of a single one:
2469 @example
2470 c['slaves'] = [BuildSlave('bot-solaris', 'solarispasswd',
2471                           notify_on_missing=["bob@@example.com",
2472                                              "alice@@example.org"],
2473                           missing_timeout=300, # notify after 10 minutes
2474                           ),
2475               ]
2476 @end example
2478 The email sent this way will use a MailNotifier (@pxref{MailNotifier})
2479 status target, if one is configured. This provides a way for you to
2480 control the ``from'' address of the email, as well as the relayhost
2481 (aka ``smarthost'') to use as an SMTP server. If no MailNotifier is
2482 configured on this buildmaster, the buildslave-missing emails will be
2483 sent using a default configuration.
2485 Note that if you want to have a MailNotifier for buildslave-missing
2486 emails but not for regular build emails, just create one with
2487 builders=[], as follows:
2489 @example
2490 from buildbot.status import mail
2491 m = mail.MailNotifier(fromaddr="buildbot@@localhost", builders=[],
2492                       relayhost="smtp.example.org")
2493 c['status'].append(m)
2494 c['slaves'] = [BuildSlave('bot-solaris', 'solarispasswd',
2495                           notify_on_missing="bob@@example.com"),
2496               ]
2497 @end example
2500 @node Defining Builders, Defining Status Targets, Buildslave Specifiers, Configuration
2501 @section Defining Builders
2503 @bcindex c['builders']
2505 The @code{c['builders']} key is a list of dictionaries which specify
2506 the Builders. The Buildmaster runs a collection of Builders, each of
2507 which handles a single type of build (e.g. full versus quick), on a
2508 single build slave. A Buildbot which makes sure that the latest code
2509 (``HEAD'') compiles correctly across four separate architecture will
2510 have four Builders, each performing the same build but on different
2511 slaves (one per platform).
2513 Each Builder gets a separate column in the waterfall display. In
2514 general, each Builder runs independently (although various kinds of
2515 interlocks can cause one Builder to have an effect on another).
2517 Each Builder specification dictionary has several required keys:
2519 @table @code
2520 @item name
2521 This specifies the Builder's name, which is used in status
2522 reports.
2524 @item slavename
2525 This specifies which buildslave will be used by this Builder.
2526 @code{slavename} must appear in the @code{c['slaves']} list. Each
2527 buildslave can accomodate multiple Builders.
2529 @item slavenames
2530 If you provide @code{slavenames} instead of @code{slavename}, you can
2531 give a list of buildslaves which are capable of running this Builder.
2532 If multiple buildslaves are available for any given Builder, you will
2533 have some measure of redundancy: in case one slave goes offline, the
2534 others can still keep the Builder working. In addition, multiple
2535 buildslaves will allow multiple simultaneous builds for the same
2536 Builder, which might be useful if you have a lot of forced or ``try''
2537 builds taking place.
2539 If you use this feature, it is important to make sure that the
2540 buildslaves are all, in fact, capable of running the given build. The
2541 slave hosts should be configured similarly, otherwise you will spend a
2542 lot of time trying (unsuccessfully) to reproduce a failure that only
2543 occurs on some of the buildslaves and not the others. Different
2544 platforms, operating systems, versions of major programs or libraries,
2545 all these things mean you should use separate Builders.
2547 @item builddir
2548 This specifies the name of a subdirectory (under the base directory)
2549 in which everything related to this builder will be placed. On the
2550 buildmaster, this holds build status information. On the buildslave,
2551 this is where checkouts, compiles, and tests are run.
2553 @item factory
2554 This is a @code{buildbot.process.factory.BuildFactory} instance which
2555 controls how the build is performed. Full details appear in their own
2556 chapter, @xref{Build Process}. Parameters like the location of the CVS
2557 repository and the compile-time options used for the build are
2558 generally provided as arguments to the factory's constructor.
2560 @end table
2562 Other optional keys may be set on each Builder:
2564 @table @code
2566 @item category
2567 If provided, this is a string that identifies a category for the
2568 builder to be a part of. Status clients can limit themselves to a
2569 subset of the available categories. A common use for this is to add
2570 new builders to your setup (for a new module, or for a new buildslave)
2571 that do not work correctly yet and allow you to integrate them with
2572 the active builders. You can put these new builders in a test
2573 category, make your main status clients ignore them, and have only
2574 private status clients pick them up. As soon as they work, you can
2575 move them over to the active category.
2577 @end table
2580 @node Defining Status Targets, Debug options, Defining Builders, Configuration
2581 @section Defining Status Targets
2583 The Buildmaster has a variety of ways to present build status to
2584 various users. Each such delivery method is a ``Status Target'' object
2585 in the configuration's @code{status} list. To add status targets, you
2586 just append more objects to this list:
2588 @bcindex c['status']
2590 @example
2591 c['status'] = []
2593 from buildbot.status import html
2594 c['status'].append(html.Waterfall(http_port=8010))
2596 from buildbot.status import mail
2597 m = mail.MailNotifier(fromaddr="buildbot@@localhost",
2598                       extraRecipients=["builds@@lists.example.com"],
2599                       sendToInterestedUsers=False)
2600 c['status'].append(m)
2602 from buildbot.status import words
2603 c['status'].append(words.IRC(host="irc.example.com", nick="bb",
2604                              channels=["#example"]))
2605 @end example
2607 Status delivery has its own chapter, @xref{Status Delivery}, in which
2608 all the built-in status targets are documented.
2611 @node Debug options,  , Defining Status Targets, Configuration
2612 @section Debug options
2615 @bcindex c['debugPassword']
2616 If you set @code{c['debugPassword']}, then you can connect to the
2617 buildmaster with the diagnostic tool launched by @code{buildbot
2618 debugclient MASTER:PORT}. From this tool, you can reload the config
2619 file, manually force builds, and inject changes, which may be useful
2620 for testing your buildmaster without actually commiting changes to
2621 your repository (or before you have the Change Sources set up). The
2622 debug tool uses the same port number as the slaves do:
2623 @code{c['slavePortnum']}, and is authenticated with this password.
2625 @example
2626 c['debugPassword'] = "debugpassword"
2627 @end example
2629 @bcindex c['manhole']
2630 If you set @code{c['manhole']} to an instance of one of the classes in
2631 @code{buildbot.manhole}, you can telnet or ssh into the buildmaster
2632 and get an interactive Python shell, which may be useful for debugging
2633 buildbot internals. It is probably only useful for buildbot
2634 developers. It exposes full access to the buildmaster's account
2635 (including the ability to modify and delete files), so it should not
2636 be enabled with a weak or easily guessable password.
2638 There are three separate @code{Manhole} classes. Two of them use SSH,
2639 one uses unencrypted telnet. Two of them use a username+password
2640 combination to grant access, one of them uses an SSH-style
2641 @file{authorized_keys} file which contains a list of ssh public keys.
2643 @table @code
2644 @item manhole.AuthorizedKeysManhole
2645 You construct this with the name of a file that contains one SSH
2646 public key per line, just like @file{~/.ssh/authorized_keys}. If you
2647 provide a non-absolute filename, it will be interpreted relative to
2648 the buildmaster's base directory.
2650 @item manhole.PasswordManhole
2651 This one accepts SSH connections but asks for a username and password
2652 when authenticating. It accepts only one such pair.
2655 @item manhole.TelnetManhole
2656 This accepts regular unencrypted telnet connections, and asks for a
2657 username/password pair before providing access. Because this
2658 username/password is transmitted in the clear, and because Manhole
2659 access to the buildmaster is equivalent to granting full shell
2660 privileges to both the buildmaster and all the buildslaves (and to all
2661 accounts which then run code produced by the buildslaves), it is
2662 highly recommended that you use one of the SSH manholes instead.
2664 @end table
2666 @example
2667 # some examples:
2668 from buildbot import manhole
2669 c['manhole'] = manhole.AuthorizedKeysManhole(1234, "authorized_keys")
2670 c['manhole'] = manhole.PasswordManhole(1234, "alice", "mysecretpassword")
2671 c['manhole'] = manhole.TelnetManhole(1234, "bob", "snoop_my_password_please")
2672 @end example
2674 The @code{Manhole} instance can be configured to listen on a specific
2675 port. You may wish to have this listening port bind to the loopback
2676 interface (sometimes known as ``lo0'', ``localhost'', or 127.0.0.1) to
2677 restrict access to clients which are running on the same host.
2679 @example
2680 from buildbot.manhole import PasswordManhole
2681 c['manhole'] = PasswordManhole("tcp:9999:interface=127.0.0.1","admin","passwd")
2682 @end example
2684 To have the @code{Manhole} listen on all interfaces, use
2685 @code{"tcp:9999"} or simply 9999. This port specification uses
2686 @code{twisted.application.strports}, so you can make it listen on SSL
2687 or even UNIX-domain sockets if you want.
2689 Note that using any Manhole requires that the TwistedConch package be
2690 installed, and that you be using Twisted version 2.0 or later.
2692 The buildmaster's SSH server will use a different host key than the
2693 normal sshd running on a typical unix host. This will cause the ssh
2694 client to complain about a ``host key mismatch'', because it does not
2695 realize there are two separate servers running on the same host. To
2696 avoid this, use a clause like the following in your @file{.ssh/config}
2697 file:
2699 @example
2700 Host remotehost-buildbot
2701  HostName remotehost
2702  HostKeyAlias remotehost-buildbot
2703  Port 9999
2704  # use 'user' if you use PasswordManhole and your name is not 'admin'.
2705  # if you use AuthorizedKeysManhole, this probably doesn't matter.
2706  User admin
2707 @end example
2710 @node Getting Source Code Changes, Build Process, Configuration, Top
2711 @chapter Getting Source Code Changes
2713 The most common way to use the Buildbot is centered around the idea of
2714 @code{Source Trees}: a directory tree filled with source code of some form
2715 which can be compiled and/or tested. Some projects use languages that don't
2716 involve any compilation step: nevertheless there may be a @code{build} phase
2717 where files are copied or rearranged into a form that is suitable for
2718 installation. Some projects do not have unit tests, and the Buildbot is
2719 merely helping to make sure that the sources can compile correctly. But in
2720 all of these cases, the thing-being-tested is a single source tree.
2722 A Version Control System mantains a source tree, and tells the
2723 buildmaster when it changes. The first step of each Build is typically
2724 to acquire a copy of some version of this tree.
2726 This chapter describes how the Buildbot learns about what Changes have
2727 occurred. For more information on VC systems and Changes, see
2728 @ref{Version Control Systems}.
2731 @menu
2732 * Change Sources::              
2733 * Choosing ChangeSources::      
2734 * CVSToys - PBService::         
2735 * Mail-parsing ChangeSources::  
2736 * PBChangeSource::              
2737 * P4Source::                    
2738 * BonsaiPoller::                
2739 * SVNPoller::                   
2740 * MercurialHook::               
2741 @end menu
2745 @node Change Sources, Choosing ChangeSources, Getting Source Code Changes, Getting Source Code Changes
2746 @section Change Sources
2748 @c TODO: rework this, the one-buildmaster-one-tree thing isn't quite
2749 @c so narrow-minded anymore
2751 Each Buildmaster watches a single source tree. Changes can be provided
2752 by a variety of ChangeSource types, however any given project will
2753 typically have only a single ChangeSource active. This section
2754 provides a description of all available ChangeSource types and
2755 explains how to set up each of them.
2757 There are a variety of ChangeSources available, some of which are
2758 meant to be used in conjunction with other tools to deliver Change
2759 events from the VC repository to the buildmaster.
2761 @itemize @bullet
2763 @item CVSToys
2764 This ChangeSource opens a TCP connection from the buildmaster to a
2765 waiting FreshCVS daemon that lives on the repository machine, and
2766 subscribes to hear about Changes.
2768 @item MaildirSource
2769 This one watches a local maildir-format inbox for email sent out by
2770 the repository when a change is made. When a message arrives, it is
2771 parsed to create the Change object. A variety of parsing functions are
2772 available to accomodate different email-sending tools.
2774 @item PBChangeSource
2775 This ChangeSource listens on a local TCP socket for inbound
2776 connections from a separate tool. Usually, this tool would be run on
2777 the VC repository machine in a commit hook. It is expected to connect
2778 to the TCP socket and send a Change message over the network
2779 connection. The @command{buildbot sendchange} command is one example
2780 of a tool that knows how to send these messages, so you can write a
2781 commit script for your VC system that calls it to deliver the Change.
2782 There are other tools in the contrib/ directory that use the same
2783 protocol.
2785 @end itemize
2787 As a quick guide, here is a list of VC systems and the ChangeSources
2788 that might be useful with them. All of these ChangeSources are in the
2789 @code{buildbot.changes} module.
2791 @table @code
2792 @item CVS
2794 @itemize @bullet
2795 @item freshcvs.FreshCVSSource (connected via TCP to the freshcvs daemon)
2796 @item mail.FCMaildirSource (watching for email sent by a freshcvs daemon)
2797 @item mail.BonsaiMaildirSource (watching for email sent by Bonsai)
2798 @item mail.SyncmailMaildirSource (watching for email sent by syncmail)
2799 @item pb.PBChangeSource (listening for connections from @code{buildbot
2800 sendchange} run in a loginfo script)
2801 @item pb.PBChangeSource (listening for connections from a long-running
2802 @code{contrib/viewcvspoll.py} polling process which examines the ViewCVS
2803 database directly
2804 @end itemize
2806 @item SVN
2807 @itemize @bullet
2808 @item pb.PBChangeSource (listening for connections from
2809 @code{contrib/svn_buildbot.py} run in a postcommit script)
2810 @item pb.PBChangeSource (listening for connections from a long-running
2811 @code{contrib/svn_watcher.py} or @code{contrib/svnpoller.py} polling
2812 process
2813 @item mail.SVNCommitEmailMaildirSource (watching for email sent by commit-email.pl)
2814 @item svnpoller.SVNPoller (polling the SVN repository)
2815 @end itemize
2817 @item Darcs
2818 @itemize @bullet
2819 @item pb.PBChangeSource (listening for connections from
2820 @code{contrib/darcs_buildbot.py} in a commit script
2821 @end itemize
2823 @item Mercurial
2824 @itemize @bullet
2825 @item pb.PBChangeSource (listening for connections from
2826 @code{contrib/hg_buildbot.py} run in an 'incoming' hook)
2827 @item pb.PBChangeSource (listening for connections from
2828 @code{buildbot/changes/hgbuildbot.py} run as an in-process 'changegroup'
2829 hook)
2830 @end itemize
2832 @item Arch/Bazaar
2833 @itemize @bullet
2834 @item pb.PBChangeSource (listening for connections from
2835 @code{contrib/arch_buildbot.py} run in a commit hook)
2836 @end itemize
2838 @item Git
2839 @itemize @bullet
2840 @item pb.PBChangeSource (listening for connections from
2841 @code{contrib/git_buildbot.py} run in the post-receive hook)
2842 @end itemize
2844 @end table
2846 All VC systems can be driven by a PBChangeSource and the
2847 @code{buildbot sendchange} tool run from some form of commit script.
2848 If you write an email parsing function, they can also all be driven by
2849 a suitable @code{MaildirSource}.
2852 @node Choosing ChangeSources, CVSToys - PBService, Change Sources, Getting Source Code Changes
2853 @section Choosing ChangeSources
2855 The @code{master.cfg} configuration file has a dictionary key named
2856 @code{BuildmasterConfig['change_source']}, which holds the active
2857 @code{IChangeSource} object. The config file will typically create an
2858 object from one of the classes described below and stuff it into this
2859 key.
2861 Each buildmaster typically has just a single ChangeSource, since it is
2862 only watching a single source tree. But if, for some reason, you need
2863 multiple sources, just set @code{c['change_source']} to a list of
2864 ChangeSources.. it will accept that too.
2866 @example
2867 s = FreshCVSSourceNewcred(host="host", port=4519,
2868                           user="alice", passwd="secret",
2869                           prefix="Twisted")
2870 BuildmasterConfig['change_source'] = [s]
2871 @end example
2873 Each source tree has a nominal @code{top}. Each Change has a list of
2874 filenames, which are all relative to this top location. The
2875 ChangeSource is responsible for doing whatever is necessary to
2876 accomplish this. Most sources have a @code{prefix} argument: a partial
2877 pathname which is stripped from the front of all filenames provided to
2878 that @code{ChangeSource}. Files which are outside this sub-tree are
2879 ignored by the changesource: it does not generate Changes for those
2880 files.
2883 @node CVSToys - PBService, Mail-parsing ChangeSources, Choosing ChangeSources, Getting Source Code Changes
2884 @section CVSToys - PBService
2886 @csindex buildbot.changes.freshcvs.FreshCVSSource
2888 The @uref{http://purl.net/net/CVSToys, CVSToys} package provides a
2889 server which runs on the machine that hosts the CVS repository it
2890 watches. It has a variety of ways to distribute commit notifications,
2891 and offers a flexible regexp-based way to filter out uninteresting
2892 changes. One of the notification options is named @code{PBService} and
2893 works by listening on a TCP port for clients. These clients subscribe
2894 to hear about commit notifications.
2896 The buildmaster has a CVSToys-compatible @code{PBService} client built
2897 in. There are two versions of it, one for old versions of CVSToys
2898 (1.0.9 and earlier) which used the @code{oldcred} authentication
2899 framework, and one for newer versions (1.0.10 and later) which use
2900 @code{newcred}. Both are classes in the
2901 @code{buildbot.changes.freshcvs} package.
2903 @code{FreshCVSSourceNewcred} objects are created with the following
2904 parameters:
2906 @table @samp
2908 @item @code{host} and @code{port}
2909 these specify where the CVSToys server can be reached
2911 @item @code{user} and @code{passwd}
2912 these specify the login information for the CVSToys server
2913 (@code{freshcvs}). These must match the server's values, which are
2914 defined in the @code{freshCfg} configuration file (which lives in the
2915 CVSROOT directory of the repository).
2917 @item @code{prefix}
2918 this is the prefix to be found and stripped from filenames delivered
2919 by the CVSToys server. Most projects live in sub-directories of the
2920 main repository, as siblings of the CVSROOT sub-directory, so
2921 typically this prefix is set to that top sub-directory name.
2923 @end table
2925 @heading Example
2927 To set up the freshCVS server, add a statement like the following to
2928 your @file{freshCfg} file:
2930 @example
2931 pb = ConfigurationSet([
2932     (None, None, None, PBService(userpass=('foo', 'bar'), port=4519)),
2933     ])
2934 @end example
2936 This will announce all changes to a client which connects to port 4519
2937 using a username of 'foo' and a password of 'bar'.
2939 Then add a clause like this to your buildmaster's @file{master.cfg}:
2941 @example
2942 BuildmasterConfig['change_source'] = FreshCVSSource("cvs.example.com", 4519,
2943                                                     "foo", "bar",
2944                                                     prefix="glib/")
2945 @end example
2947 where "cvs.example.com" is the host that is running the FreshCVS daemon, and
2948 "glib" is the top-level directory (relative to the repository's root) where
2949 all your source code lives. Most projects keep one or more projects in the
2950 same repository (along with CVSROOT/ to hold admin files like loginfo and
2951 freshCfg); the prefix= argument tells the buildmaster to ignore everything
2952 outside that directory, and to strip that common prefix from all pathnames
2953 it handles.
2956 @node Mail-parsing ChangeSources, PBChangeSource, CVSToys - PBService, Getting Source Code Changes
2957 @section Mail-parsing ChangeSources
2959 Many projects publish information about changes to their source tree
2960 by sending an email message out to a mailing list, frequently named
2961 PROJECT-commits or PROJECT-changes. Each message usually contains a
2962 description of the change (who made the change, which files were
2963 affected) and sometimes a copy of the diff. Humans can subscribe to
2964 this list to stay informed about what's happening to the source tree.
2966 The Buildbot can also be subscribed to a -commits mailing list, and
2967 can trigger builds in response to Changes that it hears about. The
2968 buildmaster admin needs to arrange for these email messages to arrive
2969 in a place where the buildmaster can find them, and configure the
2970 buildmaster to parse the messages correctly. Once that is in place,
2971 the email parser will create Change objects and deliver them to the
2972 Schedulers (see @pxref{Scheduler Types}) just like any other
2973 ChangeSource.
2975 There are two components to setting up an email-based ChangeSource.
2976 The first is to route the email messages to the buildmaster, which is
2977 done by dropping them into a ``maildir''. The second is to actually
2978 parse the messages, which is highly dependent upon the tool that was
2979 used to create them. Each VC system has a collection of favorite
2980 change-emailing tools, and each has a slightly different format, so
2981 each has a different parsing function. There is a separate
2982 ChangeSource variant for each parsing function.
2984 Once you've chosen a maildir location and a parsing function, create
2985 the change source and put it in @code{c['change_source']}:
2987 @example
2988 from buildbot.changes.mail import SyncmailMaildirSource
2989 c['change_source'] = SyncmailMaildirSource("~/maildir-buildbot",
2990                                            prefix="/trunk/")
2991 @end example
2993 @menu
2994 * Subscribing the Buildmaster::  
2995 * Using Maildirs::              
2996 * Parsing Email Change Messages::  
2997 @end menu
2999 @node Subscribing the Buildmaster, Using Maildirs, Mail-parsing ChangeSources, Mail-parsing ChangeSources
3000 @subsection Subscribing the Buildmaster
3002 The recommended way to install the buildbot is to create a dedicated
3003 account for the buildmaster. If you do this, the account will probably
3004 have a distinct email address (perhaps
3005 @email{buildmaster@@example.org}). Then just arrange for this
3006 account's email to be delivered to a suitable maildir (described in
3007 the next section).
3009 If the buildbot does not have its own account, ``extension addresses''
3010 can be used to distinguish between email intended for the buildmaster
3011 and email intended for the rest of the account. In most modern MTAs,
3012 the e.g. @code{foo@@example.org} account has control over every email
3013 address at example.org which begins with "foo", such that email
3014 addressed to @email{account-foo@@example.org} can be delivered to a
3015 different destination than @email{account-bar@@example.org}. qmail
3016 does this by using separate .qmail files for the two destinations
3017 (@file{.qmail-foo} and @file{.qmail-bar}, with @file{.qmail}
3018 controlling the base address and @file{.qmail-default} controlling all
3019 other extensions). Other MTAs have similar mechanisms.
3021 Thus you can assign an extension address like
3022 @email{foo-buildmaster@@example.org} to the buildmaster, and retain
3023 @email{foo@@example.org} for your own use.
3026 @node Using Maildirs, Parsing Email Change Messages, Subscribing the Buildmaster, Mail-parsing ChangeSources
3027 @subsection Using Maildirs
3029 A ``maildir'' is a simple directory structure originally developed for
3030 qmail that allows safe atomic update without locking. Create a base
3031 directory with three subdirectories: ``new'', ``tmp'', and ``cur''.
3032 When messages arrive, they are put into a uniquely-named file (using
3033 pids, timestamps, and random numbers) in ``tmp''. When the file is
3034 complete, it is atomically renamed into ``new''. Eventually the
3035 buildmaster notices the file in ``new'', reads and parses the
3036 contents, then moves it into ``cur''. A cronjob can be used to delete
3037 files in ``cur'' at leisure.
3039 Maildirs are frequently created with the @command{maildirmake} tool,
3040 but a simple @command{mkdir -p ~/MAILDIR/@{cur,new,tmp@}} is pretty much
3041 equivalent.
3043 Many modern MTAs can deliver directly to maildirs. The usual .forward
3044 or .procmailrc syntax is to name the base directory with a trailing
3045 slash, so something like @code{~/MAILDIR/} . qmail and postfix are
3046 maildir-capable MTAs, and procmail is a maildir-capable MDA (Mail
3047 Delivery Agent).
3049 For MTAs which cannot put files into maildirs directly, the
3050 ``safecat'' tool can be executed from a .forward file to accomplish
3051 the same thing.
3053 The Buildmaster uses the linux DNotify facility to receive immediate
3054 notification when the maildir's ``new'' directory has changed. When
3055 this facility is not available, it polls the directory for new
3056 messages, every 10 seconds by default.
3058 @node Parsing Email Change Messages,  , Using Maildirs, Mail-parsing ChangeSources
3059 @subsection Parsing Email Change Messages
3061 The second component to setting up an email-based ChangeSource is to
3062 parse the actual notices. This is highly dependent upon the VC system
3063 and commit script in use.
3065 A couple of common tools used to create these change emails are:
3067 @table @samp
3069 @item CVS
3070 @table @samp
3071 @item CVSToys MailNotifier
3072 @ref{FCMaildirSource}
3073 @item Bonsai notification
3074 @ref{BonsaiMaildirSource}
3075 @item syncmail
3076 @ref{SyncmailMaildirSource}
3077 @end table
3079 @item SVN
3080 @table @samp
3081 @item svnmailer
3082 http://opensource.perlig.de/en/svnmailer/
3083 @item commit-email.pl
3084 @ref{SVNCommitEmailMaildirSource}
3085 @end table
3087 @item Mercurial
3088 @table @samp
3089 @item NotifyExtension
3090 http://www.selenic.com/mercurial/wiki/index.cgi/NotifyExtension
3091 @end table
3093 @item Git
3094 @table @samp
3095 @item post-receive-email
3096 http://git.kernel.org/?p=git/git.git;a=blob;f=contrib/hooks/post-receive-email;hb=HEAD
3097 @end table
3099 @end table
3102 The following sections describe the parsers available for each of
3103 these tools.
3105 Most of these parsers accept a @code{prefix=} argument, which is used
3106 to limit the set of files that the buildmaster pays attention to. This
3107 is most useful for systems like CVS and SVN which put multiple
3108 projects in a single repository (or use repository names to indicate
3109 branches). Each filename that appears in the email is tested against
3110 the prefix: if the filename does not start with the prefix, the file
3111 is ignored. If the filename @emph{does} start with the prefix, that
3112 prefix is stripped from the filename before any further processing is
3113 done. Thus the prefix usually ends with a slash.
3115 @menu
3116 * FCMaildirSource::             
3117 * SyncmailMaildirSource::       
3118 * BonsaiMaildirSource::         
3119 * SVNCommitEmailMaildirSource::  
3120 @end menu
3122 @node FCMaildirSource, SyncmailMaildirSource, Parsing Email Change Messages, Parsing Email Change Messages
3123 @subsubsection FCMaildirSource
3126 @csindex buildbot.changes.mail.FCMaildirSource
3128 http://twistedmatrix.com/users/acapnotic/wares/code/CVSToys/
3130 This parser works with the CVSToys @code{MailNotification} action,
3131 which will send email to a list of recipients for each commit. This
3132 tends to work better than using @code{/bin/mail} from within the
3133 CVSROOT/loginfo file directly, as CVSToys will batch together all
3134 files changed during the same CVS invocation, and can provide more
3135 information (like creating a ViewCVS URL for each file changed).
3137 The Buildbot's @code{FCMaildirSource} knows for to parse these CVSToys
3138 messages and turn them into Change objects. It can be given two
3139 parameters: the directory name of the maildir root, and the prefix to
3140 strip.
3142 @example
3143 from buildbot.changes.mail import FCMaildirSource
3144 c['change_source'] = FCMaildirSource("~/maildir-buildbot")
3145 @end example
3147 @node SyncmailMaildirSource, BonsaiMaildirSource, FCMaildirSource, Parsing Email Change Messages
3148 @subsubsection SyncmailMaildirSource
3150 @csindex buildbot.changes.mail.SyncmailMaildirSource
3152 http://sourceforge.net/projects/cvs-syncmail
3154 @code{SyncmailMaildirSource} knows how to parse the message format used by
3155 the CVS ``syncmail'' script.
3157 @example
3158 from buildbot.changes.mail import SyncmailMaildirSource
3159 c['change_source'] = SyncmailMaildirSource("~/maildir-buildbot")
3160 @end example
3162 @node BonsaiMaildirSource, SVNCommitEmailMaildirSource, SyncmailMaildirSource, Parsing Email Change Messages
3163 @subsubsection BonsaiMaildirSource
3165 @csindex buildbot.changes.mail.BonsaiMaildirSource
3167 http://www.mozilla.org/bonsai.html
3169 @code{BonsaiMaildirSource} parses messages sent out by Bonsai, the CVS
3170 tree-management system built by Mozilla.
3172 @example
3173 from buildbot.changes.mail import BonsaiMaildirSource
3174 c['change_source'] = BonsaiMaildirSource("~/maildir-buildbot")
3175 @end example
3177 @node SVNCommitEmailMaildirSource,  , BonsaiMaildirSource, Parsing Email Change Messages
3178 @subsubsection SVNCommitEmailMaildirSource
3180 @csindex buildbot.changes.mail.SVNCommitEmailMaildirSource
3182 @code{SVNCommitEmailMaildirSource} parses message sent out by the
3183 @code{commit-email.pl} script, which is included in the Subversion
3184 distribution.
3186 It does not currently handle branches: all of the Change objects that
3187 it creates will be associated with the default (i.e. trunk) branch.
3189 @example
3190 from buildbot.changes.mail import SVNCommitEmailMaildirSource
3191 c['change_source'] = SVNCommitEmailMaildirSource("~/maildir-buildbot")
3192 @end example
3195 @node PBChangeSource, P4Source, Mail-parsing ChangeSources, Getting Source Code Changes
3196 @section PBChangeSource
3198 @csindex buildbot.changes.pb.PBChangeSource
3200 The last kind of ChangeSource actually listens on a TCP port for
3201 clients to connect and push change notices @emph{into} the
3202 Buildmaster. This is used by the built-in @code{buildbot sendchange}
3203 notification tool, as well as the VC-specific
3204 @file{contrib/svn_buildbot.py}, @file{contrib/arch_buildbot.py},
3205 @file{contrib/hg_buildbot.py} tools, and the
3206 @code{buildbot.changes.hgbuildbot} hook. These tools are run by the
3207 repository (in a commit hook script), and connect to the buildmaster
3208 directly each time a file is comitted. This is also useful for
3209 creating new kinds of change sources that work on a @code{push} model
3210 instead of some kind of subscription scheme, for example a script
3211 which is run out of an email .forward file.
3213 This ChangeSource can be configured to listen on its own TCP port, or
3214 it can share the port that the buildmaster is already using for the
3215 buildslaves to connect. (This is possible because the
3216 @code{PBChangeSource} uses the same protocol as the buildslaves, and
3217 they can be distinguished by the @code{username} attribute used when
3218 the initial connection is established). It might be useful to have it
3219 listen on a different port if, for example, you wanted to establish
3220 different firewall rules for that port. You could allow only the SVN
3221 repository machine access to the @code{PBChangeSource} port, while
3222 allowing only the buildslave machines access to the slave port. Or you
3223 could just expose one port and run everything over it. @emph{Note:
3224 this feature is not yet implemented, the PBChangeSource will always
3225 share the slave port and will always have a @code{user} name of
3226 @code{change}, and a passwd of @code{changepw}. These limitations will
3227 be removed in the future.}.
3230 The @code{PBChangeSource} is created with the following arguments. All
3231 are optional.
3233 @table @samp
3234 @item @code{port}
3235 which port to listen on. If @code{None} (which is the default), it
3236 shares the port used for buildslave connections. @emph{Not
3237 Implemented, always set to @code{None}}.
3239 @item @code{user} and @code{passwd}
3240 The user/passwd account information that the client program must use
3241 to connect. Defaults to @code{change} and @code{changepw}. @emph{Not
3242 Implemented, @code{user} is currently always set to @code{change},
3243 @code{passwd} is always set to @code{changepw}}.
3245 @item @code{prefix}
3246 The prefix to be found and stripped from filenames delivered over the
3247 connection. Any filenames which do not start with this prefix will be
3248 removed. If all the filenames in a given Change are removed, the that
3249 whole Change will be dropped. This string should probably end with a
3250 directory separator.
3252 This is useful for changes coming from version control systems that
3253 represent branches as parent directories within the repository (like
3254 SVN and Perforce). Use a prefix of 'trunk/' or
3255 'project/branches/foobranch/' to only follow one branch and to get
3256 correct tree-relative filenames. Without a prefix, the PBChangeSource
3257 will probably deliver Changes with filenames like @file{trunk/foo.c}
3258 instead of just @file{foo.c}. Of course this also depends upon the
3259 tool sending the Changes in (like @command{buildbot sendchange}) and
3260 what filenames it is delivering: that tool may be filtering and
3261 stripping prefixes at the sending end.
3263 @end table
3265 @node P4Source, BonsaiPoller, PBChangeSource, Getting Source Code Changes
3266 @section P4Source
3268 @csindex buildbot.changes.p4poller.P4Source
3270 The @code{P4Source} periodically polls a @uref{http://www.perforce.com/,
3271 Perforce} depot for changes. It accepts the following arguments:
3273 @table @samp
3274 @item @code{p4base}
3275 The base depot path to watch, without the trailing '/...'.
3277 @item @code{p4port}
3278 The Perforce server to connect to (as host:port).
3280 @item @code{p4user}
3281 The Perforce user.
3283 @item @code{p4passwd}
3284 The Perforce password.
3286 @item @code{split_file}
3287 A function that maps a pathname, without the leading @code{p4base}, to a
3288 (branch, filename) tuple. The default just returns (None, branchfile),
3289 which effectively disables branch support. You should supply a function
3290 which understands your repository structure.
3292 @item @code{pollinterval}
3293 How often to poll, in seconds. Defaults to 600 (10 minutes).
3295 @item @code{histmax}
3296 The maximum number of changes to inspect at a time. If more than this
3297 number occur since the last poll, older changes will be silently
3298 ignored.
3299 @end table
3301 @heading Example
3303 This configuration uses the @code{P4PORT}, @code{P4USER}, and @code{P4PASSWD}
3304 specified in the buildmaster's environment. It watches a project in which the
3305 branch name is simply the next path component, and the file is all path
3306 components after.
3308 @example
3309 import buildbot.changes.p4poller
3310 s = p4poller.P4Source(p4base='//depot/project/',
3311                       split_file=lambda branchfile: branchfile.split('/',1),
3312                      )
3313 c['change_source'] = s
3314 @end example
3316 @node BonsaiPoller, SVNPoller, P4Source, Getting Source Code Changes
3317 @section BonsaiPoller
3319 @csindex buildbot.changes.bonsaipoller.BonsaiPoller
3321 The @code{BonsaiPoller} periodically polls a Bonsai server. This is a
3322 CGI script accessed through a web server that provides information
3323 about a CVS tree, for example the Mozilla bonsai server at
3324 @uref{http://bonsai.mozilla.org}. Bonsai servers are usable by both
3325 humans and machines. In this case, the buildbot's change source forms
3326 a query which asks about any files in the specified branch which have
3327 changed since the last query.
3329 Please take a look at the BonsaiPoller docstring for details about the
3330 arguments it accepts.
3333 @node SVNPoller, MercurialHook, BonsaiPoller, Getting Source Code Changes
3334 @section SVNPoller
3336 @csindex buildbot.changes.svnpoller.SVNPoller
3338 The @code{buildbot.changes.svnpoller.SVNPoller} is a ChangeSource
3339 which periodically polls a @uref{http://subversion.tigris.org/,
3340 Subversion} repository for new revisions, by running the @code{svn
3341 log} command in a subshell. It can watch a single branch or multiple
3342 branches.
3344 @code{SVNPoller} accepts the following arguments:
3346 @table @code
3347 @item svnurl
3348 The base URL path to watch, like
3349 @code{svn://svn.twistedmatrix.com/svn/Twisted/trunk}, or
3350 @code{http://divmod.org/svn/Divmod/}, or even
3351 @code{file:///home/svn/Repository/ProjectA/branches/1.5/}. This must
3352 include the access scheme, the location of the repository (both the
3353 hostname for remote ones, and any additional directory names necessary
3354 to get to the repository), and the sub-path within the repository's
3355 virtual filesystem for the project and branch of interest.
3357 The @code{SVNPoller} will only pay attention to files inside the
3358 subdirectory specified by the complete svnurl.
3360 @item split_file
3361 A function to convert pathnames into (branch, relative_pathname)
3362 tuples. Use this to explain your repository's branch-naming policy to
3363 @code{SVNPoller}. This function must accept a single string and return
3364 a two-entry tuple. There are a few utility functions in
3365 @code{buildbot.changes.svnpoller} that can be used as a
3366 @code{split_file} function, see below for details.
3368 The default value always returns (None, path), which indicates that
3369 all files are on the trunk.
3371 Subclasses of @code{SVNPoller} can override the @code{split_file}
3372 method instead of using the @code{split_file=} argument.
3374 @item svnuser
3375 An optional string parameter. If set, the @code{--user} argument will
3376 be added to all @code{svn} commands. Use this if you have to
3377 authenticate to the svn server before you can do @code{svn info} or
3378 @code{svn log} commands.
3380 @item svnpasswd
3381 Like @code{svnuser}, this will cause a @code{--password} argument to
3382 be passed to all svn commands.
3384 @item pollinterval
3385 How often to poll, in seconds. Defaults to 600 (checking once every 10
3386 minutes). Lower this if you want the buildbot to notice changes
3387 faster, raise it if you want to reduce the network and CPU load on
3388 your svn server. Please be considerate of public SVN repositories by
3389 using a large interval when polling them.
3391 @item histmax
3392 The maximum number of changes to inspect at a time. Every POLLINTERVAL
3393 seconds, the @code{SVNPoller} asks for the last HISTMAX changes and
3394 looks through them for any ones it does not already know about. If
3395 more than HISTMAX revisions have been committed since the last poll,
3396 older changes will be silently ignored. Larger values of histmax will
3397 cause more time and memory to be consumed on each poll attempt.
3398 @code{histmax} defaults to 100.
3400 @item svnbin
3401 This controls the @code{svn} executable to use. If subversion is
3402 installed in a weird place on your system (outside of the
3403 buildmaster's @code{$PATH}), use this to tell @code{SVNPoller} where
3404 to find it. The default value of ``svn'' will almost always be
3405 sufficient.
3407 @end table
3409 @heading Branches
3411 Each source file that is tracked by a Subversion repository has a
3412 fully-qualified SVN URL in the following form:
3413 (REPOURL)(PROJECT-plus-BRANCH)(FILEPATH). When you create the
3414 @code{SVNPoller}, you give it a @code{svnurl} value that includes all
3415 of the REPOURL and possibly some portion of the PROJECT-plus-BRANCH
3416 string. The @code{SVNPoller} is responsible for producing Changes that
3417 contain a branch name and a FILEPATH (which is relative to the top of
3418 a checked-out tree). The details of how these strings are split up
3419 depend upon how your repository names its branches.
3421 @subheading PROJECT/BRANCHNAME/FILEPATH repositories
3423 One common layout is to have all the various projects that share a
3424 repository get a single top-level directory each. Then under a given
3425 project's directory, you get two subdirectories, one named ``trunk''
3426 and another named ``branches''. Under ``branches'' you have a bunch of
3427 other directories, one per branch, with names like ``1.5.x'' and
3428 ``testing''. It is also common to see directories like ``tags'' and
3429 ``releases'' next to ``branches'' and ``trunk''.
3431 For example, the Twisted project has a subversion server on
3432 ``svn.twistedmatrix.com'' that hosts several sub-projects. The
3433 repository is available through a SCHEME of ``svn:''. The primary
3434 sub-project is Twisted, of course, with a repository root of
3435 ``svn://svn.twistedmatrix.com/svn/Twisted''. Another sub-project is
3436 Informant, with a root of
3437 ``svn://svn.twistedmatrix.com/svn/Informant'', etc. Inside any
3438 checked-out Twisted tree, there is a file named bin/trial (which is
3439 used to run unit test suites).
3441 The trunk for Twisted is in
3442 ``svn://svn.twistedmatrix.com/svn/Twisted/trunk'', and the
3443 fully-qualified SVN URL for the trunk version of @code{trial} would be
3444 ``svn://svn.twistedmatrix.com/svn/Twisted/trunk/bin/trial''. The same
3445 SVNURL for that file on a branch named ``1.5.x'' would be
3446 ``svn://svn.twistedmatrix.com/svn/Twisted/branches/1.5.x/bin/trial''.
3448 To set up a @code{SVNPoller} that watches the Twisted trunk (and
3449 nothing else), we would use the following:
3451 @example
3452 from buildbot.changes.svnpoller import SVNPoller
3453 c['change_source'] = SVNPoller("svn://svn.twistedmatrix.com/svn/Twisted/trunk")
3454 @end example
3456 In this case, every Change that our @code{SVNPoller} produces will
3457 have @code{.branch=None}, to indicate that the Change is on the trunk.
3458 No other sub-projects or branches will be tracked.
3460 If we want our ChangeSource to follow multiple branches, we have to do
3461 two things. First we have to change our @code{svnurl=} argument to
3462 watch more than just ``.../Twisted/trunk''. We will set it to
3463 ``.../Twisted'' so that we'll see both the trunk and all the branches.
3464 Second, we have to tell @code{SVNPoller} how to split the
3465 (PROJECT-plus-BRANCH)(FILEPATH) strings it gets from the repository
3466 out into (BRANCH) and (FILEPATH) pairs.
3468 We do the latter by providing a ``split_file'' function. This function
3469 is responsible for splitting something like
3470 ``branches/1.5.x/bin/trial'' into @code{branch}=''branches/1.5.x'' and
3471 @code{filepath}=''bin/trial''. This function is always given a string
3472 that names a file relative to the subdirectory pointed to by the
3473 @code{SVNPoller}'s @code{svnurl=} argument. It is expected to return a
3474 (BRANCHNAME, FILEPATH) tuple (in which FILEPATH is relative to the
3475 branch indicated), or None to indicate that the file is outside any
3476 project of interest.
3478 (note that we want to see ``branches/1.5.x'' rather than just
3479 ``1.5.x'' because when we perform the SVN checkout, we will probably
3480 append the branch name to the baseURL, which requires that we keep the
3481 ``branches'' component in there. Other VC schemes use a different
3482 approach towards branches and may not require this artifact.)
3484 If your repository uses this same PROJECT/BRANCH/FILEPATH naming
3485 scheme, the following function will work:
3487 @example
3488 def split_file_branches(path):
3489     pieces = path.split('/')
3490     if pieces[0] == 'trunk':
3491         return (None, '/'.join(pieces[1:]))
3492     elif pieces[0] == 'branches':
3493         return ('/'.join(pieces[0:2]),
3494                 '/'.join(pieces[2:]))
3495     else:
3496         return None
3497 @end example
3499 This function is provided as
3500 @code{buildbot.changes.svnpoller.split_file_branches} for your
3501 convenience. So to have our Twisted-watching @code{SVNPoller} follow
3502 multiple branches, we would use this:
3504 @example
3505 from buildbot.changes.svnpoller import SVNPoller, split_file_branches
3506 c['change_source'] = SVNPoller("svn://svn.twistedmatrix.com/svn/Twisted",
3507                                split_file=split_file_branches)
3508 @end example
3510 Changes for all sorts of branches (with names like ``branches/1.5.x'',
3511 and None to indicate the trunk) will be delivered to the Schedulers.
3512 Each Scheduler is then free to use or ignore each branch as it sees
3513 fit.
3515 @subheading BRANCHNAME/PROJECT/FILEPATH repositories
3517 Another common way to organize a Subversion repository is to put the
3518 branch name at the top, and the projects underneath. This is
3519 especially frequent when there are a number of related sub-projects
3520 that all get released in a group.
3522 For example, Divmod.org hosts a project named ``Nevow'' as well as one
3523 named ``Quotient''. In a checked-out Nevow tree there is a directory
3524 named ``formless'' that contains a python source file named
3525 ``webform.py''. This repository is accessible via webdav (and thus
3526 uses an ``http:'' scheme) through the divmod.org hostname. There are
3527 many branches in this repository, and they use a
3528 (BRANCHNAME)/(PROJECT) naming policy.
3530 The fully-qualified SVN URL for the trunk version of webform.py is
3531 @code{http://divmod.org/svn/Divmod/trunk/Nevow/formless/webform.py}.
3532 You can do an @code{svn co} with that URL and get a copy of the latest
3533 version. The 1.5.x branch version of this file would have a URL of
3534 @code{http://divmod.org/svn/Divmod/branches/1.5.x/Nevow/formless/webform.py}.
3535 The whole Nevow trunk would be checked out with
3536 @code{http://divmod.org/svn/Divmod/trunk/Nevow}, while the Quotient
3537 trunk would be checked out using
3538 @code{http://divmod.org/svn/Divmod/trunk/Quotient}.
3540 Now suppose we want to have an @code{SVNPoller} that only cares about
3541 the Nevow trunk. This case looks just like the PROJECT/BRANCH layout
3542 described earlier:
3544 @example
3545 from buildbot.changes.svnpoller import SVNPoller
3546 c['change_source'] = SVNPoller("http://divmod.org/svn/Divmod/trunk/Nevow")
3547 @end example
3549 But what happens when we want to track multiple Nevow branches? We
3550 have to point our @code{svnurl=} high enough to see all those
3551 branches, but we also don't want to include Quotient changes (since
3552 we're only building Nevow). To accomplish this, we must rely upon the
3553 @code{split_file} function to help us tell the difference between
3554 files that belong to Nevow and those that belong to Quotient, as well
3555 as figuring out which branch each one is on.
3557 @example
3558 from buildbot.changes.svnpoller import SVNPoller
3559 c['change_source'] = SVNPoller("http://divmod.org/svn/Divmod",
3560                                split_file=my_file_splitter)
3561 @end example
3563 The @code{my_file_splitter} function will be called with
3564 repository-relative pathnames like:
3566 @table @code
3567 @item trunk/Nevow/formless/webform.py
3568 This is a Nevow file, on the trunk. We want the Change that includes this
3569 to see a filename of @code{formless/webform.py"}, and a branch of None
3571 @item branches/1.5.x/Nevow/formless/webform.py
3572 This is a Nevow file, on a branch. We want to get
3573 branch=''branches/1.5.x'' and filename=''formless/webform.py''.
3575 @item trunk/Quotient/setup.py
3576 This is a Quotient file, so we want to ignore it by having
3577 @code{my_file_splitter} return None.
3579 @item branches/1.5.x/Quotient/setup.py
3580 This is also a Quotient file, which should be ignored.
3581 @end table
3583 The following definition for @code{my_file_splitter} will do the job:
3585 @example
3586 def my_file_splitter(path):
3587     pieces = path.split('/')
3588     if pieces[0] == 'trunk':
3589         branch = None
3590         pieces.pop(0) # remove 'trunk'
3591     elif pieces[0] == 'branches':
3592         pieces.pop(0) # remove 'branches'
3593         # grab branch name
3594         branch = 'branches/' + pieces.pop(0)
3595     else:
3596         return None # something weird
3597     projectname = pieces.pop(0)
3598     if projectname != 'Nevow':
3599         return None # wrong project
3600     return (branch, '/'.join(pieces))
3601 @end example
3603 @node MercurialHook,  , SVNPoller, Getting Source Code Changes
3604 @section MercurialHook
3606 Since Mercurial is written in python, the hook script can invoke
3607 Buildbot's @code{sendchange} function directly, rather than having to
3608 spawn an external process. This function delivers the same sort of
3609 changes as @code{buildbot sendchange} and the various hook scripts in
3610 contrib/, so you'll need to add a @code{pb.PBChangeSource} to your
3611 buildmaster to receive these changes.
3613 To set this up, first choose a Mercurial repository that represents
3614 your central ``official'' source tree. This will be the same
3615 repository that your buildslaves will eventually pull from. Install
3616 Buildbot on the machine that hosts this repository, using the same
3617 version of python as Mercurial is using (so that the Mercurial hook
3618 can import code from buildbot). Then add the following to the
3619 @code{.hg/hgrc} file in that repository, replacing the buildmaster
3620 hostname/portnumber as appropriate for your buildbot:
3622 @example
3623 [hooks]
3624 changegroup.buildbot = python:buildbot.changes.hgbuildbot.hook
3626 [hgbuildbot]
3627 master = buildmaster.example.org:9987
3628 @end example
3630 (Note that Mercurial lets you define multiple @code{changegroup} hooks
3631 by giving them distinct names, like @code{changegroup.foo} and
3632 @code{changegroup.bar}, which is why we use
3633 @code{changegroup.buildbot} in this example. There is nothing magical
3634 about the ``buildbot'' suffix in the hook name. The
3635 @code{[hgbuildbot]} section @emph{is} special, however, as it is the
3636 only section that the buildbot hook pays attention to.)
3638 Also note that this runs as a @code{changegroup} hook, rather than as
3639 an @code{incoming} hook. The @code{changegroup} hook is run with
3640 multiple revisions at a time (say, if multiple revisions are being
3641 pushed to this repository in a single @command{hg push} command),
3642 whereas the @code{incoming} hook is run with just one revision at a
3643 time. The @code{hgbuildbot.hook} function will only work with the
3644 @code{changegroup} hook.
3646 The @code{[hgbuildbot]} section has two other parameters that you
3647 might specify, both of which control the name of the branch that is
3648 attached to the changes coming from this hook.
3650 One common branch naming policy for Mercurial repositories is to use
3651 it just like Darcs: each branch goes into a separate repository, and
3652 all the branches for a single project share a common parent directory.
3653 For example, you might have @file{/var/repos/PROJECT/trunk/} and
3654 @file{/var/repos/PROJECT/release}. To use this style, use the
3655 @code{branchtype = dirname} setting, which simply uses the last
3656 component of the repository's enclosing directory as the branch name:
3658 @example
3659 [hgbuildbot]
3660 master = buildmaster.example.org:9987
3661 branchtype = dirname
3662 @end example
3664 Another approach is to use Mercurial's built-in branches (the kind
3665 created with @command{hg branch} and listed with @command{hg
3666 branches}). This feature associates persistent names with particular
3667 lines of descent within a single repository. (note that the buildbot
3668 @code{source.Mercurial} checkout step does not yet support this kind
3669 of branch). To have the commit hook deliver this sort of branch name
3670 with the Change object, use @code{branchtype = inrepo}:
3672 @example
3673 [hgbuildbot]
3674 master = buildmaster.example.org:9987
3675 branchtype = inrepo
3676 @end example
3678 Finally, if you want to simply specify the branchname directly, for
3679 all changes, use @code{branch = BRANCHNAME}. This overrides
3680 @code{branchtype}:
3682 @example
3683 [hgbuildbot]
3684 master = buildmaster.example.org:9987
3685 branch = trunk
3686 @end example
3688 If you use @code{branch=} like this, you'll need to put a separate
3689 .hgrc in each repository. If you use @code{branchtype=}, you may be
3690 able to use the same .hgrc for all your repositories, stored in
3691 @file{~/.hgrc} or @file{/etc/mercurial/hgrc}.
3694 @node Build Process, Status Delivery, Getting Source Code Changes, Top
3695 @chapter Build Process
3697 A @code{Build} object is responsible for actually performing a build.
3698 It gets access to a remote @code{SlaveBuilder} where it may run
3699 commands, and a @code{BuildStatus} object where it must emit status
3700 events. The @code{Build} is created by the Builder's
3701 @code{BuildFactory}.
3703 The default @code{Build} class is made up of a fixed sequence of
3704 @code{BuildSteps}, executed one after another until all are complete
3705 (or one of them indicates that the build should be halted early). The
3706 default @code{BuildFactory} creates instances of this @code{Build}
3707 class with a list of @code{BuildSteps}, so the basic way to configure
3708 the build is to provide a list of @code{BuildSteps} to your
3709 @code{BuildFactory}.
3711 More complicated @code{Build} subclasses can make other decisions:
3712 execute some steps only if certain files were changed, or if certain
3713 previous steps passed or failed. The base class has been written to
3714 allow users to express basic control flow without writing code, but
3715 you can always subclass and customize to achieve more specialized
3716 behavior.
3718 @menu
3719 * Build Steps::                 
3720 * Interlocks::                  
3721 * Build Factories::             
3722 @end menu
3724 @node Build Steps, Interlocks, Build Process, Build Process
3725 @section Build Steps
3727 @code{BuildStep}s are usually specified in the buildmaster's
3728 configuration file, in a list that goes into the @code{BuildFactory}.
3729 The @code{BuildStep} instances in this list are used as templates to
3730 construct new independent copies for each build (so that state can be
3731 kept on the @code{BuildStep} in one build without affecting a later
3732 build). Each @code{BuildFactory} can be created with a list of steps,
3733 or the factory can be created empty and then steps added to it using
3734 the @code{addStep} method:
3736 @example
3737 from buildbot.steps import source, shell
3738 from buildbot.process import factory
3740 f = factory.BuildFactory()
3741 f.addStep(source.SVN(svnurl="http://svn.example.org/Trunk/"))
3742 f.addStep(shell.ShellCommand(command=["make", "all"]))
3743 f.addStep(shell.ShellCommand(command=["make", "test"]))
3744 @end example
3746 In earlier versions (0.7.5 and older), these steps were specified with
3747 a tuple of (step_class, keyword_arguments). Steps can still be
3748 specified this way, but the preferred form is to pass actual
3749 @code{BuildStep} instances to @code{addStep}, because that gives the
3750 @code{BuildStep} class a chance to do some validation on the
3751 arguments.
3753 The rest of this section lists all the standard BuildStep objects
3754 available for use in a Build, and the parameters which can be used to
3755 control each.
3757 @menu
3758 * Common Parameters::           
3759 * Source Checkout::             
3760 * ShellCommand::                
3761 * Simple ShellCommand Subclasses::  
3762 * Python BuildSteps::           
3763 * Transferring Files::          
3764 * Triggering Schedulers::       
3765 * Writing New BuildSteps::      
3766 @end menu
3768 @node Common Parameters, Source Checkout, Build Steps, Build Steps
3769 @subsection Common Parameters
3771 The standard @code{Build} runs a series of @code{BuildStep}s in order,
3772 only stopping when it runs out of steps or if one of them requests
3773 that the build be halted. It collects status information from each one
3774 to create an overall build status (of SUCCESS, WARNINGS, or FAILURE).
3776 All BuildSteps accept some common parameters. Some of these control
3777 how their individual status affects the overall build. Others are used
3778 to specify which @code{Locks} (see @pxref{Interlocks}) should be
3779 acquired before allowing the step to run.
3781 Arguments common to all @code{BuildStep} subclasses:
3784 @table @code
3785 @item name
3786 the name used to describe the step on the status display. It is also
3787 used to give a name to any LogFiles created by this step.
3789 @item haltOnFailure
3790 if True, a FAILURE of this build step will cause the build to halt
3791 immediately with an overall result of FAILURE.
3793 @item flunkOnWarnings
3794 when True, a WARNINGS or FAILURE of this build step will mark the
3795 overall build as FAILURE. The remaining steps will still be executed.
3797 @item flunkOnFailure
3798 when True, a FAILURE of this build step will mark the overall build as
3799 a FAILURE. The remaining steps will still be executed.
3801 @item warnOnWarnings
3802 when True, a WARNINGS or FAILURE of this build step will mark the
3803 overall build as having WARNINGS. The remaining steps will still be
3804 executed.
3806 @item warnOnFailure
3807 when True, a FAILURE of this build step will mark the overall build as
3808 having WARNINGS. The remaining steps will still be executed.
3810 @item locks
3811 a list of Locks (instances of @code{buildbot.locks.SlaveLock} or
3812 @code{buildbot.locks.MasterLock}) that should be acquired before
3813 starting this Step. The Locks will be released when the step is
3814 complete. Note that this is a list of actual Lock instances, not
3815 names. Also note that all Locks must have unique names.
3817 @end table
3820 @node Source Checkout, ShellCommand, Common Parameters, Build Steps
3821 @subsection Source Checkout
3823 The first step of any build is typically to acquire the source code
3824 from which the build will be performed. There are several classes to
3825 handle this, one for each of the different source control system that
3826 Buildbot knows about. For a description of how Buildbot treats source
3827 control in general, see @ref{Version Control Systems}.
3829 All source checkout steps accept some common parameters to control how
3830 they get the sources and where they should be placed. The remaining
3831 per-VC-system parameters are mostly to specify where exactly the
3832 sources are coming from.
3834 @table @code
3835 @item mode
3837 a string describing the kind of VC operation that is desired. Defaults
3838 to @code{update}.
3840 @table @code
3841 @item update
3842 specifies that the CVS checkout/update should be performed directly
3843 into the workdir. Each build is performed in the same directory,
3844 allowing for incremental builds. This minimizes disk space, bandwidth,
3845 and CPU time. However, it may encounter problems if the build process
3846 does not handle dependencies properly (sometimes you must do a ``clean
3847 build'' to make sure everything gets compiled), or if source files are
3848 deleted but generated files can influence test behavior (e.g. python's
3849 .pyc files), or when source directories are deleted but generated
3850 files prevent CVS from removing them. Builds ought to be correct
3851 regardless of whether they are done ``from scratch'' or incrementally,
3852 but it is useful to test both kinds: this mode exercises the
3853 incremental-build style.
3855 @item copy
3856 specifies that the CVS workspace should be maintained in a separate
3857 directory (called the 'copydir'), using checkout or update as
3858 necessary. For each build, a new workdir is created with a copy of the
3859 source tree (rm -rf workdir; cp -r copydir workdir). This doubles the
3860 disk space required, but keeps the bandwidth low (update instead of a
3861 full checkout). A full 'clean' build is performed each time. This
3862 avoids any generated-file build problems, but is still occasionally
3863 vulnerable to CVS problems such as a repository being manually
3864 rearranged, causing CVS errors on update which are not an issue with a
3865 full checkout.
3867 @c TODO: something is screwy about this, revisit. Is it the source
3868 @c directory or the working directory that is deleted each time?
3870 @item clobber
3871 specifes that the working directory should be deleted each time,
3872 necessitating a full checkout for each build. This insures a clean
3873 build off a complete checkout, avoiding any of the problems described
3874 above. This mode exercises the ``from-scratch'' build style.
3876 @item export
3877 this is like @code{clobber}, except that the 'cvs export' command is
3878 used to create the working directory. This command removes all CVS
3879 metadata files (the CVS/ directories) from the tree, which is
3880 sometimes useful for creating source tarballs (to avoid including the
3881 metadata in the tar file).
3882 @end table
3884 @item workdir
3885 like all Steps, this indicates the directory where the build will take
3886 place. Source Steps are special in that they perform some operations
3887 outside of the workdir (like creating the workdir itself).
3889 @item alwaysUseLatest
3890 if True, bypass the usual ``update to the last Change'' behavior, and
3891 always update to the latest changes instead.
3893 @item retry
3894 If set, this specifies a tuple of @code{(delay, repeats)} which means
3895 that when a full VC checkout fails, it should be retried up to
3896 @var{repeats} times, waiting @var{delay} seconds between attempts. If
3897 you don't provide this, it defaults to @code{None}, which means VC
3898 operations should not be retried. This is provided to make life easier
3899 for buildslaves which are stuck behind poor network connections.
3901 @end table
3904 My habit as a developer is to do a @code{cvs update} and @code{make} each
3905 morning. Problems can occur, either because of bad code being checked in, or
3906 by incomplete dependencies causing a partial rebuild to fail where a
3907 complete from-scratch build might succeed. A quick Builder which emulates
3908 this incremental-build behavior would use the @code{mode='update'}
3909 setting.
3911 On the other hand, other kinds of dependency problems can cause a clean
3912 build to fail where a partial build might succeed. This frequently results
3913 from a link step that depends upon an object file that was removed from a
3914 later version of the tree: in the partial tree, the object file is still
3915 around (even though the Makefiles no longer know how to create it).
3917 ``official'' builds (traceable builds performed from a known set of
3918 source revisions) are always done as clean builds, to make sure it is
3919 not influenced by any uncontrolled factors (like leftover files from a
3920 previous build). A ``full'' Builder which behaves this way would want
3921 to use the @code{mode='clobber'} setting.
3923 Each VC system has a corresponding source checkout class: their
3924 arguments are described on the following pages.
3927 @menu
3928 * CVS::                         
3929 * SVN::                         
3930 * Darcs::                       
3931 * Mercurial::                   
3932 * Arch::                        
3933 * Bazaar::                      
3934 * Bzr::                         
3935 * P4::                          
3936 * Git::                         
3937 @end menu
3939 @node CVS, SVN, Source Checkout, Source Checkout
3940 @subsubsection CVS
3941 @cindex CVS Checkout
3942 @bsindex buildbot.steps.source.CVS
3945 The @code{CVS} build step performs a @uref{http://www.nongnu.org/cvs/,
3946 CVS} checkout or update. It takes the following arguments:
3948 @table @code
3949 @item cvsroot
3950 (required): specify the CVSROOT value, which points to a CVS
3951 repository, probably on a remote machine. For example, the cvsroot
3952 value you would use to get a copy of the Buildbot source code is
3953 @code{:pserver:anonymous@@cvs.sourceforge.net:/cvsroot/buildbot}
3955 @item cvsmodule
3956 (required): specify the cvs @code{module}, which is generally a
3957 subdirectory of the CVSROOT. The cvsmodule for the Buildbot source
3958 code is @code{buildbot}.
3960 @item branch
3961 a string which will be used in a @code{-r} argument. This is most
3962 useful for specifying a branch to work on. Defaults to @code{HEAD}.
3964 @item global_options
3965 a list of flags to be put before the verb in the CVS command.
3967 @item checkoutDelay
3968 if set, the number of seconds to put between the timestamp of the last
3969 known Change and the value used for the @code{-D} option. Defaults to
3970 half of the parent Build's treeStableTimer.
3972 @end table
3975 @node SVN, Darcs, CVS, Source Checkout
3976 @subsubsection SVN
3978 @cindex SVN Checkout
3979 @bsindex buildbot.steps.source.SVN
3982 The @code{SVN} build step performs a
3983 @uref{http://subversion.tigris.org, Subversion} checkout or update.
3984 There are two basic ways of setting up the checkout step, depending
3985 upon whether you are using multiple branches or not.
3987 If all of your builds use the same branch, then you should create the
3988 @code{SVN} step with the @code{svnurl} argument:
3990 @table @code
3991 @item svnurl
3992 (required): this specifies the @code{URL} argument that will be given
3993 to the @code{svn checkout} command. It dictates both where the
3994 repository is located and which sub-tree should be extracted. In this
3995 respect, it is like a combination of the CVS @code{cvsroot} and
3996 @code{cvsmodule} arguments. For example, if you are using a remote
3997 Subversion repository which is accessible through HTTP at a URL of
3998 @code{http://svn.example.com/repos}, and you wanted to check out the
3999 @code{trunk/calc} sub-tree, you would use
4000 @code{svnurl="http://svn.example.com/repos/trunk/calc"} as an argument
4001 to your @code{SVN} step.
4002 @end table
4004 If, on the other hand, you are building from multiple branches, then
4005 you should create the @code{SVN} step with the @code{baseURL} and
4006 @code{defaultBranch} arguments instead:
4008 @table @code
4009 @item baseURL
4010 (required): this specifies the base repository URL, to which a branch
4011 name will be appended. It should probably end in a slash.
4013 @item defaultBranch
4014 this specifies the name of the branch to use when a Build does not
4015 provide one of its own. This will be appended to @code{baseURL} to
4016 create the string that will be passed to the @code{svn checkout}
4017 command.
4018 @end table
4020 If you are using branches, you must also make sure your
4021 @code{ChangeSource} will report the correct branch names.
4023 @heading branch example
4025 Let's suppose that the ``MyProject'' repository uses branches for the
4026 trunk, for various users' individual development efforts, and for
4027 several new features that will require some amount of work (involving
4028 multiple developers) before they are ready to merge onto the trunk.
4029 Such a repository might be organized as follows:
4031 @example
4032 svn://svn.example.org/MyProject/trunk
4033 svn://svn.example.org/MyProject/branches/User1/foo
4034 svn://svn.example.org/MyProject/branches/User1/bar
4035 svn://svn.example.org/MyProject/branches/User2/baz
4036 svn://svn.example.org/MyProject/features/newthing
4037 svn://svn.example.org/MyProject/features/otherthing
4038 @end example
4040 Further assume that we want the Buildbot to run tests against the
4041 trunk and against all the feature branches (i.e., do a
4042 checkout/compile/build of branch X when a file has been changed on
4043 branch X, when X is in the set [trunk, features/newthing,
4044 features/otherthing]). We do not want the Buildbot to automatically
4045 build any of the user branches, but it should be willing to build a
4046 user branch when explicitly requested (most likely by the user who
4047 owns that branch).
4049 There are three things that need to be set up to accomodate this
4050 system. The first is a ChangeSource that is capable of identifying the
4051 branch which owns any given file. This depends upon a user-supplied
4052 function, in an external program that runs in the SVN commit hook and
4053 connects to the buildmaster's @code{PBChangeSource} over a TCP
4054 connection. (you can use the ``@code{buildbot sendchange}'' utility
4055 for this purpose, but you will still need an external program to
4056 decide what value should be passed to the @code{--branch=} argument).
4057 For example, a change to a file with the SVN url of
4058 ``svn://svn.example.org/MyProject/features/newthing/src/foo.c'' should
4059 be broken down into a Change instance with
4060 @code{branch='features/newthing'} and @code{file='src/foo.c'}.
4062 The second piece is an @code{AnyBranchScheduler} which will pay
4063 attention to the desired branches. It will not pay attention to the
4064 user branches, so it will not automatically start builds in response
4065 to changes there. The AnyBranchScheduler class requires you to
4066 explicitly list all the branches you want it to use, but it would not
4067 be difficult to write a subclass which used
4068 @code{branch.startswith('features/'} to remove the need for this
4069 explicit list. Or, if you want to build user branches too, you can use
4070 AnyBranchScheduler with @code{branches=None} to indicate that you want
4071 it to pay attention to all branches.
4073 The third piece is an @code{SVN} checkout step that is configured to
4074 handle the branches correctly, with a @code{baseURL} value that
4075 matches the way the ChangeSource splits each file's URL into base,
4076 branch, and file.
4078 @example
4079 from buildbot.changes.pb import PBChangeSource
4080 from buildbot.scheduler import AnyBranchScheduler
4081 from buildbot.process import source, factory
4082 from buildbot.steps import source, shell
4084 c['change_source'] = PBChangeSource()
4085 s1 = AnyBranchScheduler('main',
4086                         ['trunk', 'features/newthing', 'features/otherthing'],
4087                         10*60, ['test-i386', 'test-ppc'])
4088 c['schedulers'] = [s1]
4090 f = factory.BuildFactory()
4091 f.addStep(source.SVN(mode='update',
4092                      baseURL='svn://svn.example.org/MyProject/',
4093                      defaultBranch='trunk'))
4094 f.addStep(shell.Compile(command="make all"))
4095 f.addStep(shell.Test(command="make test"))
4097 c['builders'] = [
4098   @{'name':'test-i386', 'slavename':'bot-i386', 'builddir':'test-i386',
4099                        'factory':f @},
4100   @{'name':'test-ppc', 'slavename':'bot-ppc', 'builddir':'test-ppc',
4101                       'factory':f @},
4103 @end example
4105 In this example, when a change arrives with a @code{branch} attribute
4106 of ``trunk'', the resulting build will have an SVN step that
4107 concatenates ``svn://svn.example.org/MyProject/'' (the baseURL) with
4108 ``trunk'' (the branch name) to get the correct svn command. If the
4109 ``newthing'' branch has a change to ``src/foo.c'', then the SVN step
4110 will concatenate ``svn://svn.example.org/MyProject/'' with
4111 ``features/newthing'' to get the svnurl for checkout.
4113 @node Darcs, Mercurial, SVN, Source Checkout
4114 @subsubsection Darcs
4116 @cindex Darcs Checkout
4117 @bsindex buildbot.steps.source.Darcs
4120 The @code{Darcs} build step performs a
4121 @uref{http://darcs.net/, Darcs} checkout or update.
4123 Like @xref{SVN}, this step can either be configured to always check
4124 out a specific tree, or set up to pull from a particular branch that
4125 gets specified separately for each build. Also like SVN, the
4126 repository URL given to Darcs is created by concatenating a
4127 @code{baseURL} with the branch name, and if no particular branch is
4128 requested, it uses a @code{defaultBranch}. The only difference in
4129 usage is that each potential Darcs repository URL must point to a
4130 fully-fledged repository, whereas SVN URLs usually point to sub-trees
4131 of the main Subversion repository. In other words, doing an SVN
4132 checkout of @code{baseURL} is legal, but silly, since you'd probably
4133 wind up with a copy of every single branch in the whole repository.
4134 Doing a Darcs checkout of @code{baseURL} is just plain wrong, since
4135 the parent directory of a collection of Darcs repositories is not
4136 itself a valid repository.
4138 The Darcs step takes the following arguments:
4140 @table @code
4141 @item repourl
4142 (required unless @code{baseURL} is provided): the URL at which the
4143 Darcs source repository is available.
4145 @item baseURL
4146 (required unless @code{repourl} is provided): the base repository URL,
4147 to which a branch name will be appended. It should probably end in a
4148 slash.
4150 @item defaultBranch
4151 (allowed if and only if @code{baseURL} is provided): this specifies
4152 the name of the branch to use when a Build does not provide one of its
4153 own. This will be appended to @code{baseURL} to create the string that
4154 will be passed to the @code{darcs get} command.
4155 @end table
4157 @node Mercurial, Arch, Darcs, Source Checkout
4158 @subsubsection Mercurial
4160 @cindex Mercurial Checkout
4161 @bsindex buildbot.steps.source.Mercurial
4164 The @code{Mercurial} build step performs a
4165 @uref{http://selenic.com/mercurial, Mercurial} (aka ``hg'') checkout
4166 or update.
4168 Branches are handled just like @xref{Darcs}.
4170 The Mercurial step takes the following arguments:
4172 @table @code
4173 @item repourl
4174 (required unless @code{baseURL} is provided): the URL at which the
4175 Mercurial source repository is available.
4177 @item baseURL
4178 (required unless @code{repourl} is provided): the base repository URL,
4179 to which a branch name will be appended. It should probably end in a
4180 slash.
4182 @item defaultBranch
4183 (allowed if and only if @code{baseURL} is provided): this specifies
4184 the name of the branch to use when a Build does not provide one of its
4185 own. This will be appended to @code{baseURL} to create the string that
4186 will be passed to the @code{hg clone} command.
4187 @end table
4190 @node Arch, Bazaar, Mercurial, Source Checkout
4191 @subsubsection Arch
4193 @cindex Arch Checkout
4194 @bsindex buildbot.steps.source.Arch
4197 The @code{Arch} build step performs an @uref{http://gnuarch.org/,
4198 Arch} checkout or update using the @code{tla} client. It takes the
4199 following arguments:
4201 @table @code
4202 @item url
4203 (required): this specifies the URL at which the Arch source archive is
4204 available.
4206 @item version
4207 (required): this specifies which ``development line'' (like a branch)
4208 should be used. This provides the default branch name, but individual
4209 builds may specify a different one.
4211 @item archive
4212 (optional): Each repository knows its own archive name. If this
4213 parameter is provided, it must match the repository's archive name.
4214 The parameter is accepted for compatibility with the @code{Bazaar}
4215 step, below.
4217 @end table
4219 @node Bazaar, Bzr, Arch, Source Checkout
4220 @subsubsection Bazaar
4222 @cindex Bazaar Checkout
4223 @bsindex buildbot.steps.source.Bazaar
4226 @code{Bazaar} is an alternate implementation of the Arch VC system,
4227 which uses a client named @code{baz}. The checkout semantics are just
4228 different enough from @code{tla} that there is a separate BuildStep for
4231 It takes exactly the same arguments as @code{Arch}, except that the
4232 @code{archive=} parameter is required. (baz does not emit the archive
4233 name when you do @code{baz register-archive}, so we must provide it
4234 ourselves).
4237 @node Bzr, P4, Bazaar, Source Checkout
4238 @subsubsection Bzr
4240 @cindex Bzr Checkout
4241 @bsindex buildbot.steps.source.Bzr
4243 @code{bzr} is a descendant of Arch/Baz, and is frequently referred to
4244 as simply ``Bazaar''. The repository-vs-workspace model is similar to
4245 Darcs, but it uses a strictly linear sequence of revisions (one
4246 history per branch) like Arch. Branches are put in subdirectories.
4247 This makes it look very much like Mercurial, so it takes the same
4248 arguments:
4250 @table @code
4252 @item repourl
4253 (required unless @code{baseURL} is provided): the URL at which the
4254 Bzr source repository is available.
4256 @item baseURL
4257 (required unless @code{repourl} is provided): the base repository URL,
4258 to which a branch name will be appended. It should probably end in a
4259 slash.
4261 @item defaultBranch
4262 (allowed if and only if @code{baseURL} is provided): this specifies
4263 the name of the branch to use when a Build does not provide one of its
4264 own. This will be appended to @code{baseURL} to create the string that
4265 will be passed to the @code{bzr checkout} command.
4266 @end table
4270 @node P4, Git, Bzr, Source Checkout
4271 @subsubsection P4
4273 @cindex Perforce Update
4274 @bsindex buildbot.steps.source.P4
4275 @c TODO @bsindex buildbot.steps.source.P4Sync
4278 The @code{P4} build step creates a @uref{http://www.perforce.com/,
4279 Perforce} client specification and performs an update.
4281 @table @code
4282 @item p4base
4283 A view into the Perforce depot without branch name or trailing "...".
4284 Typically "//depot/proj/".
4285 @item defaultBranch
4286 A branch name to append on build requests if none is specified.
4287 Typically "trunk".
4288 @item p4port
4289 (optional): the host:port string describing how to get to the P4 Depot
4290 (repository), used as the -p argument for all p4 commands.
4291 @item p4user
4292 (optional): the Perforce user, used as the -u argument to all p4
4293 commands.
4294 @item p4passwd
4295 (optional): the Perforce password, used as the -p argument to all p4
4296 commands.
4297 @item p4extra_views
4298 (optional): a list of (depotpath, clientpath) tuples containing extra
4299 views to be mapped into the client specification. Both will have
4300 "/..." appended automatically. The client name and source directory
4301 will be prepended to the client path.
4302 @item p4client
4303 (optional): The name of the client to use. In mode='copy' and
4304 mode='update', it's particularly important that a unique name is used
4305 for each checkout directory to avoid incorrect synchronization. For
4306 this reason, Python percent substitution will be performed on this value
4307 to replace %(slave)s with the slave name and %(builder)s with the
4308 builder name. The default is "buildbot_%(slave)s_%(build)s".
4309 @end table
4312 @node Git,  , P4, Source Checkout
4313 @subsubsection Git
4315 @cindex Git Checkout
4316 @bsindex buildbot.steps.source.Git
4318 The @code{Git} build step clones or updates a @uref{http://git.or.cz/,
4319 Git} repository and checks out the specified branch or revision. Note
4320 that the buildbot supports Git version 1.2.0 and later: earlier
4321 versions (such as the one shipped in Ubuntu 'Dapper') do not support
4322 the @command{git init} command that the buildbot uses.
4324 The Git step takes the following arguments:
4326 @table @code
4327 @item repourl
4328 (required): the URL of the upstream Git repository.
4330 @item branch
4331 (optional): this specifies the name of the branch to use when a Build
4332 does not provide one of its own. If this this parameter is not
4333 specified, and the Build does not provide a branch, the ``master''
4334 branch will be used.
4335 @end table
4338 @node ShellCommand, Simple ShellCommand Subclasses, Source Checkout, Build Steps
4339 @subsection ShellCommand
4341 @bsindex buildbot.steps.shell.ShellCommand
4342 @c TODO @bsindex buildbot.steps.shell.TreeSize
4344 This is a useful base class for just about everything you might want
4345 to do during a build (except for the initial source checkout). It runs
4346 a single command in a child shell on the buildslave. All stdout/stderr
4347 is recorded into a LogFile. The step finishes with a status of FAILURE
4348 if the command's exit code is non-zero, otherwise it has a status of
4349 SUCCESS.
4351 The preferred way to specify the command is with a list of argv strings,
4352 since this allows for spaces in filenames and avoids doing any fragile
4353 shell-escaping. You can also specify the command with a single string, in
4354 which case the string is given to '/bin/sh -c COMMAND' for parsing.
4356 All ShellCommands are run by default in the ``workdir'', which
4357 defaults to the ``@file{build}'' subdirectory of the slave builder's
4358 base directory. The absolute path of the workdir will thus be the
4359 slave's basedir (set as an option to @code{buildbot create-slave},
4360 @pxref{Creating a buildslave}) plus the builder's basedir (set in the
4361 builder's @code{c['builddir']} key in master.cfg) plus the workdir
4362 itself (a class-level attribute of the BuildFactory, defaults to
4363 ``@file{build}'').
4365 @code{ShellCommand} arguments:
4367 @table @code
4368 @item command
4369 a list of strings (preferred) or single string (discouraged) which
4370 specifies the command to be run. A list of strings is preferred
4371 because it can be used directly as an argv array. Using a single
4372 string (with embedded spaces) requires the buildslave to pass the
4373 string to /bin/sh for interpretation, which raises all sorts of
4374 difficult questions about how to escape or interpret shell
4375 metacharacters.
4377 @item env
4378 a dictionary of environment strings which will be added to the child
4379 command's environment. For example, to run tests with a different i18n
4380 language setting, you might use
4382 @example
4383 f.addStep(ShellCommand, command=["make", "test"],
4384           env=@{'LANG': 'fr_FR'@})
4385 @end example
4387 These variable settings will override any existing ones in the
4388 buildslave's environment. The exception is PYTHONPATH, which is merged
4389 with (actually prepended to) any existing $PYTHONPATH setting. The
4390 value is treated as a list of directories to prepend, and a single
4391 string is treated like a one-item list. For example, to prepend both
4392 @file{/usr/local/lib/python2.3} and @file{/home/buildbot/lib/python}
4393 to any existing $PYTHONPATH setting, you would do something like the
4394 following:
4396 @example
4397 f.addStep(ShellCommand, command=["make", "test"],
4398           env=@{'PYTHONPATH': ["/usr/local/lib/python2.3",
4399                               "/home/buildbot/lib/python"] @})
4400 @end example
4402 @item want_stdout
4403 if False, stdout from the child process is discarded rather than being
4404 sent to the buildmaster for inclusion in the step's LogFile.
4406 @item want_stderr
4407 like @code{want_stdout} but for stderr. Note that commands run through
4408 a PTY do not have separate stdout/stderr streams: both are merged into
4409 stdout.
4411 @item logfiles
4412 Sometimes commands will log interesting data to a local file, rather
4413 than emitting everything to stdout or stderr. For example, Twisted's
4414 ``trial'' command (which runs unit tests) only presents summary
4415 information to stdout, and puts the rest into a file named
4416 @file{_trial_temp/test.log}. It is often useful to watch these files
4417 as the command runs, rather than using @command{/bin/cat} to dump
4418 their contents afterwards.
4420 The @code{logfiles=} argument allows you to collect data from these
4421 secondary logfiles in near-real-time, as the step is running. It
4422 accepts a dictionary which maps from a local Log name (which is how
4423 the log data is presented in the build results) to a remote filename
4424 (interpreted relative to the build's working directory). Each named
4425 file will be polled on a regular basis (every couple of seconds) as
4426 the build runs, and any new text will be sent over to the buildmaster.
4428 @example
4429 f.addStep(ShellCommand, command=["make", "test"],
4430           logfiles=@{"triallog": "_trial_temp/test.log"@})
4431 @end example
4434 @item timeout
4435 if the command fails to produce any output for this many seconds, it
4436 is assumed to be locked up and will be killed.
4438 @item description
4439 This will be used to describe the command (on the Waterfall display)
4440 while the command is still running. It should be a single
4441 imperfect-tense verb, like ``compiling'' or ``testing''. The preferred
4442 form is a list of short strings, which allows the HTML Waterfall
4443 display to create narrower columns by emitting a <br> tag between each
4444 word. You may also provide a single string.
4446 @item descriptionDone
4447 This will be used to describe the command once it has finished. A
4448 simple noun like ``compile'' or ``tests'' should be used. Like
4449 @code{description}, this may either be a list of short strings or a
4450 single string.
4452 If neither @code{description} nor @code{descriptionDone} are set, the
4453 actual command arguments will be used to construct the description.
4454 This may be a bit too wide to fit comfortably on the Waterfall
4455 display.
4457 @example
4458 f.addStep(ShellCommand, command=["make", "test"],
4459           description=["testing"],
4460           descriptionDone=["tests"])
4461 @end example
4463 @end table
4465 @node Simple ShellCommand Subclasses, Python BuildSteps, ShellCommand, Build Steps
4466 @subsection Simple ShellCommand Subclasses
4468 Several subclasses of ShellCommand are provided as starting points for
4469 common build steps. These are all very simple: they just override a few
4470 parameters so you don't have to specify them yourself, making the master.cfg
4471 file less verbose.
4473 @menu
4474 * Configure::                   
4475 * Compile::                     
4476 * Test::                        
4477 * TreeSize::                    
4478 * Build Properties::            
4479 @end menu
4481 @node Configure, Compile, Simple ShellCommand Subclasses, Simple ShellCommand Subclasses
4482 @subsubsection Configure
4484 @bsindex buildbot.steps.shell.Configure
4486 This is intended to handle the @code{./configure} step from
4487 autoconf-style projects, or the @code{perl Makefile.PL} step from perl
4488 MakeMaker.pm-style modules. The default command is @code{./configure}
4489 but you can change this by providing a @code{command=} parameter.
4491 @node Compile, Test, Configure, Simple ShellCommand Subclasses
4492 @subsubsection Compile
4494 @bsindex buildbot.steps.shell.Compile
4496 This is meant to handle compiling or building a project written in C.
4497 The default command is @code{make all}. When the compile is finished,
4498 the log file is scanned for GCC warning messages, a summary log is
4499 created with any problems that were seen, and the step is marked as
4500 WARNINGS if any were discovered. The number of warnings is stored in a
4501 Build Property named ``warnings-count'', which is accumulated over all
4502 Compile steps (so if two warnings are found in one step, and three are
4503 found in another step, the overall build will have a
4504 ``warnings-count'' property of 5.
4506 The default regular expression used to detect a warning is
4507 @code{'.*warning[: ].*'} , which is fairly liberal and may cause
4508 false-positives. To use a different regexp, provide a
4509 @code{warningPattern=} argument, or use a subclass which sets the
4510 @code{warningPattern} attribute:
4512 @example
4513 f.addStep(Compile(command=["make", "test"],
4514                   warningPattern="^Warning: "))
4515 @end example
4517 The @code{warningPattern=} can also be a pre-compiled python regexp
4518 object: this makes it possible to add flags like @code{re.I} (to use
4519 case-insensitive matching).
4521 (TODO: this step needs to be extended to look for GCC error messages
4522 as well, and collect them into a separate logfile, along with the
4523 source code filenames involved).
4526 @node Test, TreeSize, Compile, Simple ShellCommand Subclasses
4527 @subsubsection Test
4529 @bsindex buildbot.steps.shell.Test
4531 This is meant to handle unit tests. The default command is @code{make
4532 test}, and the @code{warnOnFailure} flag is set.
4534 @node TreeSize, Build Properties, Test, Simple ShellCommand Subclasses
4535 @subsubsection TreeSize
4537 @bsindex buildbot.steps.shell.TreeSize
4539 This is a simple command that uses the 'du' tool to measure the size
4540 of the code tree. It puts the size (as a count of 1024-byte blocks,
4541 aka 'KiB' or 'kibibytes') on the step's status text, and sets a build
4542 property named 'tree-size-KiB' with the same value.
4545 @node Build Properties,  , TreeSize, Simple ShellCommand Subclasses
4546 @subsubsection Build Properties
4548 @cindex build properties
4550 Each build has a set of ``Build Properties'', which can be used by its
4551 BuildStep to modify their actions. For example, the SVN revision
4552 number of the source code being built is available as a build
4553 property, and a ShellCommand step could incorporate this number into a
4554 command which create a numbered release tarball.
4556 Some build properties are set when the build starts, such as the
4557 SourceStamp information. Other properties can be set by BuildSteps as
4558 they run, for example the various Source steps will set the
4559 @code{got_revision} property to the source revision that was actually
4560 checked out (which can be useful when the SourceStamp in use merely
4561 requested the ``latest revision'': @code{got_revision} will tell you
4562 what was actually built).
4564 In custom BuildSteps, you can get and set the build properties with
4565 the @code{getProperty}/@code{setProperty} methods. Each takes a string
4566 for the name of the property, and returns or accepts an
4567 arbitrary@footnote{Build properties are serialized along with the
4568 build results, so they must be serializable. For this reason, the
4569 value of any build property should be simple inert data: strings,
4570 numbers, lists, tuples, and dictionaries. They should not contain
4571 class instances.} object. For example:
4573 @example
4574 class MakeTarball(ShellCommand):
4575     def start(self):
4576         self.setCommand(["tar", "czf",
4577                          "build-%s.tar.gz" % self.getProperty("revision"),
4578                          "source"])
4579         ShellCommand.start(self)
4580 @end example
4582 @cindex WithProperties
4584 You can use build properties in ShellCommands by using the
4585 @code{WithProperties} wrapper when setting the arguments of the
4586 ShellCommand. This interpolates the named build properties into the
4587 generated shell command. You can also use a @code{WithProperties} as
4588 the @code{workdir=} argument: this allows the working directory for a
4589 command to be varied for each build, depending upon various build
4590 properties.
4592 @example
4593 from buildbot.steps.shell import ShellCommand, WithProperties
4595 f.addStep(ShellCommand,
4596           command=["tar", "czf",
4597                    WithProperties("build-%s.tar.gz", "revision"),
4598                    "source"])
4599 @end example
4601 If this BuildStep were used in a tree obtained from Subversion, it
4602 would create a tarball with a name like @file{build-1234.tar.gz}.
4604 The @code{WithProperties} function does @code{printf}-style string
4605 interpolation, using strings obtained by calling
4606 @code{build.getProperty(propname)}. Note that for every @code{%s} (or
4607 @code{%d}, etc), you must have exactly one additional argument to
4608 indicate which build property you want to insert.
4611 You can also use python dictionary-style string interpolation by using
4612 the @code{%(propname)s} syntax. In this form, the property name goes
4613 in the parentheses, and WithProperties takes @emph{no} additional
4614 arguments:
4616 @example
4617 f.addStep(ShellCommand,
4618           command=["tar", "czf",
4619                    WithProperties("build-%(revision)s.tar.gz"),
4620                    "source"])
4621 @end example
4623 Don't forget the extra ``s'' after the closing parenthesis! This is
4624 the cause of many confusing errors. Also note that you can only use
4625 WithProperties in the list form of the command= definition. You cannot
4626 currently use it in the (discouraged) @code{command="stuff"}
4627 single-string form. However, you can use something like
4628 @code{command=["/bin/sh", "-c", "stuff", WithProperties(stuff)]} to
4629 use both shell expansion and WithProperties interpolation.
4631 Note that, like python, you can either do positional-argument
4632 interpolation @emph{or} keyword-argument interpolation, not both. Thus
4633 you cannot use a string like
4634 @code{WithProperties("foo-%(revision)s-%s", "branch")}.
4636 At the moment, the only way to set build properties is by writing a
4637 custom BuildStep.
4639 @heading Common Build Properties
4641 The following build properties are set when the build is started, and
4642 are available to all steps.
4644 @table @code
4645 @item branch
4647 This comes from the build's SourceStamp, and describes which branch is
4648 being checked out. This will be @code{None} (which interpolates into
4649 @code{WithProperties} as an empty string) if the build is on the
4650 default branch, which is generally the trunk. Otherwise it will be a
4651 string like ``branches/beta1.4''. The exact syntax depends upon the VC
4652 system being used.
4654 @item revision
4656 This also comes from the SourceStamp, and is the revision of the
4657 source code tree that was requested from the VC system. When a build
4658 is requested of a specific revision (as is generally the case when the
4659 build is triggered by Changes), this will contain the revision
4660 specification. The syntax depends upon the VC system in use: for SVN
4661 it is an integer, for Mercurial it is a short string, for Darcs it is
4662 a rather large string, etc.
4664 If the ``force build'' button was pressed, the revision will be
4665 @code{None}, which means to use the most recent revision available.
4666 This is a ``trunk build''. This will be interpolated as an empty
4667 string.
4669 @item got_revision
4671 This is set when a Source step checks out the source tree, and
4672 provides the revision that was actually obtained from the VC system.
4673 In general this should be the same as @code{revision}, except for
4674 trunk builds, where @code{got_revision} indicates what revision was
4675 current when the checkout was performed. This can be used to rebuild
4676 the same source code later.
4678 Note that for some VC systems (Darcs in particular), the revision is a
4679 large string containing newlines, and is not suitable for
4680 interpolation into a filename.
4682 @item buildername
4684 This is a string that indicates which Builder the build was a part of.
4685 The combination of buildername and buildnumber uniquely identify a
4686 build.
4688 @item buildnumber
4690 Each build gets a number, scoped to the Builder (so the first build
4691 performed on any given Builder will have a build number of 0). This
4692 integer property contains the build's number.
4694 @item slavename
4696 This is a string which identifies which buildslave the build is
4697 running on.
4699 @end table
4701 @node Python BuildSteps, Transferring Files, Simple ShellCommand Subclasses, Build Steps
4702 @subsection Python BuildSteps
4704 Here are some BuildSteps that are specifcally useful for projects
4705 implemented in Python.
4707 @menu
4708 * BuildEPYDoc::                 
4709 * PyFlakes::                    
4710 @end menu
4712 @node BuildEPYDoc, PyFlakes, Python BuildSteps, Python BuildSteps
4713 @subsubsection BuildEPYDoc
4715 @bsindex buildbot.steps.python.BuildEPYDoc
4717 @url{http://epydoc.sourceforge.net/, epydoc} is a tool for generating
4718 API documentation for Python modules from their docstrings. It reads
4719 all the .py files from your source tree, processes the docstrings
4720 therein, and creates a large tree of .html files (or a single .pdf
4721 file).
4723 The @code{buildbot.steps.python.BuildEPYDoc} step will run
4724 @command{epydoc} to produce this API documentation, and will count the
4725 errors and warnings from its output.
4727 You must supply the command line to be used. The default is
4728 @command{make epydocs}, which assumes that your project has a Makefile
4729 with an ``epydocs'' target. You might wish to use something like
4730 @command{epydoc -o apiref source/PKGNAME} instead. You might also want
4731 to add @command{--pdf} to generate a PDF file instead of a large tree
4732 of HTML files.
4734 The API docs are generated in-place in the build tree (under the
4735 workdir, in the subdirectory controlled by the ``-o'' argument). To
4736 make them useful, you will probably have to copy them to somewhere
4737 they can be read. A command like @command{rsync -ad apiref/
4738 dev.example.com:~public_html/current-apiref/} might be useful. You
4739 might instead want to bundle them into a tarball and publish it in the
4740 same place where the generated install tarball is placed.
4742 @example
4743 from buildbot.steps.python import BuildEPYDoc
4746 f.addStep(BuildEPYDoc, command=["epydoc", "-o", "apiref", "source/mypkg"])
4747 @end example
4750 @node PyFlakes,  , BuildEPYDoc, Python BuildSteps
4751 @subsubsection PyFlakes
4753 @bsindex buildbot.steps.python.PyFlakes
4755 @url{http://divmod.org/trac/wiki/DivmodPyflakes, PyFlakes} is a tool
4756 to perform basic static analysis of Python code to look for simple
4757 errors, like missing imports and references of undefined names. It is
4758 like a fast and simple form of the C ``lint'' program. Other tools
4759 (like pychecker) provide more detailed results but take longer to run.
4761 The @code{buildbot.steps.python.PyFlakes} step will run pyflakes and
4762 count the various kinds of errors and warnings it detects.
4764 You must supply the command line to be used. The default is
4765 @command{make pyflakes}, which assumes you have a top-level Makefile
4766 with a ``pyflakes'' target. You might want to use something like
4767 @command{pyflakes .} or @command{pyflakes src}.
4769 @example
4770 from buildbot.steps.python import PyFlakes
4773 f.addStep(PyFlakes, command=["pyflakes", "src"])
4774 @end example
4777 @node Transferring Files, Triggering Schedulers, Python BuildSteps, Build Steps
4778 @subsection Transferring Files
4780 @cindex File Transfer
4781 @bsindex buildbot.steps.transfer.FileUpload
4782 @bsindex buildbot.steps.transfer.FileDownload
4784 Most of the work involved in a build will take place on the
4785 buildslave. But occasionally it is useful to do some work on the
4786 buildmaster side. The most basic way to involve the buildmaster is
4787 simply to move a file from the slave to the master, or vice versa.
4788 There are a pair of BuildSteps named @code{FileUpload} and
4789 @code{FileDownload} to provide this functionality. @code{FileUpload}
4790 moves a file @emph{up to} the master, while @code{FileDownload} moves
4791 a file @emph{down from} the master.
4793 As an example, let's assume that there is a step which produces an
4794 HTML file within the source tree that contains some sort of generated
4795 project documentation. We want to move this file to the buildmaster,
4796 into a @file{~/public_html} directory, so it can be visible to
4797 developers. This file will wind up in the slave-side working directory
4798 under the name @file{docs/reference.html}. We want to put it into the
4799 master-side @file{~/public_html/ref.html}.
4801 @example
4802 from buildbot.steps.shell import ShellCommand
4803 from buildbot.steps.transfer import FileUpload
4805 f.addStep(ShellCommand, command=["make", "docs"])
4806 f.addStep(FileUpload,
4807           slavesrc="docs/reference.html",
4808           masterdest="~/public_html/ref.html")
4809 @end example
4811 The @code{masterdest=} argument will be passed to os.path.expanduser,
4812 so things like ``~'' will be expanded properly. Non-absolute paths
4813 will be interpreted relative to the buildmaster's base directory.
4814 Likewise, the @code{slavesrc=} argument will be expanded and
4815 interpreted relative to the builder's working directory.
4818 To move a file from the master to the slave, use the
4819 @code{FileDownload} command. For example, let's assume that some step
4820 requires a configuration file that, for whatever reason, could not be
4821 recorded in the source code repository or generated on the buildslave
4822 side:
4824 @example
4825 from buildbot.steps.shell import ShellCommand
4826 from buildbot.steps.transfer import FileUpload
4828 f.addStep(FileDownload
4829           mastersrc="~/todays_build_config.txt",
4830           slavedest="build_config.txt")
4831 f.addStep(ShellCommand, command=["make", "config"])
4832 @end example
4834 Like @code{FileUpload}, the @code{mastersrc=} argument is interpreted
4835 relative to the buildmaster's base directory, and the
4836 @code{slavedest=} argument is relative to the builder's working
4837 directory. If the buildslave is running in @file{~buildslave}, and the
4838 builder's ``builddir'' is something like @file{tests-i386}, then the
4839 workdir is going to be @file{~buildslave/tests-i386/build}, and a
4840 @code{slavedest=} of @file{foo/bar.html} will get put in
4841 @file{~buildslave/tests-i386/build/foo/bar.html}. Remember that
4842 neither of these commands will create missing directories for you.
4845 @subheading Other Parameters
4847 The @code{maxsize=} argument lets you set a maximum size for the file
4848 to be transferred. This may help to avoid surprises: transferring a
4849 100MB coredump when you were expecting to move a 10kB status file
4850 might take an awfully long time. The @code{blocksize=} argument
4851 controls how the file is sent over the network: larger blocksizes are
4852 slightly more efficient but also consume more memory on each end, and
4853 there is a hard-coded limit of about 640kB.
4855 The @code{mode=} argument allows you to control the access permissions
4856 of the target file, traditionally expressed as an octal integer. The
4857 most common value is probably 0755, which sets the ``x'' executable
4858 bit on the file (useful for shell scripts and the like). The default
4859 value for @code{mode=} is None, which means the permission bits will
4860 default to whatever the umask of the writing process is. The default
4861 umask tends to be fairly restrictive, but at least on the buildslave
4862 you can make it less restrictive with a --umask command-line option at
4863 creation time (@pxref{Buildslave Options}).
4866 @node Triggering Schedulers, Writing New BuildSteps, Transferring Files, Build Steps
4867 @subsection Triggering Schedulers
4869 The counterpart to the Triggerable described in section
4870 @pxref{Build Dependencies} is the Trigger BuildStep.
4872 @example
4873 from buildbot.steps.trigger import Trigger
4874 f.addStep(Trigger, schedulerNames=['build-prep'],
4875                    waitForFinish=True,
4876                    updateSourceStamp=True)
4877 @end example
4879 The @code{schedulerNames=} argument lists the Triggerables
4880 that should be triggered when this step is executed.  Note that
4881 it is possible, but not advisable, to create a cycle where a build
4882 continually triggers itself, because the schedulers are specified
4883 by name.
4885 If @code{waitForFinish} is True, then the step will not finish until
4886 all of the builds from the triggered schedulers have finished. If this
4887 argument is False (the default) or not given, then the buildstep
4888 succeeds immediately after triggering the schedulers.
4890 If @code{updateSourceStamp} is True (the default), then step updates
4891 the SourceStamp given to the Triggerables to include
4892 @code{got_revision} (the revision actually used in this build) as
4893 @code{revision} (the revision to use in the triggered builds). This is
4894 useful to ensure that all of the builds use exactly the same
4895 SourceStamp, even if other Changes have occurred while the build was
4896 running.
4898 @node Writing New BuildSteps,  , Triggering Schedulers, Build Steps
4899 @subsection Writing New BuildSteps
4901 While it is a good idea to keep your build process self-contained in
4902 the source code tree, sometimes it is convenient to put more
4903 intelligence into your Buildbot configuration. One was to do this is
4904 to write a custom BuildStep. Once written, this Step can be used in
4905 the @file{master.cfg} file.
4907 The best reason for writing a custom BuildStep is to better parse the
4908 results of the command being run. For example, a BuildStep that knows
4909 about JUnit could look at the logfiles to determine which tests had
4910 been run, how many passed and how many failed, and then report more
4911 detailed information than a simple @code{rc==0} -based ``good/bad''
4912 decision.
4914 TODO: add more description of BuildSteps.
4916 @menu
4917 * BuildStep LogFiles::          
4918 * Reading Logfiles::            
4919 * Adding LogObservers::         
4920 * BuildStep URLs::              
4921 @end menu
4923 @node BuildStep LogFiles, Reading Logfiles, Writing New BuildSteps, Writing New BuildSteps
4924 @subsubsection BuildStep LogFiles
4926 Each BuildStep has a collection of ``logfiles''. Each one has a short
4927 name, like ``stdio'' or ``warnings''. Each LogFile contains an
4928 arbitrary amount of text, usually the contents of some output file
4929 generated during a build or test step, or a record of everything that
4930 was printed to stdout/stderr during the execution of some command.
4932 These LogFiles are stored to disk, so they can be retrieved later.
4934 Each can contain multiple ``channels'', generally limited to three
4935 basic ones: stdout, stderr, and ``headers''. For example, when a
4936 ShellCommand runs, it writes a few lines to the ``headers'' channel to
4937 indicate the exact argv strings being run, which directory the command
4938 is being executed in, and the contents of the current environment
4939 variables. Then, as the command runs, it adds a lot of ``stdout'' and
4940 ``stderr'' messages. When the command finishes, a final ``header''
4941 line is added with the exit code of the process.
4943 Status display plugins can format these different channels in
4944 different ways. For example, the web page shows LogFiles as text/html,
4945 with header lines in blue text, stdout in black, and stderr in red. A
4946 different URL is available which provides a text/plain format, in
4947 which stdout and stderr are collapsed together, and header lines are
4948 stripped completely. This latter option makes it easy to save the
4949 results to a file and run @command{grep} or whatever against the
4950 output.
4952 Each BuildStep contains a mapping (implemented in a python dictionary)
4953 from LogFile name to the actual LogFile objects. Status plugins can
4954 get a list of LogFiles to display, for example, a list of HREF links
4955 that, when clicked, provide the full contents of the LogFile.
4957 @heading Using LogFiles in custom BuildSteps
4959 The most common way for a custom BuildStep to use a LogFile is to
4960 summarize the results of a ShellCommand (after the command has
4961 finished running). For example, a compile step with thousands of lines
4962 of output might want to create a summary of just the warning messages.
4963 If you were doing this from a shell, you would use something like:
4965 @example
4966 grep "warning:" output.log >warnings.log
4967 @end example
4969 In a custom BuildStep, you could instead create a ``warnings'' LogFile
4970 that contained the same text. To do this, you would add code to your
4971 @code{createSummary} method that pulls lines from the main output log
4972 and creates a new LogFile with the results:
4974 @example
4975     def createSummary(self, log):
4976         warnings = []
4977         for line in log.readlines():
4978             if "warning:" in line:
4979                 warnings.append()
4980         self.addCompleteLog('warnings', "".join(warnings))
4981 @end example
4983 This example uses the @code{addCompleteLog} method, which creates a
4984 new LogFile, puts some text in it, and then ``closes'' it, meaning
4985 that no further contents will be added. This LogFile will appear in
4986 the HTML display under an HREF with the name ``warnings'', since that
4987 is the name of the LogFile.
4989 You can also use @code{addHTMLLog} to create a complete (closed)
4990 LogFile that contains HTML instead of plain text. The normal LogFile
4991 will be HTML-escaped if presented through a web page, but the HTML
4992 LogFile will not. At the moment this is only used to present a pretty
4993 HTML representation of an otherwise ugly exception traceback when
4994 something goes badly wrong during the BuildStep.
4996 In contrast, you might want to create a new LogFile at the beginning
4997 of the step, and add text to it as the command runs. You can create
4998 the LogFile and attach it to the build by calling @code{addLog}, which
4999 returns the LogFile object. You then add text to this LogFile by
5000 calling methods like @code{addStdout} and @code{addHeader}. When you
5001 are done, you must call the @code{finish} method so the LogFile can be
5002 closed. It may be useful to create and populate a LogFile like this
5003 from a LogObserver method @xref{Adding LogObservers}.
5005 The @code{logfiles=} argument to @code{ShellCommand} (see
5006 @pxref{ShellCommand}) creates new LogFiles and fills them in realtime
5007 by asking the buildslave to watch a actual file on disk. The
5008 buildslave will look for additions in the target file and report them
5009 back to the BuildStep. These additions will be added to the LogFile by
5010 calling @code{addStdout}. These secondary LogFiles can be used as the
5011 source of a LogObserver just like the normal ``stdio'' LogFile.
5013 @node Reading Logfiles, Adding LogObservers, BuildStep LogFiles, Writing New BuildSteps
5014 @subsubsection Reading Logfiles
5016 Once a LogFile has been added to a BuildStep with @code{addLog()},
5017 @code{addCompleteLog()}, @code{addHTMLLog()}, or @code{logfiles=},
5018 your BuildStep can retrieve it by using @code{getLog()}:
5020 @example
5021 class MyBuildStep(ShellCommand):
5022     logfiles = @{ "nodelog": "_test/node.log" @}
5024     def evaluateCommand(self, cmd):
5025         nodelog = self.getLog("nodelog")
5026         if "STARTED" in nodelog.getText():
5027             return SUCCESS
5028         else:
5029             return FAILURE
5030 @end example
5032 For a complete list of the methods you can call on a LogFile, please
5033 see the docstrings on the @code{IStatusLog} class in
5034 @file{buildbot/interfaces.py}.
5037 @node Adding LogObservers, BuildStep URLs, Reading Logfiles, Writing New BuildSteps
5038 @subsubsection Adding LogObservers
5040 @cindex LogObserver
5041 @cindex LogLineObserver
5043 Most shell commands emit messages to stdout or stderr as they operate,
5044 especially if you ask them nicely with a @code{--verbose} flag of some
5045 sort. They may also write text to a log file while they run. Your
5046 BuildStep can watch this output as it arrives, to keep track of how
5047 much progress the command has made. You can get a better measure of
5048 progress by counting the number of source files compiled or test cases
5049 run than by merely tracking the number of bytes that have been written
5050 to stdout. This improves the accuracy and the smoothness of the ETA
5051 display.
5053 To accomplish this, you will need to attach a @code{LogObserver} to
5054 one of the log channels, most commonly to the ``stdio'' channel but
5055 perhaps to another one which tracks a log file. This observer is given
5056 all text as it is emitted from the command, and has the opportunity to
5057 parse that output incrementally. Once the observer has decided that
5058 some event has occurred (like a source file being compiled), it can
5059 use the @code{setProgress} method to tell the BuildStep about the
5060 progress that this event represents.
5062 There are a number of pre-built @code{LogObserver} classes that you
5063 can choose from (defined in @code{buildbot.process.buildstep}, and of
5064 course you can subclass them to add further customization. The
5065 @code{LogLineObserver} class handles the grunt work of buffering and
5066 scanning for end-of-line delimiters, allowing your parser to operate
5067 on complete stdout/stderr lines. (Lines longer than a set maximum
5068 length are dropped; the maximum defaults to 16384 bytes, but you can
5069 change it by calling @code{setMaxLineLength()} on your
5070 @code{LogLineObserver} instance.  Use @code{sys.maxint} for effective
5071 infinity.)
5073 For example, let's take a look at the @code{TrialTestCaseCounter},
5074 which is used by the Trial step to count test cases as they are run.
5075 As Trial executes, it emits lines like the following:
5077 @example
5078 buildbot.test.test_config.ConfigTest.testDebugPassword ... [OK]
5079 buildbot.test.test_config.ConfigTest.testEmpty ... [OK]
5080 buildbot.test.test_config.ConfigTest.testIRC ... [FAIL]
5081 buildbot.test.test_config.ConfigTest.testLocks ... [OK]
5082 @end example
5084 When the tests are finished, trial emits a long line of ``======'' and
5085 then some lines which summarize the tests that failed. We want to
5086 avoid parsing these trailing lines, because their format is less
5087 well-defined than the ``[OK]'' lines.
5089 The parser class looks like this:
5091 @example
5092 from buildbot.process.buildstep import LogLineObserver
5094 class TrialTestCaseCounter(LogLineObserver):
5095     _line_re = re.compile(r'^([\w\.]+) \.\.\. \[([^\]]+)\]$')
5096     numTests = 0
5097     finished = False
5099     def outLineReceived(self, line):
5100         if self.finished:
5101             return
5102         if line.startswith("=" * 40):
5103             self.finished = True
5104             return
5106         m = self._line_re.search(line.strip())
5107         if m:
5108             testname, result = m.groups()
5109             self.numTests += 1
5110             self.step.setProgress('tests', self.numTests)
5111 @end example
5113 This parser only pays attention to stdout, since that's where trial
5114 writes the progress lines. It has a mode flag named @code{finished} to
5115 ignore everything after the ``===='' marker, and a scary-looking
5116 regular expression to match each line while hopefully ignoring other
5117 messages that might get displayed as the test runs.
5119 Each time it identifies a test has been completed, it increments its
5120 counter and delivers the new progress value to the step with
5121 @code{self.step.setProgress}. This class is specifically measuring
5122 progress along the ``tests'' metric, in units of test cases (as
5123 opposed to other kinds of progress like the ``output'' metric, which
5124 measures in units of bytes). The Progress-tracking code uses each
5125 progress metric separately to come up with an overall completion
5126 percentage and an ETA value.
5128 To connect this parser into the @code{Trial} BuildStep,
5129 @code{Trial.__init__} ends with the following clause:
5131 @example
5132         # this counter will feed Progress along the 'test cases' metric
5133         counter = TrialTestCaseCounter()
5134         self.addLogObserver('stdio', counter)
5135 @end example
5137 This creates a TrialTestCaseCounter and tells the step that the
5138 counter wants to watch the ``stdio'' log. The observer is
5139 automatically given a reference to the step in its @code{.step}
5140 attribute.
5142 @subheading A Somewhat Whimsical Example
5144 Let's say that we've got some snazzy new unit-test framework called
5145 Framboozle. It's the hottest thing since sliced bread. It slices, it
5146 dices, it runs unit tests like there's no tomorrow. Plus if your unit
5147 tests fail, you can use its name for a Web 2.1 startup company, make
5148 millions of dollars, and hire engineers to fix the bugs for you, while
5149 you spend your afternoons lazily hang-gliding along a scenic pacific
5150 beach, blissfully unconcerned about the state of your
5151 tests.@footnote{framboozle.com is still available. Remember, I get 10%
5152 :).}
5154 To run a Framboozle-enabled test suite, you just run the 'framboozler'
5155 command from the top of your source code tree. The 'framboozler'
5156 command emits a bunch of stuff to stdout, but the most interesting bit
5157 is that it emits the line "FNURRRGH!" every time it finishes running a
5158 test case@footnote{Framboozle gets very excited about running unit
5159 tests.}. You'd like to have a test-case counting LogObserver that
5160 watches for these lines and counts them, because counting them will
5161 help the buildbot more accurately calculate how long the build will
5162 take, and this will let you know exactly how long you can sneak out of
5163 the office for your hang-gliding lessons without anyone noticing that
5164 you're gone.
5166 This will involve writing a new BuildStep (probably named
5167 "Framboozle") which inherits from ShellCommand. The BuildStep class
5168 definition itself will look something like this:
5170 @example
5171 # START
5172 from buildbot.steps.shell import ShellCommand
5173 from buildbot.process.buildstep import LogLineObserver
5175 class FNURRRGHCounter(LogLineObserver):
5176     numTests = 0
5177     def outLineReceived(self, line):
5178         if "FNURRRGH!" in line:
5179             self.numTests += 1
5180             self.step.setProgress('tests', self.numTests)
5182 class Framboozle(ShellCommand):
5183     command = ["framboozler"]
5185     def __init__(self, **kwargs):
5186         ShellCommand.__init__(self, **kwargs)   # always upcall!
5187         counter = FNURRRGHCounter())
5188         self.addLogObserver(counter)
5189 # FINISH
5190 @end example
5192 So that's the code that we want to wind up using. How do we actually
5193 deploy it?
5195 You have a couple of different options.
5197 Option 1: The simplest technique is to simply put this text
5198 (everything from START to FINISH) in your master.cfg file, somewhere
5199 before the BuildFactory definition where you actually use it in a
5200 clause like:
5202 @example
5203 f = BuildFactory()
5204 f.addStep(SVN(svnurl="stuff"))
5205 f.addStep(Framboozle())
5206 @end example
5208 Remember that master.cfg is secretly just a python program with one
5209 job: populating the BuildmasterConfig dictionary. And python programs
5210 are allowed to define as many classes as they like. So you can define
5211 classes and use them in the same file, just as long as the class is
5212 defined before some other code tries to use it.
5214 This is easy, and it keeps the point of definition very close to the
5215 point of use, and whoever replaces you after that unfortunate
5216 hang-gliding accident will appreciate being able to easily figure out
5217 what the heck this stupid "Framboozle" step is doing anyways. The
5218 downside is that every time you reload the config file, the Framboozle
5219 class will get redefined, which means that the buildmaster will think
5220 that you've reconfigured all the Builders that use it, even though
5221 nothing changed. Bleh.
5223 Option 2: Instead, we can put this code in a separate file, and import
5224 it into the master.cfg file just like we would the normal buildsteps
5225 like ShellCommand and SVN.
5227 Create a directory named ~/lib/python, put everything from START to
5228 FINISH in ~/lib/python/framboozle.py, and run your buildmaster using:
5230 @example
5231  PYTHONPATH=~/lib/python buildbot start MASTERDIR
5232 @end example
5234 or use the @file{Makefile.buildbot} to control the way
5235 @command{buildbot start} works. Or add something like this to
5236 something like your ~/.bashrc or ~/.bash_profile or ~/.cshrc:
5238 @example
5239  export PYTHONPATH=~/lib/python
5240 @end example
5242 Once we've done this, our master.cfg can look like:
5244 @example
5245 from framboozle import Framboozle
5246 f = BuildFactory()
5247 f.addStep(SVN(svnurl="stuff"))
5248 f.addStep(Framboozle())
5249 @end example
5253 @example
5254 import framboozle
5255 f = BuildFactory()
5256 f.addStep(SVN(svnurl="stuff"))
5257 f.addStep(framboozle.Framboozle())
5258 @end example
5260 (check out the python docs for details about how "import" and "from A
5261 import B" work).
5263 What we've done here is to tell python that every time it handles an
5264 "import" statement for some named module, it should look in our
5265 ~/lib/python/ for that module before it looks anywhere else. After our
5266 directories, it will try in a bunch of standard directories too
5267 (including the one where buildbot is installed). By setting the
5268 PYTHONPATH environment variable, you can add directories to the front
5269 of this search list.
5271 Python knows that once it "import"s a file, it doesn't need to
5272 re-import it again. This means that reconfiguring the buildmaster
5273 (with "buildbot reconfig", for example) won't make it think the
5274 Framboozle class has changed every time, so the Builders that use it
5275 will not be spuriously restarted. On the other hand, you either have
5276 to start your buildmaster in a slightly weird way, or you have to
5277 modify your environment to set the PYTHONPATH variable.
5280 Option 3: Install this code into a standard python library directory
5282 Find out what your python's standard include path is by asking it:
5284 @example
5285 80:warner@@luther% python
5286 Python 2.4.4c0 (#2, Oct  2 2006, 00:57:46) 
5287 [GCC 4.1.2 20060928 (prerelease) (Debian 4.1.1-15)] on linux2
5288 Type "help", "copyright", "credits" or "license" for more information.
5289 >>> import sys
5290 >>> print sys.path
5291 ['', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/local/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages/Numeric', '/var/lib/python-support/python2.4', '/usr/lib/site-python']
5292 >>> 
5293 @end example
5295 In this case, putting the code into
5296 /usr/local/lib/python2.4/site-packages/framboozle.py would work just
5297 fine. We can use the same master.cfg "import framboozle" statement as
5298 in Option 2. By putting it in a standard include directory (instead of
5299 the decidedly non-standard ~/lib/python), we don't even have to set
5300 PYTHONPATH to anything special. The downside is that you probably have
5301 to be root to write to one of those standard include directories.
5304 Option 4: Submit the code for inclusion in the Buildbot distribution
5306 Contribute the code in an Enhancement Request on SourceForge, via
5307 http://buildbot.sf.net . Lobby, convince, coerce, bribe, badger,
5308 harass, threaten, or otherwise encourage the author to accept the
5309 patch. This lets you do something like:
5311 @example
5312 from buildbot.steps import framboozle
5313 f = BuildFactory()
5314 f.addStep(SVN(svnurl="stuff"))
5315 f.addStep(framboozle.Framboozle())
5316 @end example
5318 And then you don't even have to install framboozle.py anywhere on your
5319 system, since it will ship with Buildbot. You don't have to be root,
5320 you don't have to set PYTHONPATH. But you do have to make a good case
5321 for Framboozle being worth going into the main distribution, you'll
5322 probably have to provide docs and some unit test cases, you'll need to
5323 figure out what kind of beer the author likes, and then you'll have to
5324 wait until the next release. But in some environments, all this is
5325 easier than getting root on your buildmaster box, so the tradeoffs may
5326 actually be worth it.
5330 Putting the code in master.cfg (1) makes it available to that
5331 buildmaster instance. Putting it in a file in a personal library
5332 directory (2) makes it available for any buildmasters you might be
5333 running. Putting it in a file in a system-wide shared library
5334 directory (3) makes it available for any buildmasters that anyone on
5335 that system might be running. Getting it into the buildbot's upstream
5336 repository (4) makes it available for any buildmasters that anyone in
5337 the world might be running. It's all a matter of how widely you want
5338 to deploy that new class.
5342 @node BuildStep URLs,  , Adding LogObservers, Writing New BuildSteps
5343 @subsubsection BuildStep URLs
5345 @cindex links
5346 @cindex BuildStep URLs
5347 @cindex addURL
5349 Each BuildStep has a collection of ``links''. Like its collection of
5350 LogFiles, each link has a name and a target URL. The web status page
5351 creates HREFs for each link in the same box as it does for LogFiles,
5352 except that the target of the link is the external URL instead of an
5353 internal link to a page that shows the contents of the LogFile.
5355 These external links can be used to point at build information hosted
5356 on other servers. For example, the test process might produce an
5357 intricate description of which tests passed and failed, or some sort
5358 of code coverage data in HTML form, or a PNG or GIF image with a graph
5359 of memory usage over time. The external link can provide an easy way
5360 for users to navigate from the buildbot's status page to these
5361 external web sites or file servers. Note that the step itself is
5362 responsible for insuring that there will be a document available at
5363 the given URL (perhaps by using @command{scp} to copy the HTML output
5364 to a @file{~/public_html/} directory on a remote web server). Calling
5365 @code{addURL} does not magically populate a web server.
5367 To set one of these links, the BuildStep should call the @code{addURL}
5368 method with the name of the link and the target URL. Multiple URLs can
5369 be set.
5371 In this example, we assume that the @command{make test} command causes
5372 a collection of HTML files to be created and put somewhere on the
5373 coverage.example.org web server, in a filename that incorporates the
5374 build number.
5376 @example
5377 class TestWithCodeCoverage(BuildStep):
5378     command = ["make", "test",
5379                WithProperties("buildnum=%s" % "buildnumber")]
5381     def createSummary(self, log):
5382         buildnumber = self.getProperty("buildnumber")
5383         url = "http://coverage.example.org/builds/%s.html" % buildnumber
5384         self.addURL("coverage", url)
5385 @end example
5387 You might also want to extract the URL from some special message
5388 output by the build process itself:
5390 @example
5391 class TestWithCodeCoverage(BuildStep):
5392     command = ["make", "test",
5393                WithProperties("buildnum=%s" % "buildnumber")]
5395     def createSummary(self, log):
5396         output = StringIO(log.getText())
5397         for line in output.readlines():
5398             if line.startswith("coverage-url:"):
5399                 url = line[len("coverage-url:"):].strip()
5400                 self.addURL("coverage", url)
5401                 return
5402 @end example
5404 Note that a build process which emits both stdout and stderr might
5405 cause this line to be split or interleaved between other lines. It
5406 might be necessary to restrict the getText() call to only stdout with
5407 something like this:
5409 @example
5410         output = StringIO("".join([c[1]
5411                                    for c in log.getChunks()
5412                                    if c[0] == LOG_CHANNEL_STDOUT]))
5413 @end example
5415 Of course if the build is run under a PTY, then stdout and stderr will
5416 be merged before the buildbot ever sees them, so such interleaving
5417 will be unavoidable.
5420 @node Interlocks, Build Factories, Build Steps, Build Process
5421 @section Interlocks
5423 @cindex locks
5424 @slindex buildbot.locks.MasterLock
5425 @slindex buildbot.locks.SlaveLock
5427 For various reasons, you may want to prevent certain Steps (or perhaps
5428 entire Builds) from running simultaneously. Limited CPU speed or
5429 network bandwidth to the VC server, problems with simultaneous access
5430 to a database server used by unit tests, or multiple Builds which
5431 access shared state may all require some kind of interlock to prevent
5432 corruption, confusion, or resource overload. These resources might
5433 require completely exclusive access, or it might be sufficient to
5434 establish a limit of two or three simultaneous builds.
5436 @code{Locks} are the mechanism used to express these kinds of
5437 constraints on when Builds or Steps can be run. There are two kinds of
5438 @code{Locks}, each with their own scope: @code{MasterLock} instances
5439 are scoped to the buildbot as a whole, while @code{SlaveLock}s are
5440 scoped to a single buildslave. This means that each buildslave has a
5441 separate copy of each @code{SlaveLock}, which could enforce a
5442 one-Build-at-a-time limit for each machine, but still allow as many
5443 simultaneous builds as there are machines.
5445 Each @code{Lock} is created with a unique name. Each lock gets a count
5446 of how many owners it may have: how many processes can claim it at ths
5447 same time. This limit defaults to one, and is controllable through the
5448 @code{maxCount} argument. On @code{SlaveLock}s you can set the owner
5449 count on a per-slave basis by providing a dictionary (that maps from
5450 slavename to maximum owner count) to its @code{maxCountForSlave}
5451 argument. Any buildslaves that aren't mentioned in
5452 @code{maxCountForSlave} get their owner count from @code{maxCount}.
5454 To use a lock, simply include it in the @code{locks=} argument of the
5455 @code{BuildStep} object that should obtain the lock before it runs.
5456 This argument accepts a list of @code{Lock} objects: the Step will
5457 acquire all of them before it runs.
5459 To claim a lock for the whole Build, add a @code{'locks'} key to the
5460 builder specification dictionary with the same list of @code{Lock}
5461 objects. (This is the dictionary that has the @code{'name'},
5462 @code{'slavename'}, @code{'builddir'}, and @code{'factory'} keys). The
5463 @code{Build} object also accepts a @code{locks=} argument, but unless
5464 you are writing your own @code{BuildFactory} subclass then it will be
5465 easier to set the locks in the builder dictionary.
5467 Note that there are no partial-acquire or partial-release semantics:
5468 this prevents deadlocks caused by two Steps each waiting for a lock
5469 held by the other@footnote{Also note that a clever buildmaster admin
5470 could still create the opportunity for deadlock: Build A obtains Lock
5471 1, inside which Step A.two tries to acquire Lock 2 at the Step level.
5472 Meanwhile Build B obtains Lock 2, and has a Step B.two which wants to
5473 acquire Lock 1 at the Step level. Don't Do That.}. This also means
5474 that waiting to acquire a @code{Lock} can take an arbitrarily long
5475 time: if the buildmaster is very busy, a Step or Build which requires
5476 only one @code{Lock} may starve another that is waiting for that
5477 @code{Lock} plus some others.
5480 In the following example, we run the same build on three different
5481 platforms. The unit-test steps of these builds all use a common
5482 database server, and would interfere with each other if allowed to run
5483 simultaneously. The @code{Lock} prevents more than one of these builds
5484 from happening at the same time.
5486 @example
5487 from buildbot import locks
5488 from buildbot.steps import source, shell
5489 from buildbot.process import factory
5491 db_lock = locks.MasterLock("database")
5492 f = factory.BuildFactory()
5493 f.addStep(source.SVN(svnurl="http://example.org/svn/Trunk"))
5494 f.addStep(shell.ShellCommand(command="make all"))
5495 f.addStep(shell.ShellCommand(command="make test", locks=[db_lock]))
5496 b1 = @{'name': 'full1', 'slavename': 'bot-1', builddir='f1', 'factory': f@}
5497 b2 = @{'name': 'full2', 'slavename': 'bot-2', builddir='f2', 'factory': f@}
5498 b3 = @{'name': 'full3', 'slavename': 'bot-3', builddir='f3', 'factory': f@}
5499 c['builders'] = [b1, b2, b3]
5500 @end example
5502 In the next example, we have one buildslave hosting three separate
5503 Builders (each running tests against a different version of Python).
5504 The machine which hosts this buildslave is not particularly fast, so
5505 we want to prevent all three builds from all happening at the same
5506 time. (Assume we've experimentally determined that one build leaves
5507 unused CPU capacity, three builds causes a lot of disk thrashing, but
5508 two builds at a time is Just Right). We use a @code{SlaveLock} because
5509 the builds happening on this one slow slave should not affect builds
5510 running on other slaves, and we use the lock on the build as a whole
5511 because the slave is so slow that even multiple simultaneous SVN
5512 checkouts would be too taxing. We set @code{maxCount=2} to achieve our
5513 goal of two simultaneous builds per slave.
5515 @example
5516 from buildbot import locks
5517 from buildbot.steps import source
5518 from buildbot.process import s, factory
5520 slow_lock = locks.SlaveLock("cpu", maxCount=2)
5521 source = s(source.SVN, svnurl="http://example.org/svn/Trunk")
5522 f22 = factory.Trial(source, trialpython=["python2.2"])
5523 f23 = factory.Trial(source, trialpython=["python2.3"])
5524 f24 = factory.Trial(source, trialpython=["python2.4"])
5525 b1 = @{'name': 'p22', 'slavename': 'bot-1', builddir='p22', 'factory': f22,
5526       'locks': [slow_lock] @}
5527 b2 = @{'name': 'p23', 'slavename': 'bot-1', builddir='p23', 'factory': f23,
5528       'locks': [slow_lock] @}
5529 b3 = @{'name': 'p24', 'slavename': 'bot-1', builddir='p24', 'factory': f24,
5530       'locks': [slow_lock] @}
5531 c['builders'] = [b1, b2, b3]
5532 @end example
5534 In the last example, we use two Locks at the same time. In this case,
5535 we're concerned about both of the previous constraints, but we'll say
5536 that only the tests are computationally intensive, and that they have
5537 been split into those which use the database and those which do not.
5538 In addition, two of the Builds run on a fast machine which does not
5539 need to worry about the cpu lock, but which still must be prevented
5540 from simultaneous database access. We use @code{maxCountForSlave} to
5541 limit the slow machine to one simultanous build, but allow practically
5542 unlimited concurrent builds on the fast machine.
5544 @example
5545 from buildbot import locks
5546 from buildbot.steps import source, shell
5547 from buildbot.process import factory
5549 db_lock = locks.MasterLock("database")
5550 slavecounts = @{"bot-slow": 1, "bot-fast": 100@}
5551 cpu_lock = locks.SlaveLock("cpu", maxCountForSlave=slavecounts)
5552 f = factory.BuildFactory()
5553 f.addStep(source.SVN(svnurl="http://example.org/svn/Trunk"))
5554 f.addStep(shell.ShellCommand(command="make all", locks=[cpu_lock]))
5555 f.addStep(shell.ShellCommand(command="make test", locks=[cpu_lock]))
5556 f.addStep(shell.ShellCommand(command="make db-test", locks=[db_lock, cpu_lock]))
5558 b1 = @{'name': 'full1', 'slavename': 'bot-slow', builddir='full1',
5559       'factory': f@}
5560 b2 = @{'name': 'full2', 'slavename': 'bot-slow', builddir='full2',
5561       'factory': f@}
5562 b3 = @{'name': 'full3', 'slavename': 'bot-fast', builddir='full3',
5563       'factory': f@}
5564 b4 = @{'name': 'full4', 'slavename': 'bot-fast', builddir='full4',
5565       'factory': f@}
5566 c['builders'] = [b1, b2, b3, b4]
5567 @end example
5569 As a final note, remember that a unit test system which breaks when
5570 multiple people run it at the same time is fragile and should be
5571 fixed. Asking your human developers to serialize themselves when
5572 running unit tests will just discourage them from running the unit
5573 tests at all. Find a way to fix this: change the database tests to
5574 create a new (uniquely-named) user or table for each test run, don't
5575 use fixed listening TCP ports for network tests (instead listen on
5576 port 0 to let the kernel choose a port for you and then query the
5577 socket to find out what port was allocated). @code{MasterLock}s can be
5578 used to accomodate broken test systems like this, but are really
5579 intended for other purposes: build processes that store or retrieve
5580 products in shared directories, or which do things that human
5581 developers would not (or which might slow down or break in ways that
5582 require human attention to deal with).
5584 @code{SlaveLocks}s can be used to keep automated performance tests
5585 from interfering with each other, when there are multiple Builders all
5586 using the same buildslave. But they can't prevent other users from
5587 running CPU-intensive jobs on that host while the tests are running.
5589 @node Build Factories,  , Interlocks, Build Process
5590 @section Build Factories
5593 Each Builder is equipped with a ``build factory'', which is
5594 responsible for producing the actual @code{Build} objects that perform
5595 each build. This factory is created in the configuration file, and
5596 attached to a Builder through the @code{factory} element of its
5597 dictionary.
5599 The standard @code{BuildFactory} object creates @code{Build} objects
5600 by default. These Builds will each execute a collection of BuildSteps
5601 in a fixed sequence. Each step can affect the results of the build,
5602 but in general there is little intelligence to tie the different steps
5603 together. You can create subclasses of @code{Build} to implement more
5604 sophisticated build processes, and then use a subclass of
5605 @code{BuildFactory} (or simply set the @code{buildClass} attribute) to
5606 create instances of your new Build subclass.
5609 @menu
5610 * BuildStep Objects::           
5611 * BuildFactory::                
5612 * Process-Specific build factories::  
5613 @end menu
5615 @node BuildStep Objects, BuildFactory, Build Factories, Build Factories
5616 @subsection BuildStep Objects
5618 The steps used by these builds are all subclasses of @code{BuildStep}.
5619 The standard ones provided with Buildbot are documented later,
5620 @xref{Build Steps}. You can also write your own subclasses to use in
5621 builds.
5623 The basic behavior for a @code{BuildStep} is to:
5625 @itemize @bullet
5626 @item
5627 run for a while, then stop
5628 @item
5629 possibly invoke some RemoteCommands on the attached build slave
5630 @item
5631 possibly produce a set of log files
5632 @item
5633 finish with a status described by one of four values defined in
5634 buildbot.status.builder: SUCCESS, WARNINGS, FAILURE, SKIPPED
5635 @item
5636 provide a list of short strings to describe the step
5637 @item
5638 define a color (generally green, orange, or red) with which the
5639 step should be displayed
5640 @end itemize
5643 More sophisticated steps may produce additional information and
5644 provide it to later build steps, or store it in the factory to provide
5645 to later builds.
5648 @menu
5649 * BuildFactory Attributes::     
5650 * Quick builds::                
5651 @end menu
5653 @node BuildFactory, Process-Specific build factories, BuildStep Objects, Build Factories
5654 @subsection BuildFactory
5656 @bfindex buildbot.process.factory.BuildFactory
5657 @bfindex buildbot.process.factory.BasicBuildFactory
5658 @c TODO: what is BasicSVN anyway?
5659 @bfindex buildbot.process.factory.BasicSVN
5661 The default @code{BuildFactory}, provided in the
5662 @code{buildbot.process.factory} module, contains an internal list of
5663 ``BuildStep specifications'': a list of @code{(step_class, kwargs)}
5664 tuples for each. These specification tuples are constructed when the
5665 config file is read, by asking the instances passed to @code{addStep}
5666 for their subclass and arguments.
5668 When asked to create a Build, the @code{BuildFactory} puts a copy of
5669 the list of step specifications into the new Build object. When the
5670 Build is actually started, these step specifications are used to
5671 create the actual set of BuildSteps, which are then executed one at a
5672 time. This serves to give each Build an independent copy of each step.
5673 For example, a build which consists of a CVS checkout followed by a
5674 @code{make build} would be constructed as follows:
5676 @example
5677 from buildbot.steps import source, shell
5678 from buildbot.process import factory
5680 f = factory.BuildFactory()
5681 f.addStep(source.CVS(cvsroot=CVSROOT, cvsmodule="project", mode="update"))
5682 f.addStep(shell.Compile(command=["make", "build"]))
5683 @end example
5685 (To support config files from buildbot-0.7.5 and earlier,
5686 @code{addStep} also accepts the @code{f.addStep(shell.Compile,
5687 command=["make","build"])} form, although its use is discouraged
5688 because then the @code{Compile} step doesn't get to validate or
5689 complain about its arguments until build time. The modern
5690 pass-by-instance approach allows this validation to occur while the
5691 config file is being loaded, where the admin has a better chance of
5692 noticing problems).
5694 It is also possible to pass a list of steps into the
5695 @code{BuildFactory} when it is created. Using @code{addStep} is
5696 usually simpler, but there are cases where is is more convenient to
5697 create the list of steps ahead of time.:
5699 @example
5700 from buildbot.steps import source, shell
5701 from buildbot.process import factory
5703 all_steps = [source.CVS(cvsroot=CVSROOT, cvsmodule="project", mode="update"),
5704              shell.Compile(command=["make", "build"]),
5705             ]
5706 f = factory.BuildFactory(all_steps)
5707 @end example
5710 Each step can affect the build process in the following ways:
5712 @itemize @bullet
5713 @item
5714 If the step's @code{haltOnFailure} attribute is True, then a failure
5715 in the step (i.e. if it completes with a result of FAILURE) will cause
5716 the whole build to be terminated immediately: no further steps will be
5717 executed. This is useful for setup steps upon which the rest of the
5718 build depends: if the CVS checkout or @code{./configure} process
5719 fails, there is no point in trying to compile or test the resulting
5720 tree.
5722 @item
5723 If the @code{flunkOnFailure} or @code{flunkOnWarnings} flag is set,
5724 then a result of FAILURE or WARNINGS will mark the build as a whole as
5725 FAILED. However, the remaining steps will still be executed. This is
5726 appropriate for things like multiple testing steps: a failure in any
5727 one of them will indicate that the build has failed, however it is
5728 still useful to run them all to completion.
5730 @item
5731 Similarly, if the @code{warnOnFailure} or @code{warnOnWarnings} flag
5732 is set, then a result of FAILURE or WARNINGS will mark the build as
5733 having WARNINGS, and the remaining steps will still be executed. This
5734 may be appropriate for certain kinds of optional build or test steps.
5735 For example, a failure experienced while building documentation files
5736 should be made visible with a WARNINGS result but not be serious
5737 enough to warrant marking the whole build with a FAILURE.
5739 @end itemize
5741 In addition, each Step produces its own results, may create logfiles,
5742 etc. However only the flags described above have any effect on the
5743 build as a whole.
5745 The pre-defined BuildSteps like @code{CVS} and @code{Compile} have
5746 reasonably appropriate flags set on them already. For example, without
5747 a source tree there is no point in continuing the build, so the
5748 @code{CVS} class has the @code{haltOnFailure} flag set to True. Look
5749 in @file{buildbot/steps/*.py} to see how the other Steps are
5750 marked.
5752 Each Step is created with an additional @code{workdir} argument that
5753 indicates where its actions should take place. This is specified as a
5754 subdirectory of the slave builder's base directory, with a default
5755 value of @code{build}. This is only implemented as a step argument (as
5756 opposed to simply being a part of the base directory) because the
5757 CVS/SVN steps need to perform their checkouts from the parent
5758 directory.
5760 @menu
5761 * BuildFactory Attributes::     
5762 * Quick builds::                
5763 @end menu
5765 @node BuildFactory Attributes, Quick builds, BuildFactory, BuildFactory
5766 @subsubsection BuildFactory Attributes
5768 Some attributes from the BuildFactory are copied into each Build.
5770 @cindex treeStableTimer
5772 @table @code
5773 @item useProgress
5774 (defaults to True): if True, the buildmaster keeps track of how long
5775 each step takes, so it can provide estimates of how long future builds
5776 will take. If builds are not expected to take a consistent amount of
5777 time (such as incremental builds in which a random set of files are
5778 recompiled or tested each time), this should be set to False to
5779 inhibit progress-tracking.
5781 @end table
5784 @node Quick builds,  , BuildFactory Attributes, BuildFactory
5785 @subsubsection Quick builds
5787 @bfindex buildbot.process.factory.QuickBuildFactory
5789 The difference between a ``full build'' and a ``quick build'' is that
5790 quick builds are generally done incrementally, starting with the tree
5791 where the previous build was performed. That simply means that the
5792 source-checkout step should be given a @code{mode='update'} flag, to
5793 do the source update in-place.
5795 In addition to that, the @code{useProgress} flag should be set to
5796 False. Incremental builds will (or at least the ought to) compile as
5797 few files as necessary, so they will take an unpredictable amount of
5798 time to run. Therefore it would be misleading to claim to predict how
5799 long the build will take.
5802 @node Process-Specific build factories,  , BuildFactory, Build Factories
5803 @subsection Process-Specific build factories
5805 Many projects use one of a few popular build frameworks to simplify
5806 the creation and maintenance of Makefiles or other compilation
5807 structures. Buildbot provides several pre-configured BuildFactory
5808 subclasses which let you build these projects with a minimum of fuss.
5810 @menu
5811 * GNUAutoconf::                 
5812 * CPAN::                        
5813 * Python distutils::            
5814 * Python/Twisted/trial projects::  
5815 @end menu
5817 @node GNUAutoconf, CPAN, Process-Specific build factories, Process-Specific build factories
5818 @subsubsection GNUAutoconf
5820 @bfindex buildbot.process.factory.GNUAutoconf
5822 @uref{http://www.gnu.org/software/autoconf/, GNU Autoconf} is a
5823 software portability tool, intended to make it possible to write
5824 programs in C (and other languages) which will run on a variety of
5825 UNIX-like systems. Most GNU software is built using autoconf. It is
5826 frequently used in combination with GNU automake. These tools both
5827 encourage a build process which usually looks like this:
5829 @example
5830 % CONFIG_ENV=foo ./configure --with-flags
5831 % make all
5832 % make check
5833 # make install
5834 @end example
5836 (except of course the Buildbot always skips the @code{make install}
5837 part).
5839 The Buildbot's @code{buildbot.process.factory.GNUAutoconf} factory is
5840 designed to build projects which use GNU autoconf and/or automake. The
5841 configuration environment variables, the configure flags, and command
5842 lines used for the compile and test are all configurable, in general
5843 the default values will be suitable.
5845 Example:
5847 @example
5848 # use the s() convenience function defined earlier
5849 f = factory.GNUAutoconf(source=s(step.SVN, svnurl=URL, mode="copy"),
5850                         flags=["--disable-nls"])
5851 @end example
5853 Required Arguments:
5855 @table @code
5856 @item source
5857 This argument must be a step specification tuple that provides a
5858 BuildStep to generate the source tree.
5859 @end table
5861 Optional Arguments:
5863 @table @code
5864 @item configure
5865 The command used to configure the tree. Defaults to
5866 @code{./configure}. Accepts either a string or a list of shell argv
5867 elements.
5869 @item configureEnv
5870 The environment used for the initial configuration step. This accepts
5871 a dictionary which will be merged into the buildslave's normal
5872 environment. This is commonly used to provide things like
5873 @code{CFLAGS="-O2 -g"} (to turn off debug symbols during the compile).
5874 Defaults to an empty dictionary.
5876 @item configureFlags
5877 A list of flags to be appended to the argument list of the configure
5878 command. This is commonly used to enable or disable specific features
5879 of the autoconf-controlled package, like @code{["--without-x"]} to
5880 disable windowing support. Defaults to an empty list.
5882 @item compile
5883 this is a shell command or list of argv values which is used to
5884 actually compile the tree. It defaults to @code{make all}. If set to
5885 None, the compile step is skipped.
5887 @item test
5888 this is a shell command or list of argv values which is used to run
5889 the tree's self-tests. It defaults to @code{make check}. If set to
5890 None, the test step is skipped.
5892 @end table
5895 @node CPAN, Python distutils, GNUAutoconf, Process-Specific build factories
5896 @subsubsection CPAN
5898 @bfindex buildbot.process.factory.CPAN
5900 Most Perl modules available from the @uref{http://www.cpan.org/, CPAN}
5901 archive use the @code{MakeMaker} module to provide configuration,
5902 build, and test services. The standard build routine for these modules
5903 looks like:
5905 @example
5906 % perl Makefile.PL
5907 % make
5908 % make test
5909 # make install
5910 @end example
5912 (except again Buildbot skips the install step)
5914 Buildbot provides a @code{CPAN} factory to compile and test these
5915 projects.
5918 Arguments:
5919 @table @code
5920 @item source
5921 (required): A step specification tuple, that that used by GNUAutoconf.
5923 @item perl
5924 A string which specifies the @code{perl} executable to use. Defaults
5925 to just @code{perl}.
5927 @end table
5930 @node Python distutils, Python/Twisted/trial projects, CPAN, Process-Specific build factories
5931 @subsubsection Python distutils
5933 @bfindex buildbot.process.factory.Distutils
5935 Most Python modules use the @code{distutils} package to provide
5936 configuration and build services. The standard build process looks
5937 like:
5939 @example
5940 % python ./setup.py build
5941 % python ./setup.py install
5942 @end example
5944 Unfortunately, although Python provides a standard unit-test framework
5945 named @code{unittest}, to the best of my knowledge @code{distutils}
5946 does not provide a standardized target to run such unit tests. (please
5947 let me know if I'm wrong, and I will update this factory).
5949 The @code{Distutils} factory provides support for running the build
5950 part of this process. It accepts the same @code{source=} parameter as
5951 the other build factories.
5954 Arguments:
5955 @table @code
5956 @item source
5957 (required): A step specification tuple, that that used by GNUAutoconf.
5958   
5959 @item python
5960 A string which specifies the @code{python} executable to use. Defaults
5961 to just @code{python}.
5963 @item test
5964 Provides a shell command which runs unit tests. This accepts either a
5965 string or a list. The default value is None, which disables the test
5966 step (since there is no common default command to run unit tests in
5967 distutils modules).
5969 @end table
5972 @node Python/Twisted/trial projects,  , Python distutils, Process-Specific build factories
5973 @subsubsection Python/Twisted/trial projects
5975 @bfindex buildbot.process.factory.Trial
5976 @c TODO: document these steps better
5977 @bsindex buildbot.steps.python_twisted.HLint
5978 @bsindex buildbot.steps.python_twisted.Trial
5979 @bsindex buildbot.steps.python_twisted.ProcessDocs
5980 @bsindex buildbot.steps.python_twisted.BuildDebs
5981 @bsindex buildbot.steps.python_twisted.RemovePYCs
5983 Twisted provides a unit test tool named @code{trial} which provides a
5984 few improvements over Python's built-in @code{unittest} module. Many
5985 python projects which use Twisted for their networking or application
5986 services also use trial for their unit tests. These modules are
5987 usually built and tested with something like the following:
5989 @example
5990 % python ./setup.py build
5991 % PYTHONPATH=build/lib.linux-i686-2.3 trial -v PROJECTNAME.test
5992 % python ./setup.py install
5993 @end example
5995 Unfortunately, the @file{build/lib} directory into which the
5996 built/copied .py files are placed is actually architecture-dependent,
5997 and I do not yet know of a simple way to calculate its value. For many
5998 projects it is sufficient to import their libraries ``in place'' from
5999 the tree's base directory (@code{PYTHONPATH=.}).
6001 In addition, the @var{PROJECTNAME} value where the test files are
6002 located is project-dependent: it is usually just the project's
6003 top-level library directory, as common practice suggests the unit test
6004 files are put in the @code{test} sub-module. This value cannot be
6005 guessed, the @code{Trial} class must be told where to find the test
6006 files.
6008 The @code{Trial} class provides support for building and testing
6009 projects which use distutils and trial. If the test module name is
6010 specified, trial will be invoked. The library path used for testing
6011 can also be set.
6013 One advantage of trial is that the Buildbot happens to know how to
6014 parse trial output, letting it identify which tests passed and which
6015 ones failed. The Buildbot can then provide fine-grained reports about
6016 how many tests have failed, when individual tests fail when they had
6017 been passing previously, etc.
6019 Another feature of trial is that you can give it a series of source
6020 .py files, and it will search them for special @code{test-case-name}
6021 tags that indicate which test cases provide coverage for that file.
6022 Trial can then run just the appropriate tests. This is useful for
6023 quick builds, where you want to only run the test cases that cover the
6024 changed functionality.
6026 Arguments:
6027 @table @code
6028 @item source
6029 (required): A step specification tuple, like that used by GNUAutoconf.
6031 @item buildpython
6032 A list (argv array) of strings which specifies the @code{python}
6033 executable to use when building the package. Defaults to just
6034 @code{['python']}. It may be useful to add flags here, to supress
6035 warnings during compilation of extension modules. This list is
6036 extended with @code{['./setup.py', 'build']} and then executed in a
6037 ShellCommand.
6039 @item testpath
6040 Provides a directory to add to @code{PYTHONPATH} when running the unit
6041 tests, if tests are being run. Defaults to @code{.} to include the
6042 project files in-place. The generated build library is frequently
6043 architecture-dependent, but may simply be @file{build/lib} for
6044 pure-python modules.
6046 @item trialpython
6047 Another list of strings used to build the command that actually runs
6048 trial. This is prepended to the contents of the @code{trial} argument
6049 below. It may be useful to add @code{-W} flags here to supress
6050 warnings that occur while tests are being run. Defaults to an empty
6051 list, meaning @code{trial} will be run without an explicit
6052 interpreter, which is generally what you want if you're using
6053 @file{/usr/bin/trial} instead of, say, the @file{./bin/trial} that
6054 lives in the Twisted source tree.
6056 @item trial
6057 provides the name of the @code{trial} command. It is occasionally
6058 useful to use an alternate executable, such as @code{trial2.2} which
6059 might run the tests under an older version of Python. Defaults to
6060 @code{trial}.
6062 @item tests
6063 Provides a module name or names which contain the unit tests for this
6064 project. Accepts a string, typically @code{PROJECTNAME.test}, or a
6065 list of strings. Defaults to None, indicating that no tests should be
6066 run. You must either set this or @code{useTestCaseNames} to do anyting
6067 useful with the Trial factory.
6069 @item useTestCaseNames
6070 Tells the Step to provide the names of all changed .py files to trial,
6071 so it can look for test-case-name tags and run just the matching test
6072 cases. Suitable for use in quick builds. Defaults to False.
6074 @item randomly
6075 If @code{True}, tells Trial (with the @code{--random=0} argument) to
6076 run the test cases in random order, which sometimes catches subtle
6077 inter-test dependency bugs. Defaults to @code{False}.
6079 @item recurse
6080 If @code{True}, tells Trial (with the @code{--recurse} argument) to
6081 look in all subdirectories for additional test cases. It isn't clear
6082 to me how this works, but it may be useful to deal with the
6083 unknown-PROJECTNAME problem described above, and is currently used in
6084 the Twisted buildbot to accomodate the fact that test cases are now
6085 distributed through multiple twisted.SUBPROJECT.test directories.
6087 @end table  
6089 Unless one of @code{trialModule} or @code{useTestCaseNames}
6090 are set, no tests will be run.
6092 Some quick examples follow. Most of these examples assume that the
6093 target python code (the ``code under test'') can be reached directly
6094 from the root of the target tree, rather than being in a @file{lib/}
6095 subdirectory.
6097 @example
6098 #  Trial(source, tests="toplevel.test") does:
6099 #   python ./setup.py build
6100 #   PYTHONPATH=. trial -to toplevel.test
6102 #  Trial(source, tests=["toplevel.test", "other.test"]) does:
6103 #   python ./setup.py build
6104 #   PYTHONPATH=. trial -to toplevel.test other.test
6106 #  Trial(source, useTestCaseNames=True) does:
6107 #   python ./setup.py build
6108 #   PYTHONPATH=. trial -to --testmodule=foo/bar.py..  (from Changes)
6110 #  Trial(source, buildpython=["python2.3", "-Wall"], tests="foo.tests"):
6111 #   python2.3 -Wall ./setup.py build
6112 #   PYTHONPATH=. trial -to foo.tests
6114 #  Trial(source, trialpython="python2.3", trial="/usr/bin/trial",
6115 #        tests="foo.tests") does:
6116 #   python2.3 -Wall ./setup.py build
6117 #   PYTHONPATH=. python2.3 /usr/bin/trial -to foo.tests
6119 # For running trial out of the tree being tested (only useful when the
6120 # tree being built is Twisted itself):
6121 #  Trial(source, trialpython=["python2.3", "-Wall"], trial="./bin/trial",
6122 #        tests="foo.tests") does:
6123 #   python2.3 -Wall ./setup.py build
6124 #   PYTHONPATH=. python2.3 -Wall ./bin/trial -to foo.tests
6125 @end example
6127 If the output directory of @code{./setup.py build} is known, you can
6128 pull the python code from the built location instead of the source
6129 directories. This should be able to handle variations in where the
6130 source comes from, as well as accomodating binary extension modules:
6132 @example
6133 # Trial(source,tests="toplevel.test",testpath='build/lib.linux-i686-2.3')
6134 # does:
6135 #  python ./setup.py build
6136 #  PYTHONPATH=build/lib.linux-i686-2.3 trial -to toplevel.test
6137 @end example
6140 @node Status Delivery, Command-line tool, Build Process, Top
6141 @chapter Status Delivery
6143 More details are available in the docstrings for each class, use a
6144 command like @code{pydoc buildbot.status.html.WebStatus} to see them.
6145 Most status delivery objects take a @code{categories=} argument, which
6146 can contain a list of ``category'' names: in this case, it will only
6147 show status for Builders that are in one of the named categories.
6149 (implementor's note: each of these objects should be a
6150 service.MultiService which will be attached to the BuildMaster object
6151 when the configuration is processed. They should use
6152 @code{self.parent.getStatus()} to get access to the top-level IStatus
6153 object, either inside @code{startService} or later. They may call
6154 @code{status.subscribe()} in @code{startService} to receive
6155 notifications of builder events, in which case they must define
6156 @code{builderAdded} and related methods. See the docstrings in
6157 @file{buildbot/interfaces.py} for full details.)
6159 @menu
6160 * WebStatus::                   
6161 * MailNotifier::                
6162 * IRC Bot::                     
6163 * PBListener::                  
6164 * Writing New Status Plugins::  
6165 @end menu
6167 @c @node Email Delivery,  , Status Delivery, Status Delivery
6168 @c @subsection Email Delivery
6170 @c DOCUMENT THIS
6173 @node WebStatus, MailNotifier, Status Delivery, Status Delivery
6174 @section WebStatus
6176 @cindex WebStatus
6177 @stindex buildbot.status.web.baseweb.WebStatus
6179 The @code{buildbot.status.html.WebStatus} status target runs a small
6180 web server inside the buildmaster. You can point a browser at this web
6181 server and retrieve information about every build the buildbot knows
6182 about, as well as find out what the buildbot is currently working on.
6184 The first page you will see is the ``Welcome Page'', which contains
6185 links to all the other useful pages. This page is simply served from
6186 the @file{public_html/index.html} file in the buildmaster's base
6187 directory, where it is created by the @command{buildbot create-master}
6188 command along with the rest of the buildmaster.
6190 The most complex resource provided by @code{WebStatus} is the
6191 ``Waterfall Display'', which shows a time-based chart of events. This
6192 somewhat-busy display provides detailed information about all steps of
6193 all recent builds, and provides hyperlinks to look at individual build
6194 logs and source changes. By simply reloading this page on a regular
6195 basis, you will see a complete description of everything the buildbot
6196 is currently working on.
6198 There are also pages with more specialized information. For example,
6199 there is a page which shows the last 20 builds performed by the
6200 buildbot, one line each. Each line is a link to detailed information
6201 about that build. By adding query arguments to the URL used to reach
6202 this page, you can narrow the display to builds that involved certain
6203 branches, or which ran on certain Builders. These pages are described
6204 in great detail below.
6207 When the buildmaster is created, a subdirectory named
6208 @file{public_html/} is created in its base directory. @code{WebStatus}
6209 will serve files from this directory: for example, when a user points
6210 their browser at the buildbot's @code{WebStatus} URL, they will see
6211 the contents of the @file{public_html/index.html} file. Likewise,
6212 @file{public_html/robots.txt}, @file{public_html/buildbot.css}, and
6213 @file{public_html/favicon.ico} are all useful things to have in there.
6214 The first time a buildmaster is created, the @file{public_html}
6215 directory is populated with some sample files, which you will probably
6216 want to customize for your own project. These files are all static:
6217 the buildbot does not modify them in any way as it serves them to HTTP
6218 clients.
6220 @example
6221 from buildbot.status.html import WebStatus
6222 c['status'].append(WebStatus(8080))
6223 @end example
6225 Note that the initial robots.txt file has Disallow lines for all of
6226 the dynamically-generated buildbot pages, to discourage web spiders
6227 and search engines from consuming a lot of CPU time as they crawl
6228 through the entire history of your buildbot. If you are running the
6229 buildbot behind a reverse proxy, you'll probably need to put the
6230 robots.txt file somewhere else (at the top level of the parent web
6231 server), and replace the URL prefixes in it with more suitable values.
6233 In addition, if you are familiar with twisted.web @emph{Resource
6234 Trees}, you can write code to add additional pages at places inside
6235 this web space. Just use @code{webstatus.putChild} to place these
6236 resources.
6238 The following section describes the special URLs and the status views
6239 they provide.
6242 @menu
6243 * WebStatus Configuration Parameters::  
6244 * Buildbot Web Resources::      
6245 * XMLRPC server::               
6246 * HTML Waterfall::              
6247 @end menu
6249 @node WebStatus Configuration Parameters, Buildbot Web Resources, WebStatus, WebStatus
6250 @subsection WebStatus Configuration Parameters
6252 The most common way to run a @code{WebStatus} is on a regular TCP
6253 port. To do this, just pass in the TCP port number when you create the
6254 @code{WebStatus} instance; this is called the @code{http_port} argument:
6256 @example
6257 from buildbot.status.html import WebStatus
6258 c['status'].append(WebStatus(8080))
6259 @end example
6261 The @code{http_port} argument is actually a ``strports specification''
6262 for the port that the web server should listen on. This can be a
6263 simple port number, or a string like
6264 @code{tcp:8080:interface=127.0.0.1} (to limit connections to the
6265 loopback interface, and therefore to clients running on the same
6266 host)@footnote{It may even be possible to provide SSL access by using
6267 a specification like
6268 @code{"ssl:12345:privateKey=mykey.pen:certKey=cert.pem"}, but this is
6269 completely untested}.
6271 If instead (or in addition) you provide the @code{distrib_port}
6272 argument, a twisted.web distributed server will be started either on a
6273 TCP port (if @code{distrib_port} is like @code{"tcp:12345"}) or more
6274 likely on a UNIX socket (if @code{distrib_port} is like
6275 @code{"unix:/path/to/socket"}).
6277 The @code{distrib_port} option means that, on a host with a
6278 suitably-configured twisted-web server, you do not need to consume a
6279 separate TCP port for the buildmaster's status web page. When the web
6280 server is constructed with @code{mktap web --user}, URLs that point to
6281 @code{http://host/~username/} are dispatched to a sub-server that is
6282 listening on a UNIX socket at @code{~username/.twisted-web-pb}. On
6283 such a system, it is convenient to create a dedicated @code{buildbot}
6284 user, then set @code{distrib_port} to
6285 @code{"unix:"+os.path.expanduser("~/.twistd-web-pb")}. This
6286 configuration will make the HTML status page available at
6287 @code{http://host/~buildbot/} . Suitable URL remapping can make it
6288 appear at @code{http://host/buildbot/}, and the right virtual host
6289 setup can even place it at @code{http://buildbot.host/} .
6291 The other @code{WebStatus} argument is @code{allowForce}. If set to
6292 True, then the web page will provide a ``Force Build'' button that
6293 allows visitors to manually trigger builds. This is useful for
6294 developers to re-run builds that have failed because of intermittent
6295 problems in the test suite, or because of libraries that were not
6296 installed at the time of the previous build. You may not wish to allow
6297 strangers to cause a build to run: in that case, set this to False to
6298 remove these buttons. The default value is False.
6302 @node Buildbot Web Resources, XMLRPC server, WebStatus Configuration Parameters, WebStatus
6303 @subsection Buildbot Web Resources
6305 Certain URLs are ``magic'', and the pages they serve are created by
6306 code in various classes in the @file{buildbot.status.web} package
6307 instead of being read from disk. The most common way to access these
6308 pages is for the buildmaster admin to write or modify the
6309 @file{index.html} page to contain links to them. Of course other
6310 project web pages can contain links to these buildbot pages as well.
6312 Many pages can be modified by adding query arguments to the URL. For
6313 example, a page which shows the results of the most recent build
6314 normally does this for all builders at once. But by appending
6315 ``?builder=i386'' to the end of the URL, the page will show only the
6316 results for the ``i386'' builder. When used in this way, you can add
6317 multiple ``builder='' arguments to see multiple builders. Remembering
6318 that URL query arguments are separated @emph{from each other} with
6319 ampersands, a URL that ends in ``?builder=i386&builder=ppc'' would
6320 show builds for just those two Builders.
6322 The @code{branch=} query argument can be used on some pages. This
6323 filters the information displayed by that page down to only the builds
6324 or changes which involved the given branch. Use @code{branch=trunk} to
6325 reference the trunk: if you aren't intentionally using branches,
6326 you're probably using trunk. Multiple @code{branch=} arguments can be
6327 used to examine multiple branches at once (so appending
6328 @code{?branch=foo&branch=bar} to the URL will show builds involving
6329 either branch). No @code{branch=} arguments means to show builds and
6330 changes for all branches.
6332 Some pages may include the Builder name or the build number in the
6333 main part of the URL itself. For example, a page that describes Build
6334 #7 of the ``i386'' builder would live at @file{/builders/i386/builds/7}.
6336 The table below lists all of the internal pages and the URLs that can
6337 be used to access them.
6339 NOTE: of the pages described here, @code{/slave_status_timeline} and
6340 @code{/last_build} have not yet been implemented, and @code{/xmlrpc}
6341 has only a few methods so far. Future releases will improve this.
6343 @table @code
6345 @item /waterfall
6347 This provides a chronologically-oriented display of the activity of
6348 all builders. It is the same display used by the Waterfall display.
6350 By adding one or more ``builder='' query arguments, the Waterfall is
6351 restricted to only showing information about the given Builders. By
6352 adding one or more ``branch='' query arguments, the display is
6353 restricted to showing information about the given branches. In
6354 addition, adding one or more ``category='' query arguments to the URL
6355 will limit the display to Builders that were defined with one of the
6356 given categories.
6358 A 'show_events=true' query argument causes the display to include
6359 non-Build events, like slaves attaching and detaching, as well as
6360 reconfiguration events. 'show_events=false' hides these events. The
6361 default is to show them.
6363 The @code{last_time=}, @code{first_time=}, and @code{show_time=}
6364 arguments will control what interval of time is displayed. The default
6365 is to show the latest events, but these can be used to look at earlier
6366 periods in history. The @code{num_events=} argument also provides a
6367 limit on the size of the displayed page.
6369 The Waterfall has references to resources many of the other portions
6370 of the URL space: @file{/builders} for access to individual builds,
6371 @file{/changes} for access to information about source code changes,
6372 etc.
6374 @item /builders/$BUILDERNAME
6376 This describes the given Builder, and provides buttons to force a build.
6378 @item /builders/$BUILDERNAME/builds/$BUILDNUM
6380 This describes a specific Build.
6382 @item /builders/$BUILDERNAME/builds/$BUILDNUM/steps/$STEPNAME
6384 This describes a specific BuildStep.
6386 @item /builders/$BUILDERNAME/builds/$BUILDNUM/steps/$STEPNAME/logs/$LOGNAME
6388 This provides an HTML representation of a specific logfile.
6390 @item /builders/$BUILDERNAME/builds/$BUILDNUM/steps/$STEPNAME/logs/$LOGNAME/text
6392 This returns the logfile as plain text, without any HTML coloring
6393 markup. It also removes the ``headers'', which are the lines that
6394 describe what command was run and what the environment variable
6395 settings were like. This maybe be useful for saving to disk and
6396 feeding to tools like 'grep'.
6398 @item /changes
6400 This provides a brief description of the ChangeSource in use
6401 (@pxref{Change Sources}).
6403 @item /changes/NN
6405 This shows detailed information about the numbered Change: who was the
6406 author, what files were changed, what revision number was represented,
6407 etc.
6409 @item /buildslaves
6411 This summarizes each BuildSlave, including which Builders are
6412 configured to use it, whether the buildslave is currently connected or
6413 not, and host information retrieved from the buildslave itself.
6415 @item /one_line_per_build
6417 This page shows one line of text for each build, merging information
6418 from all Builders@footnote{Apparently this is the same way
6419 http://buildd.debian.org displays build status}. Each line specifies
6420 the name of the Builder, the number of the Build, what revision it
6421 used, and a summary of the results. Successful builds are in green,
6422 while failing builds are in red. The date and time of the build are
6423 added to the right-hand edge of the line. The lines are ordered by
6424 build finish timestamp.
6426 One or more @code{builder=} or @code{branch=} arguments can be used to
6427 restrict the list. In addition, a @code{numbuilds=} argument will
6428 control how many lines are displayed (20 by default).
6430 @item /one_box_per_builder
6432 This page shows a small table, with one box for each Builder,
6433 containing the results of the most recent Build. It does not show the
6434 individual steps, or the current status. This is a simple summary of
6435 buildbot status: if this page is green, then all tests are passing.
6437 As with @code{/one_line_per_build}, this page will also honor
6438 @code{builder=} and @code{branch=} arguments.
6440 @item /about
6442 This page gives a brief summary of the Buildbot itself: software
6443 version, versions of some libraries that the Buildbot depends upon,
6444 etc. It also contains a link to the buildbot.net home page.
6446 @item /slave_status_timeline
6448 (note: this page has not yet been implemented)
6450 This provides a chronological display of configuration and operational
6451 events: master startup/shutdown, slave connect/disconnect, and
6452 config-file changes. When a config-file reload is abandoned because of
6453 an error in the config file, the error is displayed on this page.
6455 This page does not show any builds.
6457 @item /last_build/$BUILDERNAME/status.png
6459 This returns a PNG image that describes the results of the most recent
6460 build, which can be referenced in an IMG tag by other pages, perhaps
6461 from a completely different site. Use it as you would a webcounter.
6463 @end table
6465 There are also a set of web-status resources that are intended for use
6466 by other programs, rather than humans.
6468 @table @code
6470 @item /xmlrpc
6472 This runs an XML-RPC server which can be used to query status
6473 information about various builds. See @ref{XMLRPC server} for more
6474 details.
6476 @end table
6478 @node XMLRPC server, HTML Waterfall, Buildbot Web Resources, WebStatus
6479 @subsection XMLRPC server
6481 When using WebStatus, the buildbot runs an XML-RPC server at
6482 @file{/xmlrpc} that can be used by other programs to query build
6483 status. The following table lists the methods that can be invoked
6484 using this interface.
6486 @table @code
6487 @item getAllBuildsInInterval(start, stop)
6489 Return a list of builds that have completed after the 'start'
6490 timestamp and before the 'stop' timestamp. This looks at all Builders.
6492 The timestamps are integers, interpreted as standard unix timestamps
6493 (seconds since epoch).
6495 Each Build is returned as a tuple in the form: @code{(buildername,
6496 buildnumber, build_end, branchname, revision, results, text)}
6498 The buildnumber is an integer. 'build_end' is an integer (seconds
6499 since epoch) specifying when the build finished.
6501 The branchname is a string, which may be an empty string to indicate
6502 None (i.e. the default branch). The revision is a string whose meaning
6503 is specific to the VC system in use, and comes from the 'got_revision'
6504 build property. The results are expressed as a string, one of
6505 ('success', 'warnings', 'failure', 'exception'). The text is a list of
6506 short strings that ought to be joined by spaces and include slightly
6507 more data about the results of the build.
6509 @item getBuild(builder_name, build_number)
6511 Return information about a specific build.
6513 This returns a dictionary (aka ``struct'' in XMLRPC terms) with
6514 complete information about the build. It does not include the contents
6515 of the log files, but it has just about everything else.
6517 @end table
6519 @node HTML Waterfall,  , XMLRPC server, WebStatus
6520 @subsection HTML Waterfall
6522 @cindex Waterfall
6523 @stindex buildbot.status.html.Waterfall
6525 The @code{Waterfall} status target, deprecated as of 0.7.6, is a
6526 subset of the regular @code{WebStatus} resource (@pxref{WebStatus}).
6527 This section (and the @code{Waterfall} class itself) will be removed
6528 from a future release.
6530 @example
6531 from buildbot.status import html
6532 w = html.Waterfall(http_port=8080)
6533 c['status'].append(w)
6534 @end example
6538 @node MailNotifier, IRC Bot, WebStatus, Status Delivery
6539 @section MailNotifier
6541 @cindex email
6542 @cindex mail
6543 @stindex buildbot.status.mail.MailNotifier
6545 The buildbot can also send email when builds finish. The most common
6546 use of this is to tell developers when their change has caused the
6547 build to fail. It is also quite common to send a message to a mailing
6548 list (usually named ``builds'' or similar) about every build.
6550 The @code{MailNotifier} status target is used to accomplish this. You
6551 configure it by specifying who mail should be sent to, under what
6552 circumstances mail should be sent, and how to deliver the mail. It can
6553 be configured to only send out mail for certain builders, and only
6554 send messages when the build fails, or when the builder transitions
6555 from success to failure. It can also be configured to include various
6556 build logs in each message.
6559 By default, the message will be sent to the Interested Users list
6560 (@pxref{Doing Things With Users}), which includes all developers who
6561 made changes in the build. You can add additional recipients with the
6562 extraRecipients argument.
6564 Each MailNotifier sends mail to a single set of recipients. To send
6565 different kinds of mail to different recipients, use multiple
6566 MailNotifiers.
6568 The following simple example will send an email upon the completion of
6569 each build, to just those developers whose Changes were included in
6570 the build. The email contains a description of the Build, its results,
6571 and URLs where more information can be obtained.
6573 @example
6574 from buildbot.status.mail import MailNotifier
6575 mn = MailNotifier(fromaddr="buildbot@@example.org", lookup="example.org")
6576 c['status'].append(mn)
6577 @end example
6579 To get a simple one-message-per-build (say, for a mailing list), use
6580 the following form instead. This form does not send mail to individual
6581 developers (and thus does not need the @code{lookup=} argument,
6582 explained below), instead it only ever sends mail to the ``extra
6583 recipients'' named in the arguments:
6585 @example
6586 mn = MailNotifier(fromaddr="buildbot@@example.org",
6587                   sendToInterestedUsers=False,
6588                   extraRecipients=['listaddr@@example.org'])
6589 @end example
6591 @heading MailNotifier arguments
6593 @table @code
6594 @item fromaddr
6595 The email address to be used in the 'From' header.
6597 @item sendToInterestedUsers
6598 (boolean). If True (the default), send mail to all of the Interested
6599 Users. If False, only send mail to the extraRecipients list.
6601 @item extraRecipients
6602 (tuple of strings). A list of email addresses to which messages should
6603 be sent (in addition to the InterestedUsers list, which includes any
6604 developers who made Changes that went into this build). It is a good
6605 idea to create a small mailing list and deliver to that, then let
6606 subscribers come and go as they please.
6608 @item subject
6609 (string). A string to be used as the subject line of the message.
6610 @code{%(builder)s} will be replaced with the name of the builder which
6611 provoked the message.
6613 @item mode
6614 (string). Default to 'all'. One of:
6615 @table @code
6616 @item all
6617 Send mail about all builds, bothpassing and failing
6618 @item failing
6619 Only send mail about builds which fail
6620 @item problem
6621 Only send mail about a build which failed when the previous build has passed.
6622 If your builds usually pass, then this will only send mail when a problem
6623 occurs.
6624 @end table
6626 @item builders
6627 (list of strings). A list of builder names for which mail should be
6628 sent. Defaults to None (send mail for all builds). Use either builders
6629 or categories, but not both.
6631 @item categories
6632 (list of strings). A list of category names to serve status
6633 information for. Defaults to None (all categories). Use either
6634 builders or categories, but not both.
6636 @item addLogs
6637 (boolean). If True, include all build logs as attachments to the
6638 messages. These can be quite large. This can also be set to a list of
6639 log names, to send a subset of the logs. Defaults to False.
6641 @item relayhost
6642 (string). The host to which the outbound SMTP connection should be
6643 made. Defaults to 'localhost'
6645 @item lookup
6646 (implementor of @code{IEmailLookup}). Object which provides
6647 IEmailLookup, which is responsible for mapping User names (which come
6648 from the VC system) into valid email addresses. If not provided, the
6649 notifier will only be able to send mail to the addresses in the
6650 extraRecipients list. Most of the time you can use a simple Domain
6651 instance. As a shortcut, you can pass as string: this will be treated
6652 as if you had provided Domain(str). For example,
6653 lookup='twistedmatrix.com' will allow mail to be sent to all
6654 developers whose SVN usernames match their twistedmatrix.com account
6655 names. See buildbot/status/mail.py for more details.
6657 @end table
6660 @node IRC Bot, PBListener, MailNotifier, Status Delivery
6661 @section IRC Bot
6663 @cindex IRC
6664 @stindex buildbot.status.words.IRC
6667 The @code{buildbot.status.words.IRC} status target creates an IRC bot
6668 which will attach to certain channels and be available for status
6669 queries. It can also be asked to announce builds as they occur, or be
6670 told to shut up.
6672 @example
6673 from twisted.status import words
6674 irc = words.IRC("irc.example.org", "botnickname", 
6675                 channels=["channel1", "channel2"],
6676                 password="mysecretpassword")
6677 c['status'].append(irc)
6678 @end example
6680 Take a look at the docstring for @code{words.IRC} for more details on
6681 configuring this service. The @code{password} argument, if provided,
6682 will be sent to Nickserv to claim the nickname: some IRC servers will
6683 not allow clients to send private messages until they have logged in
6684 with a password.
6686 To use the service, you address messages at the buildbot, either
6687 normally (@code{botnickname: status}) or with private messages
6688 (@code{/msg botnickname status}). The buildbot will respond in kind.
6690 Some of the commands currently available:
6692 @table @code
6694 @item list builders
6695 Emit a list of all configured builders
6696 @item status BUILDER
6697 Announce the status of a specific Builder: what it is doing right now.
6698 @item status all
6699 Announce the status of all Builders
6700 @item watch BUILDER
6701 If the given Builder is currently running, wait until the Build is
6702 finished and then announce the results.
6703 @item last BUILDER
6704 Return the results of the last build to run on the given Builder.
6706 @item help COMMAND
6707 Describe a command. Use @code{help commands} to get a list of known
6708 commands.
6709 @item source
6710 Announce the URL of the Buildbot's home page.
6711 @item version
6712 Announce the version of this Buildbot.
6713 @end table
6715 If the @code{allowForce=True} option was used, some addtional commands
6716 will be available:
6718 @table @code
6719 @item force build BUILDER REASON
6720 Tell the given Builder to start a build of the latest code. The user
6721 requesting the build and REASON are recorded in the Build status. The
6722 buildbot will announce the build's status when it finishes.
6724 @item stop build BUILDER REASON
6725 Terminate any running build in the given Builder. REASON will be added
6726 to the build status to explain why it was stopped. You might use this
6727 if you committed a bug, corrected it right away, and don't want to
6728 wait for the first build (which is destined to fail) to complete
6729 before starting the second (hopefully fixed) build.
6730 @end table
6732 @node PBListener, Writing New Status Plugins, IRC Bot, Status Delivery
6733 @section PBListener
6735 @cindex PBListener
6736 @stindex buildbot.status.client.PBListener
6739 @example
6740 import buildbot.status.client
6741 pbl = buildbot.status.client.PBListener(port=int, user=str,
6742                                         passwd=str)
6743 c['status'].append(pbl)
6744 @end example
6746 This sets up a PB listener on the given TCP port, to which a PB-based
6747 status client can connect and retrieve status information.
6748 @code{buildbot statusgui} (@pxref{statusgui}) is an example of such a
6749 status client. The @code{port} argument can also be a strports
6750 specification string.
6752 @node Writing New Status Plugins,  , PBListener, Status Delivery
6753 @section Writing New Status Plugins
6755 TODO: this needs a lot more examples
6757 Each status plugin is an object which provides the
6758 @code{twisted.application.service.IService} interface, which creates a
6759 tree of Services with the buildmaster at the top [not strictly true].
6760 The status plugins are all children of an object which implements
6761 @code{buildbot.interfaces.IStatus}, the main status object. From this
6762 object, the plugin can retrieve anything it wants about current and
6763 past builds. It can also subscribe to hear about new and upcoming
6764 builds.
6766 Status plugins which only react to human queries (like the Waterfall
6767 display) never need to subscribe to anything: they are idle until
6768 someone asks a question, then wake up and extract the information they
6769 need to answer it, then they go back to sleep. Plugins which need to
6770 act spontaneously when builds complete (like the MailNotifier plugin)
6771 need to subscribe to hear about new builds.
6773 If the status plugin needs to run network services (like the HTTP
6774 server used by the Waterfall plugin), they can be attached as Service
6775 children of the plugin itself, using the @code{IServiceCollection}
6776 interface.
6780 @node Command-line tool, Resources, Status Delivery, Top
6781 @chapter Command-line tool
6783 The @command{buildbot} command-line tool can be used to start or stop a
6784 buildmaster or buildbot, and to interact with a running buildmaster.
6785 Some of its subcommands are intended for buildmaster admins, while
6786 some are for developers who are editing the code that the buildbot is
6787 monitoring.
6789 @menu
6790 * Administrator Tools::         
6791 * Developer Tools::             
6792 * Other Tools::                 
6793 * .buildbot config directory::  
6794 @end menu
6796 @node Administrator Tools, Developer Tools, Command-line tool, Command-line tool
6797 @section Administrator Tools
6799 The following @command{buildbot} sub-commands are intended for
6800 buildmaster administrators:
6802 @heading create-master
6804 This creates a new directory and populates it with files that allow it
6805 to be used as a buildmaster's base directory.
6807 @example
6808 buildbot create-master BASEDIR
6809 @end example
6811 @heading create-slave
6813 This creates a new directory and populates it with files that let it
6814 be used as a buildslave's base directory. You must provide several
6815 arguments, which are used to create the initial @file{buildbot.tac}
6816 file.
6818 @example
6819 buildbot create-slave @var{BASEDIR} @var{MASTERHOST}:@var{PORT} @var{SLAVENAME} @var{PASSWORD}
6820 @end example
6822 @heading start
6824 This starts a buildmaster or buildslave which was already created in
6825 the given base directory. The daemon is launched in the background,
6826 with events logged to a file named @file{twistd.log}.
6828 @example
6829 buildbot start BASEDIR
6830 @end example
6832 @heading stop
6834 This terminates the daemon (either buildmaster or buildslave) running
6835 in the given directory.
6837 @example
6838 buildbot stop BASEDIR
6839 @end example
6841 @heading sighup
6843 This sends a SIGHUP to the buildmaster running in the given directory,
6844 which causes it to re-read its @file{master.cfg} file.
6846 @example
6847 buildbot sighup BASEDIR
6848 @end example
6850 @node Developer Tools, Other Tools, Administrator Tools, Command-line tool
6851 @section Developer Tools
6853 These tools are provided for use by the developers who are working on
6854 the code that the buildbot is monitoring.
6856 @menu
6857 * statuslog::                   
6858 * statusgui::                   
6859 * try::                         
6860 @end menu
6862 @node statuslog, statusgui, Developer Tools, Developer Tools
6863 @subsection statuslog
6865 @example
6866 buildbot statuslog --master @var{MASTERHOST}:@var{PORT}
6867 @end example
6869 This command starts a simple text-based status client, one which just
6870 prints out a new line each time an event occurs on the buildmaster.
6872 The @option{--master} option provides the location of the
6873 @code{buildbot.status.client.PBListener} status port, used to deliver
6874 build information to realtime status clients. The option is always in
6875 the form of a string, with hostname and port number separated by a
6876 colon (@code{HOSTNAME:PORTNUM}). Note that this port is @emph{not} the
6877 same as the slaveport (although a future version may allow the same
6878 port number to be used for both purposes). If you get an error message
6879 to the effect of ``Failure: twisted.cred.error.UnauthorizedLogin:'',
6880 this may indicate that you are connecting to the slaveport rather than
6881 a @code{PBListener} port.
6883 The @option{--master} option can also be provided by the
6884 @code{masterstatus} name in @file{.buildbot/options} (@pxref{.buildbot
6885 config directory}).
6887 @node statusgui, try, statuslog, Developer Tools
6888 @subsection statusgui
6890 @cindex statusgui
6892 If you have set up a PBListener (@pxref{PBListener}), you will be able
6893 to monitor your Buildbot using a simple Gtk+ application invoked with
6894 the @code{buildbot statusgui} command:
6896 @example
6897 buildbot statusgui --master @var{MASTERHOST}:@var{PORT}
6898 @end example
6900 This command starts a simple Gtk+-based status client, which contains
6901 a few boxes for each Builder that change color as events occur. It
6902 uses the same @option{--master} argument as the @command{buildbot
6903 statuslog} command (@pxref{statuslog}).
6905 @node try,  , statusgui, Developer Tools
6906 @subsection try
6908 This lets a developer to ask the question ``What would happen if I
6909 committed this patch right now?''. It runs the unit test suite (across
6910 multiple build platforms) on the developer's current code, allowing
6911 them to make sure they will not break the tree when they finally
6912 commit their changes.
6914 The @command{buildbot try} command is meant to be run from within a
6915 developer's local tree, and starts by figuring out the base revision
6916 of that tree (what revision was current the last time the tree was
6917 updated), and a patch that can be applied to that revision of the tree
6918 to make it match the developer's copy. This (revision, patch) pair is
6919 then sent to the buildmaster, which runs a build with that
6920 SourceStamp. If you want, the tool will emit status messages as the
6921 builds run, and will not terminate until the first failure has been
6922 detected (or the last success).
6924 There is an alternate form which accepts a pre-made patch file
6925 (typically the output of a command like 'svn diff'). This ``--diff''
6926 form does not require a local tree to run from. See @xref{try --diff}.
6928 For this command to work, several pieces must be in place:
6931 @heading TryScheduler
6933 @slindex buildbot.scheduler.Try_Jobdir
6934 @slindex buildbot.scheduler.Try_Userpass
6936 The buildmaster must have a @code{scheduler.Try} instance in
6937 the config file's @code{c['schedulers']} list. This lets the
6938 administrator control who may initiate these ``trial'' builds, which
6939 branches are eligible for trial builds, and which Builders should be
6940 used for them.
6942 The @code{TryScheduler} has various means to accept build requests:
6943 all of them enforce more security than the usual buildmaster ports do.
6944 Any source code being built can be used to compromise the buildslave
6945 accounts, but in general that code must be checked out from the VC
6946 repository first, so only people with commit privileges can get
6947 control of the buildslaves. The usual force-build control channels can
6948 waste buildslave time but do not allow arbitrary commands to be
6949 executed by people who don't have those commit privileges. However,
6950 the source code patch that is provided with the trial build does not
6951 have to go through the VC system first, so it is important to make
6952 sure these builds cannot be abused by a non-committer to acquire as
6953 much control over the buildslaves as a committer has. Ideally, only
6954 developers who have commit access to the VC repository would be able
6955 to start trial builds, but unfortunately the buildmaster does not, in
6956 general, have access to VC system's user list.
6958 As a result, the @code{TryScheduler} requires a bit more
6959 configuration. There are currently two ways to set this up:
6961 @table @strong
6962 @item jobdir (ssh)
6964 This approach creates a command queue directory, called the
6965 ``jobdir'', in the buildmaster's working directory. The buildmaster
6966 admin sets the ownership and permissions of this directory to only
6967 grant write access to the desired set of developers, all of whom must
6968 have accounts on the machine. The @code{buildbot try} command creates
6969 a special file containing the source stamp information and drops it in
6970 the jobdir, just like a standard maildir. When the buildmaster notices
6971 the new file, it unpacks the information inside and starts the builds.
6973 The config file entries used by 'buildbot try' either specify a local
6974 queuedir (for which write and mv are used) or a remote one (using scp
6975 and ssh).
6977 The advantage of this scheme is that it is quite secure, the
6978 disadvantage is that it requires fiddling outside the buildmaster
6979 config (to set the permissions on the jobdir correctly). If the
6980 buildmaster machine happens to also house the VC repository, then it
6981 can be fairly easy to keep the VC userlist in sync with the
6982 trial-build userlist. If they are on different machines, this will be
6983 much more of a hassle. It may also involve granting developer accounts
6984 on a machine that would not otherwise require them.
6986 To implement this, the buildslave invokes 'ssh -l username host
6987 buildbot tryserver ARGS', passing the patch contents over stdin. The
6988 arguments must include the inlet directory and the revision
6989 information.
6991 @item user+password (PB)
6993 In this approach, each developer gets a username/password pair, which
6994 are all listed in the buildmaster's configuration file. When the
6995 developer runs @code{buildbot try}, their machine connects to the
6996 buildmaster via PB and authenticates themselves using that username
6997 and password, then sends a PB command to start the trial build.
6999 The advantage of this scheme is that the entire configuration is
7000 performed inside the buildmaster's config file. The disadvantages are
7001 that it is less secure (while the ``cred'' authentication system does
7002 not expose the password in plaintext over the wire, it does not offer
7003 most of the other security properties that SSH does). In addition, the
7004 buildmaster admin is responsible for maintaining the username/password
7005 list, adding and deleting entries as developers come and go.
7007 @end table
7010 For example, to set up the ``jobdir'' style of trial build, using a
7011 command queue directory of @file{MASTERDIR/jobdir} (and assuming that
7012 all your project developers were members of the @code{developers} unix
7013 group), you would first create that directory (with @command{mkdir
7014 MASTERDIR/jobdir MASTERDIR/jobdir/new MASTERDIR/jobdir/cur
7015 MASTERDIR/jobdir/tmp; chgrp developers MASTERDIR/jobdir
7016 MASTERDIR/jobdir/*; chmod g+rwx,o-rwx MASTERDIR/jobdir
7017 MASTERDIR/jobdir/*}), and then use the following scheduler in the
7018 buildmaster's config file:
7020 @example
7021 from buildbot.scheduler import Try_Jobdir
7022 s = Try_Jobdir("try1", ["full-linux", "full-netbsd", "full-OSX"],
7023                jobdir="jobdir")
7024 c['schedulers'] = [s]
7025 @end example
7027 Note that you must create the jobdir before telling the buildmaster to
7028 use this configuration, otherwise you will get an error. Also remember
7029 that the buildmaster must be able to read and write to the jobdir as
7030 well. Be sure to watch the @file{twistd.log} file (@pxref{Logfiles})
7031 as you start using the jobdir, to make sure the buildmaster is happy
7032 with it.
7034 To use the username/password form of authentication, create a
7035 @code{Try_Userpass} instance instead. It takes the same
7036 @code{builderNames} argument as the @code{Try_Jobdir} form, but
7037 accepts an addtional @code{port} argument (to specify the TCP port to
7038 listen on) and a @code{userpass} list of username/password pairs to
7039 accept. Remember to use good passwords for this: the security of the
7040 buildslave accounts depends upon it:
7042 @example
7043 from buildbot.scheduler import Try_Userpass
7044 s = Try_Userpass("try2", ["full-linux", "full-netbsd", "full-OSX"],
7045                  port=8031, userpass=[("alice","pw1"), ("bob", "pw2")] )
7046 c['schedulers'] = [s]
7047 @end example
7049 Like most places in the buildbot, the @code{port} argument takes a
7050 strports specification. See @code{twisted.application.strports} for
7051 details.
7054 @heading locating the master
7056 The @command{try} command needs to be told how to connect to the
7057 @code{TryScheduler}, and must know which of the authentication
7058 approaches described above is in use by the buildmaster. You specify
7059 the approach by using @option{--connect=ssh} or @option{--connect=pb}
7060 (or @code{try_connect = 'ssh'} or @code{try_connect = 'pb'} in
7061 @file{.buildbot/options}).
7063 For the PB approach, the command must be given a @option{--master}
7064 argument (in the form HOST:PORT) that points to TCP port that you
7065 picked in the @code{Try_Userpass} scheduler. It also takes a
7066 @option{--username} and @option{--passwd} pair of arguments that match
7067 one of the entries in the buildmaster's @code{userpass} list. These
7068 arguments can also be provided as @code{try_master},
7069 @code{try_username}, and @code{try_password} entries in the
7070 @file{.buildbot/options} file.
7072 For the SSH approach, the command must be given @option{--tryhost},
7073 @option{--username}, and optionally @option{--password} (TODO:
7074 really?) to get to the buildmaster host. It must also be given
7075 @option{--trydir}, which points to the inlet directory configured
7076 above. The trydir can be relative to the user's home directory, but
7077 most of the time you will use an explicit path like
7078 @file{~buildbot/project/trydir}. These arguments can be provided in
7079 @file{.buildbot/options} as @code{try_host}, @code{try_username},
7080 @code{try_password}, and @code{try_dir}.
7082 In addition, the SSH approach needs to connect to a PBListener status
7083 port, so it can retrieve and report the results of the build (the PB
7084 approach uses the existing connection to retrieve status information,
7085 so this step is not necessary). This requires a @option{--master}
7086 argument, or a @code{masterstatus} entry in @file{.buildbot/options},
7087 in the form of a HOSTNAME:PORT string.
7090 @heading choosing the Builders
7092 A trial build is performed on multiple Builders at the same time, and
7093 the developer gets to choose which Builders are used (limited to a set
7094 selected by the buildmaster admin with the TryScheduler's
7095 @code{builderNames=} argument). The set you choose will depend upon
7096 what your goals are: if you are concerned about cross-platform
7097 compatibility, you should use multiple Builders, one from each
7098 platform of interest. You might use just one builder if that platform
7099 has libraries or other facilities that allow better test coverage than
7100 what you can accomplish on your own machine, or faster test runs.
7102 The set of Builders to use can be specified with multiple
7103 @option{--builder} arguments on the command line. It can also be
7104 specified with a single @code{try_builders} option in
7105 @file{.buildbot/options} that uses a list of strings to specify all
7106 the Builder names:
7108 @example
7109 try_builders = ["full-OSX", "full-win32", "full-linux"]
7110 @end example
7112 @heading specifying the VC system
7114 The @command{try} command also needs to know how to take the
7115 developer's current tree and extract the (revision, patch)
7116 source-stamp pair. Each VC system uses a different process, so you
7117 start by telling the @command{try} command which VC system you are
7118 using, with an argument like @option{--vc=cvs} or @option{--vc=tla}.
7119 This can also be provided as @code{try_vc} in
7120 @file{.buildbot/options}.
7122 The following names are recognized: @code{cvs} @code{svn} @code{baz}
7123 @code{tla} @code{hg} @code{darcs}
7126 @heading finding the top of the tree
7128 Some VC systems (notably CVS and SVN) track each directory
7129 more-or-less independently, which means the @command{try} command
7130 needs to move up to the top of the project tree before it will be able
7131 to construct a proper full-tree patch. To accomplish this, the
7132 @command{try} command will crawl up through the parent directories
7133 until it finds a marker file. The default name for this marker file is
7134 @file{.buildbot-top}, so when you are using CVS or SVN you should
7135 @code{touch .buildbot-top} from the top of your tree before running
7136 @command{buildbot try}. Alternatively, you can use a filename like
7137 @file{ChangeLog} or @file{README}, since many projects put one of
7138 these files in their top-most directory (and nowhere else). To set
7139 this filename, use @option{--try-topfile=ChangeLog}, or set it in the
7140 options file with @code{try_topfile = 'ChangeLog'}.
7142 You can also manually set the top of the tree with
7143 @option{--try-topdir=~/trees/mytree}, or @code{try_topdir =
7144 '~/trees/mytree'}. If you use @code{try_topdir}, in a
7145 @file{.buildbot/options} file, you will need a separate options file
7146 for each tree you use, so it may be more convenient to use the
7147 @code{try_topfile} approach instead.
7149 Other VC systems which work on full projects instead of individual
7150 directories (tla, baz, darcs, monotone, mercurial, git) do not require
7151 @command{try} to know the top directory, so the @option{--try-topfile}
7152 and @option{--try-topdir} arguments will be ignored.
7153 @c is this true? I think I currently require topdirs all the time.
7155 If the @command{try} command cannot find the top directory, it will
7156 abort with an error message.
7158 @heading determining the branch name
7160 Some VC systems record the branch information in a way that ``try''
7161 can locate it, in particular Arch (both @command{tla} and
7162 @command{baz}). For the others, if you are using something other than
7163 the default branch, you will have to tell the buildbot which branch
7164 your tree is using. You can do this with either the @option{--branch}
7165 argument, or a @option{try_branch} entry in the
7166 @file{.buildbot/options} file.
7168 @heading determining the revision and patch
7170 Each VC system has a separate approach for determining the tree's base
7171 revision and computing a patch.
7173 @table @code
7175 @item CVS
7177 @command{try} pretends that the tree is up to date. It converts the
7178 current time into a @code{-D} time specification, uses it as the base
7179 revision, and computes the diff between the upstream tree as of that
7180 point in time versus the current contents. This works, more or less,
7181 but requires that the local clock be in reasonably good sync with the
7182 repository.
7184 @item SVN
7185 @command{try} does a @code{svn status -u} to find the latest
7186 repository revision number (emitted on the last line in the ``Status
7187 against revision: NN'' message). It then performs an @code{svn diff
7188 -rNN} to find out how your tree differs from the repository version,
7189 and sends the resulting patch to the buildmaster. If your tree is not
7190 up to date, this will result in the ``try'' tree being created with
7191 the latest revision, then @emph{backwards} patches applied to bring it
7192 ``back'' to the version you actually checked out (plus your actual
7193 code changes), but this will still result in the correct tree being
7194 used for the build.
7196 @item baz
7197 @command{try} does a @code{baz tree-id} to determine the
7198 fully-qualified version and patch identifier for the tree
7199 (ARCHIVE/VERSION--patch-NN), and uses the VERSION--patch-NN component
7200 as the base revision. It then does a @code{baz diff} to obtain the
7201 patch.
7203 @item tla
7204 @command{try} does a @code{tla tree-version} to get the
7205 fully-qualified version identifier (ARCHIVE/VERSION), then takes the
7206 first line of @code{tla logs --reverse} to figure out the base
7207 revision. Then it does @code{tla changes --diffs} to obtain the patch.
7209 @item Darcs
7210 @code{darcs changes --context} emits a text file that contains a list
7211 of all patches back to and including the last tag was made. This text
7212 file (plus the location of a repository that contains all these
7213 patches) is sufficient to re-create the tree. Therefore the contents
7214 of this ``context'' file @emph{are} the revision stamp for a
7215 Darcs-controlled source tree.
7217 So @command{try} does a @code{darcs changes --context} to determine
7218 what your tree's base revision is, and then does a @code{darcs diff
7219 -u} to compute the patch relative to that revision.
7221 @item Mercurial
7222 @code{hg identify} emits a short revision ID (basically a truncated
7223 SHA1 hash of the current revision's contents), which is used as the
7224 base revision. @code{hg diff} then provides the patch relative to that
7225 revision. For @command{try} to work, your working directory must only
7226 have patches that are available from the same remotely-available
7227 repository that the build process' @code{step.Mercurial} will use.
7229 @item Git
7230 @code{git branch -v} lists all the branches available in the local
7231 repository along with the revision ID it points to and a short summary
7232 of the last commit. The line containing the currently checked out
7233 branch begins with '* ' (star and space) while all the others start
7234 with '  ' (two spaces). @command{try} scans for this line and extracts
7235 the branch name and revision from it. Then it generates a diff against
7236 the base revision.
7237 @c TODO: I'm not sure if this actually works the way it's intended
7238 @c since the extracted base revision might not actually exist in the
7239 @c upstream repository. Perhaps we need to add a --remote option to
7240 @c specify the remote tracking branch to generate a diff against.
7242 @c TODO: monotone
7243 @end table
7245 @heading waiting for results
7247 If you provide the @option{--wait} option (or @code{try_wait = True}
7248 in @file{.buildbot/options}), the @command{buildbot try} command will
7249 wait until your changes have either been proven good or bad before
7250 exiting. Unless you use the @option{--quiet} option (or
7251 @code{try_quiet=True}), it will emit a progress message every 60
7252 seconds until the builds have completed.
7254 @menu
7255 * try --diff::                  
7256 @end menu
7258 @node try --diff,  , try, try
7259 @subsubsection try --diff
7261 Sometimes you might have a patch from someone else that you want to
7262 submit to the buildbot. For example, a user may have created a patch
7263 to fix some specific bug and sent it to you by email. You've inspected
7264 the patch and suspect that it might do the job (and have at least
7265 confirmed that it doesn't do anything evil). Now you want to test it
7266 out.
7268 One approach would be to check out a new local tree, apply the patch,
7269 run your local tests, then use ``buildbot try'' to run the tests on
7270 other platforms. An alternate approach is to use the @command{buildbot
7271 try --diff} form to have the buildbot test the patch without using a
7272 local tree.
7274 This form takes a @option{--diff} argument which points to a file that
7275 contains the patch you want to apply. By default this patch will be
7276 applied to the TRUNK revision, but if you give the optional
7277 @option{--baserev} argument, a tree of the given revision will be used
7278 as a starting point instead of TRUNK.
7280 You can also use @command{buildbot try --diff=-} to read the patch
7281 from stdin.
7283 Each patch has a ``patchlevel'' associated with it. This indicates the
7284 number of slashes (and preceding pathnames) that should be stripped
7285 before applying the diff. This exactly corresponds to the @option{-p}
7286 or @option{--strip} argument to the @command{patch} utility. By
7287 default @command{buildbot try --diff} uses a patchlevel of 0, but you
7288 can override this with the @option{-p} argument.
7290 When you use @option{--diff}, you do not need to use any of the other
7291 options that relate to a local tree, specifically @option{--vc},
7292 @option{--try-topfile}, or @option{--try-topdir}. These options will
7293 be ignored. Of course you must still specify how to get to the
7294 buildmaster (with @option{--connect}, @option{--tryhost}, etc).
7297 @node Other Tools, .buildbot config directory, Developer Tools, Command-line tool
7298 @section Other Tools
7300 These tools are generally used by buildmaster administrators.
7302 @menu
7303 * sendchange::                  
7304 * debugclient::                 
7305 @end menu
7307 @node sendchange, debugclient, Other Tools, Other Tools
7308 @subsection sendchange
7310 This command is used to tell the buildmaster about source changes. It
7311 is intended to be used from within a commit script, installed on the
7312 VC server. It requires that you have a PBChangeSource
7313 (@pxref{PBChangeSource}) running in the buildmaster (by being set in
7314 @code{c['change_source']}).
7317 @example
7318 buildbot sendchange --master @var{MASTERHOST}:@var{PORT} --username @var{USER} @var{FILENAMES..}
7319 @end example
7321 There are other (optional) arguments which can influence the
7322 @code{Change} that gets submitted:
7324 @table @code
7325 @item --branch
7326 This provides the (string) branch specifier. If omitted, it defaults
7327 to None, indicating the ``default branch''. All files included in this
7328 Change must be on the same branch.
7330 @item --revision_number
7331 This provides a (numeric) revision number for the change, used for VC systems
7332 that use numeric transaction numbers (like Subversion).
7334 @item --revision
7335 This provides a (string) revision specifier, for VC systems that use
7336 strings (Arch would use something like patch-42 etc).
7338 @item --revision_file
7339 This provides a filename which will be opened and the contents used as
7340 the revision specifier. This is specifically for Darcs, which uses the
7341 output of @command{darcs changes --context} as a revision specifier.
7342 This context file can be a couple of kilobytes long, spanning a couple
7343 lines per patch, and would be a hassle to pass as a command-line
7344 argument.
7346 @item --comments
7347 This provides the change comments as a single argument. You may want
7348 to use @option{--logfile} instead.
7350 @item --logfile
7351 This instructs the tool to read the change comments from the given
7352 file. If you use @code{-} as the filename, the tool will read the
7353 change comments from stdin.
7354 @end table
7357 @node debugclient,  , sendchange, Other Tools
7358 @subsection debugclient
7360 @example
7361 buildbot debugclient --master @var{MASTERHOST}:@var{PORT} --passwd @var{DEBUGPW}
7362 @end example
7364 This launches a small Gtk+/Glade-based debug tool, connecting to the
7365 buildmaster's ``debug port''. This debug port shares the same port
7366 number as the slaveport (@pxref{Setting the slaveport}), but the
7367 @code{debugPort} is only enabled if you set a debug password in the
7368 buildmaster's config file (@pxref{Debug options}). The
7369 @option{--passwd} option must match the @code{c['debugPassword']}
7370 value.
7372 @option{--master} can also be provided in @file{.debug/options} by the
7373 @code{master} key. @option{--passwd} can be provided by the
7374 @code{debugPassword} key.
7376 The @code{Connect} button must be pressed before any of the other
7377 buttons will be active. This establishes the connection to the
7378 buildmaster. The other sections of the tool are as follows:
7380 @table @code
7381 @item Reload .cfg
7382 Forces the buildmaster to reload its @file{master.cfg} file. This is
7383 equivalent to sending a SIGHUP to the buildmaster, but can be done
7384 remotely through the debug port. Note that it is a good idea to be
7385 watching the buildmaster's @file{twistd.log} as you reload the config
7386 file, as any errors which are detected in the config file will be
7387 announced there.
7389 @item Rebuild .py
7390 (not yet implemented). The idea here is to use Twisted's ``rebuild''
7391 facilities to replace the buildmaster's running code with a new
7392 version. Even if this worked, it would only be used by buildbot
7393 developers.
7395 @item poke IRC
7396 This locates a @code{words.IRC} status target and causes it to emit a
7397 message on all the channels to which it is currently connected. This
7398 was used to debug a problem in which the buildmaster lost the
7399 connection to the IRC server and did not attempt to reconnect.
7401 @item Commit
7402 This allows you to inject a Change, just as if a real one had been
7403 delivered by whatever VC hook you are using. You can set the name of
7404 the committed file and the name of the user who is doing the commit.
7405 Optionally, you can also set a revision for the change. If the
7406 revision you provide looks like a number, it will be sent as an
7407 integer, otherwise it will be sent as a string.
7409 @item Force Build
7410 This lets you force a Builder (selected by name) to start a build of
7411 the current source tree.
7413 @item Currently
7414 (obsolete). This was used to manually set the status of the given
7415 Builder, but the status-assignment code was changed in an incompatible
7416 way and these buttons are no longer meaningful.
7418 @end table
7421 @node .buildbot config directory,  , Other Tools, Command-line tool
7422 @section .buildbot config directory
7424 Many of the @command{buildbot} tools must be told how to contact the
7425 buildmaster that they interact with. This specification can be
7426 provided as a command-line argument, but most of the time it will be
7427 easier to set them in an ``options'' file. The @command{buildbot}
7428 command will look for a special directory named @file{.buildbot},
7429 starting from the current directory (where the command was run) and
7430 crawling upwards, eventually looking in the user's home directory. It
7431 will look for a file named @file{options} in this directory, and will
7432 evaluate it as a python script, looking for certain names to be set.
7433 You can just put simple @code{name = 'value'} pairs in this file to
7434 set the options.
7436 For a description of the names used in this file, please see the
7437 documentation for the individual @command{buildbot} sub-commands. The
7438 following is a brief sample of what this file's contents could be.
7440 @example
7441 # for status-reading tools
7442 masterstatus = 'buildbot.example.org:12345'
7443 # for 'sendchange' or the debug port
7444 master = 'buildbot.example.org:18990'
7445 debugPassword = 'eiv7Po'
7446 @end example
7448 @table @code
7449 @item masterstatus
7450 Location of the @code{client.PBListener} status port, used by
7451 @command{statuslog} and @command{statusgui}.
7453 @item master
7454 Location of the @code{debugPort} (for @command{debugclient}). Also the
7455 location of the @code{pb.PBChangeSource} (for @command{sendchange}).
7456 Usually shares the slaveport, but a future version may make it
7457 possible to have these listen on a separate port number.
7459 @item debugPassword
7460 Must match the value of @code{c['debugPassword']}, used to protect the
7461 debug port, for the @command{debugclient} command.
7463 @item username
7464 Provides a default username for the @command{sendchange} command.
7466 @end table
7469 The following options are used by the @code{buildbot try} command
7470 (@pxref{try}):
7472 @table @code
7473 @item try_connect
7474 This specifies how the ``try'' command should deliver its request to
7475 the buildmaster. The currently accepted values are ``ssh'' and ``pb''.
7476 @item try_builders
7477 Which builders should be used for the ``try'' build.
7478 @item try_vc
7479 This specifies the version control system being used.
7480 @item try_branch
7481 This indicates that the current tree is on a non-trunk branch.
7482 @item try_topdir
7483 @item try_topfile
7484 Use @code{try_topdir} to explicitly indicate the top of your working
7485 tree, or @code{try_topfile} to name a file that will only be found in
7486 that top-most directory.
7488 @item try_host
7489 @item try_username
7490 @item try_dir
7491 When try_connect is ``ssh'', the command will pay attention to
7492 @code{try_host}, @code{try_username}, and @code{try_dir}.
7494 @item try_username
7495 @item try_password
7496 @item try_master
7497 Instead, when @code{try_connect} is ``pb'', the command will pay
7498 attention to @code{try_username}, @code{try_password}, and
7499 @code{try_master}.
7501 @item try_wait
7502 @item masterstatus
7503 @code{try_wait} and @code{masterstatus} are used to ask the ``try''
7504 command to wait for the requested build to complete.
7506 @end table
7510 @node Resources, Developer's Appendix, Command-line tool, Top
7511 @chapter Resources
7513 The Buildbot's home page is at @uref{http://buildbot.sourceforge.net/}
7515 For configuration questions and general discussion, please use the
7516 @code{buildbot-devel} mailing list. The subscription instructions and
7517 archives are available at
7518 @uref{http://lists.sourceforge.net/lists/listinfo/buildbot-devel}
7520 @node Developer's Appendix, Index of Useful Classes, Resources, Top
7521 @unnumbered Developer's Appendix
7523 This appendix contains random notes about the implementation of the
7524 Buildbot, and is likely to only be of use to people intending to
7525 extend the Buildbot's internals.
7527 The buildmaster consists of a tree of Service objects, which is shaped
7528 as follows:
7530 @example
7531 BuildMaster
7532  ChangeMaster  (in .change_svc)
7533   [IChangeSource instances]
7534  [IScheduler instances]  (in .schedulers)
7535  BotMaster  (in .botmaster)
7536   [IBuildSlave instances]
7537  [IStatusTarget instances]  (in .statusTargets)
7538 @end example
7540 The BotMaster has a collection of Builder objects as values of its
7541 @code{.builders} dictionary.
7544 @node Index of Useful Classes, Index of master.cfg keys, Developer's Appendix, Top
7545 @unnumbered Index of Useful Classes
7547 This is a list of all user-visible classes. There are the ones that
7548 are useful in @file{master.cfg}, the buildmaster's configuration file.
7549 Classes that are not listed here are generally internal things that
7550 admins are unlikely to have much use for.
7553 @heading Change Sources
7554 @printindex cs
7556 @heading Schedulers and Locks
7557 @printindex sl
7559 @heading Build Factories
7560 @printindex bf
7562 @heading Build Steps
7563 @printindex bs
7565 @c undocumented steps
7566 @bsindex buildbot.steps.source.Git
7567 @bsindex buildbot.steps.maxq.MaxQ
7570 @heading Status Targets
7571 @printindex st
7573 @c TODO: undocumented targets
7575 @node Index of master.cfg keys, Index, Index of Useful Classes, Top
7576 @unnumbered Index of master.cfg keys
7578 This is a list of all of the significant keys in master.cfg . Recall
7579 that master.cfg is effectively a small python program with exactly one
7580 responsibility: create a dictionary named @code{BuildmasterConfig}.
7581 The keys of this dictionary are listed here. The beginning of the
7582 master.cfg file typically starts with something like:
7584 @example
7585 BuildmasterConfig = c = @{@}
7586 @end example
7588 Therefore a config key of @code{change_source} will usually appear in
7589 master.cfg as @code{c['change_source']}.
7591 @printindex bc
7594 @node Index,  , Index of master.cfg keys, Top
7595 @unnumbered Index
7597 @printindex cp
7600 @bye