hush some pyflakes warnings
[buildbot.git] / docs / buildbot.texinfo
blob620a2e0257b70dfba8be70491061d6cc8a22b631
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename buildbot.info
4 @settitle BuildBot Manual 0.7.5+
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 * Creating a buildslave::       
87 * Launching the daemons::       
88 * Logfiles::                    
89 * Shutdown::                    
90 * Maintenance::                 
91 * Troubleshooting::             
93 Creating a buildslave
95 * Buildslave Options::          
97 Troubleshooting
99 * Starting the buildslave::     
100 * Connecting to the buildmaster::  
101 * Forcing Builds::              
103 Concepts
105 * Version Control Systems::     
106 * Schedulers::                  
107 * BuildSet::                    
108 * BuildRequest::                
109 * Builder::                     
110 * Users::                       
112 Version Control Systems
114 * Generalizing VC Systems::     
115 * Source Tree Specifications::  
116 * How Different VC Systems Specify Sources::  
117 * Attributes of Changes::       
119 Users
121 * Doing Things With Users::     
122 * Email Addresses::             
123 * IRC Nicknames::               
124 * Live Status Clients::         
126 Configuration
128 * Config File Format::          
129 * Loading the Config File::     
130 * Defining the Project::        
131 * Listing Change Sources and Schedulers::  
132 * Setting the slaveport::       
133 * Buildslave Specifiers::       
134 * Defining Builders::           
135 * Defining Status Targets::     
136 * Debug options::               
138 Listing Change Sources and Schedulers
140 * Scheduler Types::             
141 * Build Dependencies::          
143 Getting Source Code Changes
145 * Change Sources::              
147 Change Sources
149 * Choosing ChangeSources::      
150 * CVSToys - PBService::         
151 * CVSToys - mail notification::  
152 * Other mail notification ChangeSources::  
153 * PBChangeSource::              
154 * P4Source::                    
155 * BonsaiPoller::                
156 * SVNPoller::                   
158 Build Process
160 * Build Steps::                 
161 * Interlocks::                  
162 * Build Factories::             
164 Build Steps
166 * Common Parameters::           
167 * Source Checkout::             
168 * ShellCommand::                
169 * Simple ShellCommand Subclasses::  
170 * Python BuildSteps::           
171 * Transferring Files::          
172 * Writing New BuildSteps::      
174 Source Checkout
176 * CVS::                         
177 * SVN::                         
178 * Darcs::                       
179 * Mercurial::                   
180 * Arch::                        
181 * Bazaar::                      
182 * Bzr::                         
183 * P4::                          
185 Simple ShellCommand Subclasses
187 * Configure::                   
188 * Compile::                     
189 * Test::                        
190 * Build Properties::            
192 Python BuildSteps
194 * BuildEPYDoc::                 
195 * PyFlakes::                    
197 Writing New BuildSteps
199 * BuildStep LogFiles::          
200 * Adding LogObservers::         
201 * BuildStep URLs::              
203 Build Factories
205 * BuildStep Objects::           
206 * BuildFactory::                
207 * Process-Specific build factories::  
209 BuildStep Objects
211 * BuildFactory Attributes::     
212 * Quick builds::                
214 BuildFactory
216 * BuildFactory Attributes::     
217 * Quick builds::                
219 Process-Specific build factories
221 * GNUAutoconf::                 
222 * CPAN::                        
223 * Python distutils::            
224 * Python/Twisted/trial projects::  
226 Status Delivery
228 * HTML Waterfall::              
229 * IRC Bot::                     
230 * PBListener::                  
231 * Writing New Status Plugins::  
233 Command-line tool
235 * Administrator Tools::         
236 * Developer Tools::             
237 * Other Tools::                 
238 * .buildbot config directory::  
240 Developer Tools
242 * statuslog::                   
243 * statusgui::                   
244 * try::                         
246 Other Tools
248 * sendchange::                  
249 * debugclient::                 
251 @end detailmenu
252 @end menu
254 @node Introduction, Installation, Top, Top
255 @chapter Introduction
257 @cindex introduction
259 The BuildBot is a system to automate the compile/test cycle required by most
260 software projects to validate code changes. By automatically rebuilding and
261 testing the tree each time something has changed, build problems are
262 pinpointed quickly, before other developers are inconvenienced by the
263 failure. The guilty developer can be identified and harassed without human
264 intervention. By running the builds on a variety of platforms, developers
265 who do not have the facilities to test their changes everywhere before
266 checkin will at least know shortly afterwards whether they have broken the
267 build or not. Warning counts, lint checks, image size, compile time, and
268 other build parameters can be tracked over time, are more visible, and
269 are therefore easier to improve.
271 The overall goal is to reduce tree breakage and provide a platform to
272 run tests or code-quality checks that are too annoying or pedantic for
273 any human to waste their time with. Developers get immediate (and
274 potentially public) feedback about their changes, encouraging them to
275 be more careful about testing before checkin.
277 Features:
279 @itemize @bullet
280 @item
281 run builds on a variety of slave platforms
282 @item
283 arbitrary build process: handles projects using C, Python, whatever
284 @item
285 minimal host requirements: python and Twisted
286 @item
287 slaves can be behind a firewall if they can still do checkout
288 @item
289 status delivery through web page, email, IRC, other protocols
290 @item
291 track builds in progress, provide estimated completion time
292 @item
293 flexible configuration by subclassing generic build process classes
294 @item
295 debug tools to force a new build, submit fake Changes, query slave status
296 @item
297 released under the GPL
298 @end itemize
300 @menu
301 * History and Philosophy::      
302 * System Architecture::         
303 * Control Flow::                
304 @end menu
307 @node History and Philosophy, System Architecture, Introduction, Introduction
308 @section History and Philosophy
310 @cindex Philosophy of operation
312 The Buildbot was inspired by a similar project built for a development
313 team writing a cross-platform embedded system. The various components
314 of the project were supposed to compile and run on several flavors of
315 unix (linux, solaris, BSD), but individual developers had their own
316 preferences and tended to stick to a single platform. From time to
317 time, incompatibilities would sneak in (some unix platforms want to
318 use @code{string.h}, some prefer @code{strings.h}), and then the tree
319 would compile for some developers but not others. The buildbot was
320 written to automate the human process of walking into the office,
321 updating a tree, compiling (and discovering the breakage), finding the
322 developer at fault, and complaining to them about the problem they had
323 introduced. With multiple platforms it was difficult for developers to
324 do the right thing (compile their potential change on all platforms);
325 the buildbot offered a way to help.
327 Another problem was when programmers would change the behavior of a
328 library without warning its users, or change internal aspects that
329 other code was (unfortunately) depending upon. Adding unit tests to
330 the codebase helps here: if an application's unit tests pass despite
331 changes in the libraries it uses, you can have more confidence that
332 the library changes haven't broken anything. Many developers
333 complained that the unit tests were inconvenient or took too long to
334 run: having the buildbot run them reduces the developer's workload to
335 a minimum.
337 In general, having more visibility into the project is always good,
338 and automation makes it easier for developers to do the right thing.
339 When everyone can see the status of the project, developers are
340 encouraged to keep the tree in good working order. Unit tests that
341 aren't run on a regular basis tend to suffer from bitrot just like
342 code does: exercising them on a regular basis helps to keep them
343 functioning and useful.
345 The current version of the Buildbot is additionally targeted at
346 distributed free-software projects, where resources and platforms are
347 only available when provided by interested volunteers. The buildslaves
348 are designed to require an absolute minimum of configuration, reducing
349 the effort a potential volunteer needs to expend to be able to
350 contribute a new test environment to the project. The goal is for
351 anyone who wishes that a given project would run on their favorite
352 platform should be able to offer that project a buildslave, running on
353 that platform, where they can verify that their portability code
354 works, and keeps working.
356 @node System Architecture, Control Flow, History and Philosophy, Introduction
357 @comment  node-name,  next,  previous,  up
358 @section System Architecture
360 The Buildbot consists of a single @code{buildmaster} and one or more
361 @code{buildslaves}, connected in a star topology. The buildmaster
362 makes all decisions about what, when, and how to build. It sends
363 commands to be run on the build slaves, which simply execute the
364 commands and return the results. (certain steps involve more local
365 decision making, where the overhead of sending a lot of commands back
366 and forth would be inappropriate, but in general the buildmaster is
367 responsible for everything).
369 The buildmaster is usually fed @code{Changes} by some sort of version
370 control system (@pxref{Change Sources}), which may cause builds to be
371 run. As the builds are performed, various status messages are
372 produced, which are then sent to any registered Status Targets
373 (@pxref{Status Delivery}).
375 @c @image{FILENAME, WIDTH, HEIGHT, ALTTEXT, EXTENSION}
376 @image{images/overview,,,Overview Diagram,}
378 The buildmaster is configured and maintained by the ``buildmaster
379 admin'', who is generally the project team member responsible for
380 build process issues. Each buildslave is maintained by a ``buildslave
381 admin'', who do not need to be quite as involved. Generally slaves are
382 run by anyone who has an interest in seeing the project work well on
383 their favorite platform.
385 @menu
386 * BuildSlave Connections::      
387 * Buildmaster Architecture::    
388 * Status Delivery Architecture::  
389 @end menu
391 @node BuildSlave Connections, Buildmaster Architecture, System Architecture, System Architecture
392 @subsection BuildSlave Connections
394 The buildslaves are typically run on a variety of separate machines,
395 at least one per platform of interest. These machines connect to the
396 buildmaster over a TCP connection to a publically-visible port. As a
397 result, the buildslaves can live behind a NAT box or similar
398 firewalls, as long as they can get to buildmaster. The TCP connections
399 are initiated by the buildslave and accepted by the buildmaster, but
400 commands and results travel both ways within this connection. The
401 buildmaster is always in charge, so all commands travel exclusively
402 from the buildmaster to the buildslave.
404 To perform builds, the buildslaves must typically obtain source code
405 from a CVS/SVN/etc repository. Therefore they must also be able to
406 reach the repository. The buildmaster provides instructions for
407 performing builds, but does not provide the source code itself.
409 @image{images/slaves,,,BuildSlave Connections,}
411 @node Buildmaster Architecture, Status Delivery Architecture, BuildSlave Connections, System Architecture
412 @subsection Buildmaster Architecture
414 The Buildmaster consists of several pieces:
416 @image{images/master,,,BuildMaster Architecture,}
418 @itemize @bullet
420 @item
421 Change Sources, which create a Change object each time something is
422 modified in the VC repository. Most ChangeSources listen for messages
423 from a hook script of some sort. Some sources actively poll the
424 repository on a regular basis. All Changes are fed to the Schedulers.
426 @item
427 Schedulers, which decide when builds should be performed. They collect
428 Changes into BuildRequests, which are then queued for delivery to
429 Builders until a buildslave is available.
431 @item
432 Builders, which control exactly @emph{how} each build is performed
433 (with a series of BuildSteps, configured in a BuildFactory). Each
434 Build is run on a single buildslave.
436 @item
437 Status plugins, which deliver information about the build results
438 through protocols like HTTP, mail, and IRC.
440 @end itemize
442 @image{images/slavebuilder,,,SlaveBuilders,}
444 Each Builder is configured with a list of BuildSlaves that it will use
445 for its builds. These buildslaves are expected to behave identically:
446 the only reason to use multiple BuildSlaves for a single Builder is to
447 provide a measure of load-balancing.
449 Within a single BuildSlave, each Builder creates its own SlaveBuilder
450 instance. These SlaveBuilders operate independently from each other.
451 Each gets its own base directory to work in. It is quite common to
452 have many Builders sharing the same buildslave. For example, there
453 might be two buildslaves: one for i386, and a second for PowerPC.
454 There may then be a pair of Builders that do a full compile/test run,
455 one for each architecture, and a lone Builder that creates snapshot
456 source tarballs if the full builders complete successfully. The full
457 builders would each run on a single buildslave, whereas the tarball
458 creation step might run on either buildslave (since the platform
459 doesn't matter when creating source tarballs). In this case, the
460 mapping would look like:
462 @example
463 Builder(full-i386)  ->  BuildSlaves(slave-i386)
464 Builder(full-ppc)   ->  BuildSlaves(slave-ppc)
465 Builder(source-tarball) -> BuildSlaves(slave-i386, slave-ppc)
466 @end example
468 and each BuildSlave would have two SlaveBuilders inside it, one for a
469 full builder, and a second for the source-tarball builder.
471 Once a SlaveBuilder is available, the Builder pulls one or more
472 BuildRequests off its incoming queue. (It may pull more than one if it
473 determines that it can merge the requests together; for example, there
474 may be multiple requests to build the current HEAD revision). These
475 requests are merged into a single Build instance, which includes the
476 SourceStamp that describes what exact version of the source code
477 should be used for the build. The Build is then assigned to a
478 SlaveBuilder and the build begins.
481 @node Status Delivery Architecture,  , Buildmaster Architecture, System Architecture
482 @subsection Status Delivery Architecture
484 The buildmaster maintains a central Status object, to which various
485 status plugins are connected. Through this Status object, a full
486 hierarchy of build status objects can be obtained.
488 @image{images/status,,,Status Delivery,}
490 The configuration file controls which status plugins are active. Each
491 status plugin gets a reference to the top-level Status object. From
492 there they can request information on each Builder, Build, Step, and
493 LogFile. This query-on-demand interface is used by the html.Waterfall
494 plugin to create the main status page each time a web browser hits the
495 main URL.
497 The status plugins can also subscribe to hear about new Builds as they
498 occur: this is used by the MailNotifier to create new email messages
499 for each recently-completed Build.
501 The Status object records the status of old builds on disk in the
502 buildmaster's base directory. This allows it to return information
503 about historical builds.
505 There are also status objects that correspond to Schedulers and
506 BuildSlaves. These allow status plugins to report information about
507 upcoming builds, and the online/offline status of each buildslave.
510 @node Control Flow,  , System Architecture, Introduction
511 @comment  node-name,  next,  previous,  up
512 @section Control Flow
514 A day in the life of the buildbot:
516 @itemize @bullet
518 @item
519 A developer commits some source code changes to the repository. A hook
520 script or commit trigger of some sort sends information about this
521 change to the buildmaster through one of its configured Change
522 Sources. This notification might arrive via email, or over a network
523 connection (either initiated by the buildmaster as it ``subscribes''
524 to changes, or by the commit trigger as it pushes Changes towards the
525 buildmaster). The Change contains information about who made the
526 change, what files were modified, which revision contains the change,
527 and any checkin comments.
529 @item
530 The buildmaster distributes this change to all of its configured
531 Schedulers. Any ``important'' changes cause the ``tree-stable-timer''
532 to be started, and the Change is added to a list of those that will go
533 into a new Build. When the timer expires, a Build is started on each
534 of a set of configured Builders, all compiling/testing the same source
535 code. Unless configured otherwise, all Builds run in parallel on the
536 various buildslaves.
538 @item
539 The Build consists of a series of Steps. Each Step causes some number
540 of commands to be invoked on the remote buildslave associated with
541 that Builder. The first step is almost always to perform a checkout of
542 the appropriate revision from the same VC system that produced the
543 Change. The rest generally perform a compile and run unit tests. As
544 each Step runs, the buildslave reports back command output and return
545 status to the buildmaster.
547 @item
548 As the Build runs, status messages like ``Build Started'', ``Step
549 Started'', ``Build Finished'', etc, are published to a collection of
550 Status Targets. One of these targets is usually the HTML ``Waterfall''
551 display, which shows a chronological list of events, and summarizes
552 the results of the most recent build at the top of each column.
553 Developers can periodically check this page to see how their changes
554 have fared. If they see red, they know that they've made a mistake and
555 need to fix it. If they see green, they know that they've done their
556 duty and don't need to worry about their change breaking anything.
558 @item
559 If a MailNotifier status target is active, the completion of a build
560 will cause email to be sent to any developers whose Changes were
561 incorporated into this Build. The MailNotifier can be configured to
562 only send mail upon failing builds, or for builds which have just
563 transitioned from passing to failing. Other status targets can provide
564 similar real-time notification via different communication channels,
565 like IRC.
567 @end itemize
570 @node Installation, Concepts, Introduction, Top
571 @chapter Installation
573 @menu
574 * Requirements::                
575 * Installing the code::         
576 * Creating a buildmaster::      
577 * Creating a buildslave::       
578 * Launching the daemons::       
579 * Logfiles::                    
580 * Shutdown::                    
581 * Maintenance::                 
582 * Troubleshooting::             
583 @end menu
585 @node Requirements, Installing the code, Installation, Installation
586 @section Requirements
588 At a bare minimum, you'll need the following (for both the buildmaster
589 and a buildslave):
591 @itemize @bullet
592 @item
593 Python: http://www.python.org
595 Buildbot requires python-2.2 or later, and is primarily developed
596 against python-2.3. The buildmaster uses generators, a feature which
597 is not available in python-2.1, and both master and slave require a
598 version of Twisted which only works with python-2.2 or later. Certain
599 features (like the inclusion of build logs in status emails) require
600 python-2.2.2 or later. The IRC ``force build'' command requires
601 python-2.3 (for the shlex.split function).
603 @item
604 Twisted: http://twistedmatrix.com
606 Both the buildmaster and the buildslaves require Twisted-1.3.0 or
607 later. It has been mainly developed against Twisted-2.0.1, but has
608 been tested against Twisted-2.1.0 (the most recent as of this
609 writing), and might even work on versions as old as Twisted-1.1.0, but
610 as always the most recent version is recommended.
612 Twisted-1.3.0 and earlier were released as a single monolithic
613 package. When you run Buildbot against Twisted-2.0.0 or later (which
614 are split into a number of smaller subpackages), you'll need at least
615 "Twisted" (the core package), and you'll also want TwistedMail,
616 TwistedWeb, and TwistedWords (for sending email, serving a web status
617 page, and delivering build status via IRC, respectively).
618 @end itemize
620 Certain other packages may be useful on the system running the
621 buildmaster:
623 @itemize @bullet
624 @item
625 CVSToys: http://purl.net/net/CVSToys
627 If your buildmaster uses FreshCVSSource to receive change notification
628 from a cvstoys daemon, it will require CVSToys be installed (tested
629 with CVSToys-1.0.10). If the it doesn't use that source (i.e. if you
630 only use a mail-parsing change source, or the SVN notification
631 script), you will not need CVSToys.
633 @end itemize
635 And of course, your project's build process will impose additional
636 requirements on the buildslaves. These hosts must have all the tools
637 necessary to compile and test your project's source code.
640 @node Installing the code, Creating a buildmaster, Requirements, Installation
641 @section Installing the code
643 @cindex installation
645 The Buildbot is installed using the standard python @code{distutils}
646 module. After unpacking the tarball, the process is:
648 @example
649 python setup.py build
650 python setup.py install
651 @end example
653 where the install step may need to be done as root. This will put the
654 bulk of the code in somewhere like
655 /usr/lib/python2.3/site-packages/buildbot . It will also install the
656 @code{buildbot} command-line tool in /usr/bin/buildbot.
658 To test this, shift to a different directory (like /tmp), and run:
660 @example
661 buildbot --version
662 @end example
664 If it shows you the versions of Buildbot and Twisted, the install went
665 ok. If it says @code{no such command} or it gets an @code{ImportError}
666 when it tries to load the libaries, then something went wrong.
667 @code{pydoc buildbot} is another useful diagnostic tool.
669 Windows users will find these files in other places. You will need to
670 make sure that python can find the libraries, and will probably find
671 it convenient to have @code{buildbot} on your PATH.
673 If you wish, you can run the buildbot unit test suite like this:
675 @example
676 PYTHONPATH=. trial buildbot.test
677 @end example
679 This should run up to 192 tests, depending upon what VC tools you have
680 installed. On my desktop machine it takes about five minutes to
681 complete. Nothing should fail, a few might be skipped. If any of the
682 tests fail, you should stop and investigate the cause before
683 continuing the installation process, as it will probably be easier to
684 track down the bug early.
686 If you cannot or do not wish to install the buildbot into a site-wide
687 location like @file{/usr} or @file{/usr/local}, you can also install
688 it into the account's home directory. Do the install command like
689 this:
691 @example
692 python setup.py install --home=~
693 @end example
695 That will populate @file{~/lib/python} and create
696 @file{~/bin/buildbot}. Make sure this lib directory is on your
697 @code{PYTHONPATH}.
700 @node Creating a buildmaster, Creating a buildslave, Installing the code, Installation
701 @section Creating a buildmaster
703 As you learned earlier (@pxref{System Architecture}), the buildmaster
704 runs on a central host (usually one that is publically visible, so
705 everybody can check on the status of the project), and controls all
706 aspects of the buildbot system. Let us call this host
707 @code{buildbot.example.org}.
709 You may wish to create a separate user account for the buildmaster,
710 perhaps named @code{buildmaster}. This can help keep your personal
711 configuration distinct from that of the buildmaster and is useful if
712 you have to use a mail-based notification system (@pxref{Change
713 Sources}). However, the Buildbot will work just fine with your regular
714 user account.
716 You need to choose a directory for the buildmaster, called the
717 @code{basedir}. This directory will be owned by the buildmaster, which
718 will use configuration files therein, and create status files as it
719 runs. @file{~/Buildbot} is a likely value. If you run multiple
720 buildmasters in the same account, or if you run both masters and
721 slaves, you may want a more distinctive name like
722 @file{~/Buildbot/master/gnomovision} or
723 @file{~/Buildmasters/fooproject}. If you are using a separate user
724 account, this might just be @file{~buildmaster/masters/fooproject}.
726 Once you've picked a directory, use the @command{buildbot
727 create-master} command to create the directory and populate it with
728 startup files:
730 @example
731 buildbot create-master @var{basedir}
732 @end example
734 You will need to create a configuration file (@pxref{Configuration})
735 before starting the buildmaster. Most of the rest of this manual is
736 dedicated to explaining how to do this. A sample configuration file is
737 placed in the working directory, named @file{master.cfg.sample}, which
738 can be copied to @file{master.cfg} and edited to suit your purposes.
740 (Internal details: This command creates a file named
741 @file{buildbot.tac} that contains all the state necessary to create
742 the buildmaster. Twisted has a tool called @code{twistd} which can use
743 this .tac file to create and launch a buildmaster instance. twistd
744 takes care of logging and daemonization (running the program in the
745 background). @file{/usr/bin/buildbot} is a front end which runs twistd
746 for you.)
748 In addition to @file{buildbot.tac}, a small @file{Makefile.sample} is
749 installed. This can be used as the basis for customized daemon startup,
750 @xref{Launching the daemons}.
753 @node Creating a buildslave, Launching the daemons, Creating a buildmaster, Installation
754 @section Creating a buildslave
756 Typically, you will be adding a buildslave to an existing buildmaster,
757 to provide additional architecture coverage. The buildbot
758 administrator will give you several pieces of information necessary to
759 connect to the buildmaster. You should also be somewhat familiar with
760 the project being tested, so you can troubleshoot build problems
761 locally.
763 The buildbot exists to make sure that the project's stated ``how to
764 build it'' process actually works. To this end, the buildslave should
765 run in an environment just like that of your regular developers.
766 Typically the project build process is documented somewhere
767 (@file{README}, @file{INSTALL}, etc), in a document that should
768 mention all library dependencies and contain a basic set of build
769 instructions. This document will be useful as you configure the host
770 and account in which the buildslave runs.
772 Here's a good checklist for setting up a buildslave:
774 @enumerate
775 @item
776 Set up the account
778 It is recommended (although not mandatory) to set up a separate user
779 account for the buildslave. This account is frequently named
780 @code{buildbot} or @code{buildslave}. This serves to isolate your
781 personal working environment from that of the slave's, and helps to
782 minimize the security threat posed by letting possibly-unknown
783 contributors run arbitrary code on your system. The account should
784 have a minimum of fancy init scripts.
786 @item
787 Install the buildbot code
789 Follow the instructions given earlier (@pxref{Installing the code}).
790 If you use a separate buildslave account, and you didn't install the
791 buildbot code to a shared location, then you will need to install it
792 with @code{--home=~} for each account that needs it.
794 @item
795 Set up the host
797 Make sure the host can actually reach the buildmaster. Usually the
798 buildmaster is running a status webserver on the same machine, so
799 simply point your web browser at it and see if you can get there.
800 Install whatever additional packages or libraries the project's
801 INSTALL document advises. (or not: if your buildslave is supposed to
802 make sure that building without optional libraries still works, then
803 don't install those libraries).
805 Again, these libraries don't necessarily have to be installed to a
806 site-wide shared location, but they must be available to your build
807 process. Accomplishing this is usually very specific to the build
808 process, so installing them to @file{/usr} or @file{/usr/local} is
809 usually the best approach.
811 @item
812 Test the build process
814 Follow the instructions in the INSTALL document, in the buildslave's
815 account. Perform a full CVS (or whatever) checkout, configure, make,
816 run tests, etc. Confirm that the build works without manual fussing.
817 If it doesn't work when you do it by hand, it will be unlikely to work
818 when the buildbot attempts to do it in an automated fashion.
820 @item
821 Choose a base directory
823 This should be somewhere in the buildslave's account, typically named
824 after the project which is being tested. The buildslave will not touch
825 any file outside of this directory. Something like @file{~/Buildbot}
826 or @file{~/Buildslaves/fooproject} is appropriate.
828 @item
829 Get the buildmaster host/port, botname, and password
831 When the buildbot admin configures the buildmaster to accept and use
832 your buildslave, they will provide you with the following pieces of
833 information:
835 @itemize @bullet
836 @item
837 your buildslave's name
838 @item
839 the password assigned to your buildslave
840 @item
841 the hostname and port number of the buildmaster, i.e. buildbot.example.org:8007
842 @end itemize
844 @item
845 Create the buildslave
847 Now run the 'buildbot' command as follows:
849 @example
850 buildbot create-slave @var{BASEDIR} @var{MASTERHOST}:@var{PORT} @var{SLAVENAME} @var{PASSWORD}
851 @end example
853 This will create the base directory and a collection of files inside,
854 including the @file{buildbot.tac} file that contains all the
855 information you passed to the @code{buildbot} command.
857 @item
858 Fill in the hostinfo files
860 When it first connects, the buildslave will send a few files up to the
861 buildmaster which describe the host that it is running on. These files
862 are presented on the web status display so that developers have more
863 information to reproduce any test failures that are witnessed by the
864 buildbot. There are sample files in the @file{info} subdirectory of
865 the buildbot's base directory. You should edit these to correctly
866 describe you and your host.
868 @file{BASEDIR/info/admin} should contain your name and email address.
869 This is the ``buildslave admin address'', and will be visible from the
870 build status page (so you may wish to munge it a bit if
871 address-harvesting spambots are a concern).
873 @file{BASEDIR/info/host} should be filled with a brief description of
874 the host: OS, version, memory size, CPU speed, versions of relevant
875 libraries installed, and finally the version of the buildbot code
876 which is running the buildslave.
878 If you run many buildslaves, you may want to create a single
879 @file{~buildslave/info} file and share it among all the buildslaves
880 with symlinks.
882 @end enumerate
884 @menu
885 * Buildslave Options::          
886 @end menu
888 @node Buildslave Options,  , Creating a buildslave, Creating a buildslave
889 @subsection Buildslave Options
891 There are a handful of options you might want to use when creating the
892 buildslave with the @command{buildbot create-slave <options> DIR <params>}
893 command. You can type @command{buildbot create-slave --help} for a summary.
894 To use these, just include them on the @command{buildbot create-slave}
895 command line, like this:
897 @example
898 buildbot create-slave --umask=022 ~/buildslave buildmaster.example.org:42012 myslavename mypasswd
899 @end example
901 @table @code
902 @item --usepty
903 This is a boolean flag that tells the buildslave whether to launch
904 child processes in a PTY (the default) or with regular pipes. The
905 advantage of using a PTY is that ``grandchild'' processes are more
906 likely to be cleaned up if the build is interrupted or times out
907 (since it enables the use of a ``process group'' in which all child
908 processes will be placed). The disadvantages: some forms of Unix have
909 problems with PTYs, some of your unit tests may behave differently
910 when run under a PTY (generally those which check to see if they are
911 being run interactively), and PTYs will merge the stdout and stderr
912 streams into a single output stream (which means the red-vs-black
913 coloring in the logfiles will be lost). If you encounter problems, you
914 can add @code{--usepty=0} to disable the use of PTYs. Note that
915 windows buildslaves never use PTYs.
917 @item --umask
918 This is a string (generally an octal representation of an integer)
919 which will cause the buildslave process' ``umask'' value to be set
920 shortly after initialization. The ``twistd'' daemonization utility
921 forces the umask to 077 at startup (which means that all files created
922 by the buildslave or its child processes will be unreadable by any
923 user other than the buildslave account). If you want build products to
924 be readable by other accounts, you can add @code{--umask=022} to tell
925 the buildslave to fix the umask after twistd clobbers it. If you want
926 build products to be @emph{writable} by other accounts too, use
927 @code{--umask=000}, but this is likely to be a security problem.
929 @item --keepalive
930 This is a number that indicates how frequently ``keepalive'' messages
931 should be sent from the buildslave to the buildmaster, expressed in
932 seconds. The default (600) causes a message to be sent to the
933 buildmaster at least once every 10 minutes. To set this to a lower
934 value, use e.g. @code{--keepalive=120}.
936 If the buildslave is behind a NAT box or stateful firewall, these
937 messages may help to keep the connection alive: some NAT boxes tend to
938 forget about a connection if it has not been used in a while. When
939 this happens, the buildmaster will think that the buildslave has
940 disappeared, and builds will time out. Meanwhile the buildslave will
941 not realize than anything is wrong.
943 @end table
946 @node Launching the daemons, Logfiles, Creating a buildslave, Installation
947 @section Launching the daemons
949 Both the buildmaster and the buildslave run as daemon programs. To
950 launch them, pass the working directory to the @code{buildbot}
951 command:
953 @example
954 buildbot start @var{BASEDIR}
955 @end example
957 This command will start the daemon and then return, so normally it
958 will not produce any output. To verify that the programs are indeed
959 running, look for a pair of files named @file{twistd.log} and
960 @file{twistd.pid} that should be created in the working directory.
961 @file{twistd.pid} contains the process ID of the newly-spawned daemon.
963 When the buildslave connects to the buildmaster, new directories will
964 start appearing in its base directory. The buildmaster tells the slave
965 to create a directory for each Builder which will be using that slave.
966 All build operations are performed within these directories: CVS
967 checkouts, compiles, and tests.
969 Once you get everything running, you will want to arrange for the
970 buildbot daemons to be started at boot time. One way is to use
971 @code{cron}, by putting them in a @@reboot crontab entry@footnote{this
972 @@reboot syntax is understood by Vixie cron, which is the flavor
973 usually provided with linux systems. Other unices may have a cron that
974 doesn't understand @@reboot}:
976 @example
977 @@reboot buildbot start @var{BASEDIR}
978 @end example
980 When you run @command{crontab} to set this up, remember to do it as
981 the buildmaster or buildslave account! If you add this to your crontab
982 when running as your regular account (or worse yet, root), then the
983 daemon will run as the wrong user, quite possibly as one with more
984 authority than you intended to provide.
986 It is important to remember that the environment provided to cron jobs
987 and init scripts can be quite different that your normal runtime.
988 There may be fewer environment variables specified, and the PATH may
989 be shorter than usual. It is a good idea to test out this method of
990 launching the buildslave by using a cron job with a time in the near
991 future, with the same command, and then check @file{twistd.log} to
992 make sure the slave actually started correctly. Common problems here
993 are for @file{/usr/local} or @file{~/bin} to not be on your
994 @code{PATH}, or for @code{PYTHONPATH} to not be set correctly.
995 Sometimes @code{HOME} is messed up too.
997 To modify the way the daemons are started (perhaps you want to set
998 some environment variables first, or perform some cleanup each time),
999 you can create a file named @file{Makefile.buildbot} in the base
1000 directory. When the @file{buildbot} front-end tool is told to
1001 @command{start} the daemon, and it sees this file (and
1002 @file{/usr/bin/make} exists), it will do @command{make -f
1003 Makefile.buildbot start} instead of its usual action (which involves
1004 running @command{twistd}). When the buildmaster or buildslave is
1005 installed, a @file{Makefile.sample} is created which implements the
1006 same behavior as the the @file{buildbot} tool uses, so if you want to
1007 customize the process, just copy @file{Makefile.sample} to
1008 @file{Makefile.buildbot} and edit it as necessary.
1010 @node Logfiles, Shutdown, Launching the daemons, Installation
1011 @section Logfiles
1013 @cindex logfiles
1015 While a buildbot daemon runs, it emits text to a logfile, named
1016 @file{twistd.log}. A command like @code{tail -f twistd.log} is useful
1017 to watch the command output as it runs.
1019 The buildmaster will announce any errors with its configuration file
1020 in the logfile, so it is a good idea to look at the log at startup
1021 time to check for any problems. Most buildmaster activities will cause
1022 lines to be added to the log.
1024 @node Shutdown, Maintenance, Logfiles, Installation
1025 @section Shutdown
1027 To stop a buildmaster or buildslave manually, use:
1029 @example
1030 buildbot stop @var{BASEDIR}
1031 @end example
1033 This simply looks for the @file{twistd.pid} file and kills whatever
1034 process is identified within.
1036 At system shutdown, all processes are sent a @code{SIGKILL}. The
1037 buildmaster and buildslave will respond to this by shutting down
1038 normally.
1040 The buildmaster will respond to a @code{SIGHUP} by re-reading its
1041 config file. The following shortcut is available:
1043 @example
1044 buildbot reconfig @var{BASEDIR}
1045 @end example
1047 When you update the Buildbot code to a new release, you will need to
1048 restart the buildmaster and/or buildslave before it can take advantage
1049 of the new code. You can do a @code{buildbot stop @var{BASEDIR}} and
1050 @code{buildbot start @var{BASEDIR}} in quick succession, or you can
1051 use the @code{restart} shortcut, which does both steps for you:
1053 @example
1054 buildbot restart @var{BASEDIR}
1055 @end example
1058 @node Maintenance, Troubleshooting, Shutdown, Installation
1059 @section Maintenance
1061 It is a good idea to check the buildmaster's status page every once in
1062 a while, to see if your buildslave is still online. Eventually the
1063 buildbot will probably be enhanced to send you email (via the
1064 @file{info/admin} email address) when the slave has been offline for
1065 more than a few hours.
1067 If you find you can no longer provide a buildslave to the project, please
1068 let the project admins know, so they can put out a call for a
1069 replacement.
1071 The Buildbot records status and logs output continually, each time a
1072 build is performed. The status tends to be small, but the build logs
1073 can become quite large. Each build and log are recorded in a separate
1074 file, arranged hierarchically under the buildmaster's base directory.
1075 To prevent these files from growing without bound, you should
1076 periodically delete old build logs. A simple cron job to delete
1077 anything older than, say, two weeks should do the job. The only trick
1078 is to leave the @file{buildbot.tac} and other support files alone, for
1079 which find's @code{-mindepth} argument helps skip everything in the
1080 top directory. You can use something like the following:
1082 @example
1083 @@weekly cd BASEDIR && find . -mindepth 2 -type f -mtime +14 -exec rm @{@} \;
1084 @@weekly cd BASEDIR && find twistd.log* -mtime +14 -exec rm @{@} \;
1085 @end example
1087 @node Troubleshooting,  , Maintenance, Installation
1088 @section Troubleshooting
1090 Here are a few hints on diagnosing common problems.
1092 @menu
1093 * Starting the buildslave::     
1094 * Connecting to the buildmaster::  
1095 * Forcing Builds::              
1096 @end menu
1098 @node Starting the buildslave, Connecting to the buildmaster, Troubleshooting, Troubleshooting
1099 @subsection Starting the buildslave
1101 Cron jobs are typically run with a minimal shell (@file{/bin/sh}, not
1102 @file{/bin/bash}), and tilde expansion is not always performed in such
1103 commands. You may want to use explicit paths, because the @code{PATH}
1104 is usually quite short and doesn't include anything set by your
1105 shell's startup scripts (@file{.profile}, @file{.bashrc}, etc). If
1106 you've installed buildbot (or other python libraries) to an unusual
1107 location, you may need to add a @code{PYTHONPATH} specification (note
1108 that python will do tilde-expansion on @code{PYTHONPATH} elements by
1109 itself). Sometimes it is safer to fully-specify everything:
1111 @example
1112 @@reboot PYTHONPATH=~/lib/python /usr/local/bin/buildbot start /usr/home/buildbot/basedir
1113 @end example
1115 Take the time to get the @@reboot job set up. Otherwise, things will work
1116 fine for a while, but the first power outage or system reboot you have will
1117 stop the buildslave with nothing but the cries of sorrowful developers to
1118 remind you that it has gone away.
1120 @node Connecting to the buildmaster, Forcing Builds, Starting the buildslave, Troubleshooting
1121 @subsection Connecting to the buildmaster
1123 If the buildslave cannot connect to the buildmaster, the reason should
1124 be described in the @file{twistd.log} logfile. Some common problems
1125 are an incorrect master hostname or port number, or a mistyped bot
1126 name or password. If the buildslave loses the connection to the
1127 master, it is supposed to attempt to reconnect with an
1128 exponentially-increasing backoff. Each attempt (and the time of the
1129 next attempt) will be logged. If you get impatient, just manually stop
1130 and re-start the buildslave.
1132 When the buildmaster is restarted, all slaves will be disconnected,
1133 and will attempt to reconnect as usual. The reconnect time will depend
1134 upon how long the buildmaster is offline (i.e. how far up the
1135 exponential backoff curve the slaves have travelled). Again,
1136 @code{buildbot stop @var{BASEDIR}; buildbot start @var{BASEDIR}} will
1137 speed up the process.
1139 @node Forcing Builds,  , Connecting to the buildmaster, Troubleshooting
1140 @subsection Forcing Builds
1142 From the buildmaster's main status web page, you can force a build to
1143 be run on your build slave. Figure out which column is for a builder
1144 that runs on your slave, click on that builder's name, and the page
1145 that comes up will have a ``Force Build'' button. Fill in the form,
1146 hit the button, and a moment later you should see your slave's
1147 @file{twistd.log} filling with commands being run. Using @code{pstree}
1148 or @code{top} should also reveal the cvs/make/gcc/etc processes being
1149 run by the buildslave. Note that the same web page should also show
1150 the @file{admin} and @file{host} information files that you configured
1151 earlier.
1153 @node Concepts, Configuration, Installation, Top
1154 @chapter Concepts
1156 This chapter defines some of the basic concepts that the Buildbot
1157 uses. You'll need to understand how the Buildbot sees the world to
1158 configure it properly.
1160 @menu
1161 * Version Control Systems::     
1162 * Schedulers::                  
1163 * BuildSet::                    
1164 * BuildRequest::                
1165 * Builder::                     
1166 * Users::                       
1167 @end menu
1169 @node Version Control Systems, Schedulers, Concepts, Concepts
1170 @section Version Control Systems
1172 @cindex Version Control
1174 These source trees come from a Version Control System of some kind.
1175 CVS and Subversion are two popular ones, but the Buildbot supports
1176 others. All VC systems have some notion of an upstream
1177 @code{repository} which acts as a server@footnote{except Darcs, but
1178 since the Buildbot never modifies its local source tree we can ignore
1179 the fact that Darcs uses a less centralized model}, from which clients
1180 can obtain source trees according to various parameters. The VC
1181 repository provides source trees of various projects, for different
1182 branches, and from various points in time. The first thing we have to
1183 do is to specify which source tree we want to get.
1185 @menu
1186 * Generalizing VC Systems::     
1187 * Source Tree Specifications::  
1188 * How Different VC Systems Specify Sources::  
1189 * Attributes of Changes::       
1190 @end menu
1192 @node Generalizing VC Systems, Source Tree Specifications, Version Control Systems, Version Control Systems
1193 @subsection Generalizing VC Systems
1195 For the purposes of the Buildbot, we will try to generalize all VC
1196 systems as having repositories that each provide sources for a variety
1197 of projects. Each project is defined as a directory tree with source
1198 files. The individual files may each have revisions, but we ignore
1199 that and treat the project as a whole as having a set of revisions
1200 (CVS is really the only VC system still in widespread use that has
1201 per-file revisions.. everything modern has moved to atomic tree-wide
1202 changesets). Each time someone commits a change to the project, a new
1203 revision becomes available. These revisions can be described by a
1204 tuple with two items: the first is a branch tag, and the second is
1205 some kind of revision stamp or timestamp. Complex projects may have
1206 multiple branch tags, but there is always a default branch. The
1207 timestamp may be an actual timestamp (such as the -D option to CVS),
1208 or it may be a monotonically-increasing transaction number (such as
1209 the change number used by SVN and P4, or the revision number used by
1210 Arch/Baz/Bazaar, or a labeled tag used in CVS)@footnote{many VC
1211 systems provide more complexity than this: in particular the local
1212 views that P4 and ClearCase can assemble out of various source
1213 directories are more complex than we're prepared to take advantage of
1214 here}. The SHA1 revision ID used by Monotone and Mercurial is also a
1215 kind of revision stamp, in that it specifies a unique copy of the
1216 source tree, as does a Darcs ``context'' file.
1218 When we aren't intending to make any changes to the sources we check out
1219 (at least not any that need to be committed back upstream), there are two
1220 basic ways to use a VC system:
1222 @itemize @bullet
1223 @item
1224 Retrieve a specific set of source revisions: some tag or key is used
1225 to index this set, which is fixed and cannot be changed by subsequent
1226 developers committing new changes to the tree. Releases are built from
1227 tagged revisions like this, so that they can be rebuilt again later
1228 (probably with controlled modifications).
1229 @item
1230 Retrieve the latest sources along a specific branch: some tag is used
1231 to indicate which branch is to be used, but within that constraint we want
1232 to get the latest revisions.
1233 @end itemize
1235 Build personnel or CM staff typically use the first approach: the
1236 build that results is (ideally) completely specified by the two
1237 parameters given to the VC system: repository and revision tag. This
1238 gives QA and end-users something concrete to point at when reporting
1239 bugs. Release engineers are also reportedly fond of shipping code that
1240 can be traced back to a concise revision tag of some sort.
1242 Developers are more likely to use the second approach: each morning
1243 the developer does an update to pull in the changes committed by the
1244 team over the last day. These builds are not easy to fully specify: it
1245 depends upon exactly when you did a checkout, and upon what local
1246 changes the developer has in their tree. Developers do not normally
1247 tag each build they produce, because there is usually significant
1248 overhead involved in creating these tags. Recreating the trees used by
1249 one of these builds can be a challenge. Some VC systems may provide
1250 implicit tags (like a revision number), while others may allow the use
1251 of timestamps to mean ``the state of the tree at time X'' as opposed
1252 to a tree-state that has been explicitly marked.
1254 The Buildbot is designed to help developers, so it usually works in
1255 terms of @emph{the latest} sources as opposed to specific tagged
1256 revisions. However, it would really prefer to build from reproducible
1257 source trees, so implicit revisions are used whenever possible.
1259 @node Source Tree Specifications, How Different VC Systems Specify Sources, Generalizing VC Systems, Version Control Systems
1260 @subsection Source Tree Specifications
1262 So for the Buildbot's purposes we treat each VC system as a server
1263 which can take a list of specifications as input and produce a source
1264 tree as output. Some of these specifications are static: they are
1265 attributes of the builder and do not change over time. Others are more
1266 variable: each build will have a different value. The repository is
1267 changed over time by a sequence of Changes, each of which represents a
1268 single developer making changes to some set of files. These Changes
1269 are cumulative@footnote{Monotone's @emph{multiple heads} feature
1270 violates this assumption of cumulative Changes, but in most situations
1271 the changes don't occur frequently enough for this to be a significant
1272 problem}.
1274 For normal builds, the Buildbot wants to get well-defined source trees
1275 that contain specific Changes, and exclude other Changes that may have
1276 occurred after the desired ones. We assume that the Changes arrive at
1277 the buildbot (through one of the mechanisms described in @pxref{Change
1278 Sources}) in the same order in which they are committed to the
1279 repository. The Buildbot waits for the tree to become ``stable''
1280 before initiating a build, for two reasons. The first is that
1281 developers frequently make multiple related commits in quick
1282 succession, even when the VC system provides ways to make atomic
1283 transactions involving multiple files at the same time. Running a
1284 build in the middle of these sets of changes would use an inconsistent
1285 set of source files, and is likely to fail (and is certain to be less
1286 useful than a build which uses the full set of changes). The
1287 tree-stable-timer is intended to avoid these useless builds that
1288 include some of the developer's changes but not all. The second reason
1289 is that some VC systems (i.e. CVS) do not provide repository-wide
1290 transaction numbers, so that timestamps are the only way to refer to
1291 a specific repository state. These timestamps may be somewhat
1292 ambiguous, due to processing and notification delays. By waiting until
1293 the tree has been stable for, say, 10 minutes, we can choose a
1294 timestamp from the middle of that period to use for our source
1295 checkout, and then be reasonably sure that any clock-skew errors will
1296 not cause the build to be performed on an inconsistent set of source
1297 files.
1299 The Schedulers always use the tree-stable-timer, with a timeout that
1300 is configured to reflect a reasonable tradeoff between build latency
1301 and change frequency. When the VC system provides coherent
1302 repository-wide revision markers (such as Subversion's revision
1303 numbers, or in fact anything other than CVS's timestamps), the
1304 resulting Build is simply performed against a source tree defined by
1305 that revision marker. When the VC system does not provide this, a
1306 timestamp from the middle of the tree-stable period is used to
1307 generate the source tree@footnote{this @code{checkoutDelay} defaults
1308 to half the tree-stable timer, but it can be overridden with an
1309 argument to the Source Step}.
1311 @node How Different VC Systems Specify Sources, Attributes of Changes, Source Tree Specifications, Version Control Systems
1312 @subsection How Different VC Systems Specify Sources
1314 For CVS, the static specifications are @code{repository} and
1315 @code{module}. In addition to those, each build uses a timestamp (or
1316 omits the timestamp to mean @code{the latest}) and @code{branch tag}
1317 (which defaults to HEAD). These parameters collectively specify a set
1318 of sources from which a build may be performed.
1320 @uref{http://subversion.tigris.org, Subversion} combines the
1321 repository, module, and branch into a single @code{Subversion URL}
1322 parameter. Within that scope, source checkouts can be specified by a
1323 numeric @code{revision number} (a repository-wide
1324 monotonically-increasing marker, such that each transaction that
1325 changes the repository is indexed by a different revision number), or
1326 a revision timestamp. When branches are used, the repository and
1327 module form a static @code{baseURL}, while each build has a
1328 @code{revision number} and a @code{branch} (which defaults to a
1329 statically-specified @code{defaultBranch}). The @code{baseURL} and
1330 @code{branch} are simply concatenated together to derive the
1331 @code{svnurl} to use for the checkout.
1333 @uref{http://www.perforce.com/, Perforce} is similar. The server
1334 is specified through a @code{P4PORT} parameter. Module and branch
1335 are specified in a single depot path, and revisions are
1336 depot-wide. When branches are used, the @code{p4base} and
1337 @code{defaultBranch} are concatenated together to produce the depot
1338 path.
1340 @uref{http://wiki.gnuarch.org/, Arch} and
1341 @uref{http://bazaar.canonical.com/, Bazaar} specify a repository by
1342 URL, as well as a @code{version} which is kind of like a branch name.
1343 Arch uses the word @code{archive} to represent the repository. Arch
1344 lets you push changes from one archive to another, removing the strict
1345 centralization required by CVS and SVN. It retains the distinction
1346 between repository and working directory that most other VC systems
1347 use. For complex multi-module directory structures, Arch has a
1348 built-in @code{build config} layer with which the checkout process has
1349 two steps. First, an initial bootstrap checkout is performed to
1350 retrieve a set of build-config files. Second, one of these files is
1351 used to figure out which archives/modules should be used to populate
1352 subdirectories of the initial checkout.
1354 Builders which use Arch and Bazaar therefore have a static archive
1355 @code{url}, and a default ``branch'' (which is a string that specifies
1356 a complete category--branch--version triple). Each build can have its
1357 own branch (the category--branch--version string) to override the
1358 default, as well as a revision number (which is turned into a
1359 --patch-NN suffix when performing the checkout).
1362 @uref{http://bazaar-vcs.org, Bzr} (which is a descendant of
1363 Arch/Bazaar, and is frequently referred to as ``Bazaar'') has the same
1364 sort of repository-vs-workspace model as Arch, but the repository data
1365 can either be stored inside the working directory or kept elsewhere
1366 (either on the same machine or on an entirely different machine). For
1367 the purposes of Buildbot (which never commits changes), the repository
1368 is specified with a URL and a revision number.
1370 The most common way to obtain read-only access to a bzr tree is via
1371 HTTP, simply by making the repository visible through a web server
1372 like Apache. Bzr can also use FTP and SFTP servers, if the buildslave
1373 process has sufficient privileges to access them. Higher performance
1374 can be obtained by running a special Bazaar-specific server. None of
1375 these matter to the buildbot: the repository URL just has to match the
1376 kind of server being used. The @code{repoURL} argument provides the
1377 location of the repository.
1379 Branches are expressed as subdirectories of the main central
1380 repository, which means that if branches are being used, the BZR step
1381 is given a @code{baseURL} and @code{defaultBranch} instead of getting
1382 the @code{repoURL} argument.
1385 @uref{http://abridgegame.org/darcs/, Darcs} doesn't really have the
1386 notion of a single master repository. Nor does it really have
1387 branches. In Darcs, each working directory is also a repository, and
1388 there are operations to push and pull patches from one of these
1389 @code{repositories} to another. For the Buildbot's purposes, all you
1390 need to do is specify the URL of a repository that you want to build
1391 from. The build slave will then pull the latest patches from that
1392 repository and build them. Multiple branches are implemented by using
1393 multiple repositories (possibly living on the same server).
1395 Builders which use Darcs therefore have a static @code{repourl} which
1396 specifies the location of the repository. If branches are being used,
1397 the source Step is instead configured with a @code{baseURL} and a
1398 @code{defaultBranch}, and the two strings are simply concatenated
1399 together to obtain the repository's URL. Each build then has a
1400 specific branch which replaces @code{defaultBranch}, or just uses the
1401 default one. Instead of a revision number, each build can have a
1402 ``context'', which is a string that records all the patches that are
1403 present in a given tree (this is the output of @command{darcs changes
1404 --context}, and is considerably less concise than, e.g. Subversion's
1405 revision number, but the patch-reordering flexibility of Darcs makes
1406 it impossible to provide a shorter useful specification).
1408 @uref{http://selenic.com/mercurial, Mercurial} is like Darcs, in that
1409 each branch is stored in a separate repository. The @code{repourl},
1410 @code{baseURL}, and @code{defaultBranch} arguments are all handled the
1411 same way as with Darcs. The ``revision'', however, is the hash
1412 identifier returned by @command{hg identify}.
1415 @node Attributes of Changes,  , How Different VC Systems Specify Sources, Version Control Systems
1416 @subsection Attributes of Changes
1418 @heading Who
1420 Each Change has a @code{who} attribute, which specifies which
1421 developer is responsible for the change. This is a string which comes
1422 from a namespace controlled by the VC repository. Frequently this
1423 means it is a username on the host which runs the repository, but not
1424 all VC systems require this (Arch, for example, uses a fully-qualified
1425 @code{Arch ID}, which looks like an email address, as does Darcs).
1426 Each StatusNotifier will map the @code{who} attribute into something
1427 appropriate for their particular means of communication: an email
1428 address, an IRC handle, etc.
1430 @heading Files
1432 It also has a list of @code{files}, which are just the tree-relative
1433 filenames of any files that were added, deleted, or modified for this
1434 Change. These filenames are used by the @code{isFileImportant}
1435 function (in the Scheduler) to decide whether it is worth triggering a
1436 new build or not, e.g. the function could use
1437 @code{filename.endswith(".c")} to only run a build if a C file were
1438 checked in. Certain BuildSteps can also use the list of changed files
1439 to run a more targeted series of tests, e.g. the
1440 @code{python_twisted.Trial} step can run just the unit tests that
1441 provide coverage for the modified .py files instead of running the
1442 full test suite.
1444 @heading Comments
1446 The Change also has a @code{comments} attribute, which is a string
1447 containing any checkin comments.
1449 @heading Revision
1451 Each Change can have a @code{revision} attribute, which describes how
1452 to get a tree with a specific state: a tree which includes this Change
1453 (and all that came before it) but none that come after it. If this
1454 information is unavailable, the @code{.revision} attribute will be
1455 @code{None}. These revisions are provided by the ChangeSource, and
1456 consumed by the @code{computeSourceRevision} method in the appropriate
1457 @code{step.Source} class.
1459 @table @samp
1460 @item CVS
1461 @code{revision} is an int, seconds since the epoch
1462 @item SVN
1463 @code{revision} is an int, a transation number (r%d)
1464 @item Darcs
1465 @code{revision} is a large string, the output of @code{darcs changes --context}
1466 @item Mercurial
1467 @code{revision} is a short string (a hash ID), the output of @code{hg identify}
1468 @item Arch/Bazaar
1469 @code{revision} is the full revision ID (ending in --patch-%d)
1470 @item P4
1471 @code{revision} is an int, the transaction number
1472 @end table
1474 @heading Branches
1476 The Change might also have a @code{branch} attribute. This indicates
1477 that all of the Change's files are in the same named branch. The
1478 Schedulers get to decide whether the branch should be built or not.
1480 For VC systems like CVS, Arch, and Monotone, the @code{branch} name is
1481 unrelated to the filename. (that is, the branch name and the filename
1482 inhabit unrelated namespaces). For SVN, branches are expressed as
1483 subdirectories of the repository, so the file's ``svnurl'' is a
1484 combination of some base URL, the branch name, and the filename within
1485 the branch. (In a sense, the branch name and the filename inhabit the
1486 same namespace). Darcs branches are subdirectories of a base URL just
1487 like SVN. Mercurial branches are the same as Darcs.
1489 @table @samp
1490 @item CVS
1491 branch='warner-newfeature', files=['src/foo.c']
1492 @item SVN
1493 branch='branches/warner-newfeature', files=['src/foo.c']
1494 @item Darcs
1495 branch='warner-newfeature', files=['src/foo.c']
1496 @item Mercurial
1497 branch='warner-newfeature', files=['src/foo.c']
1498 @item Arch/Bazaar
1499 branch='buildbot--usebranches--0', files=['buildbot/master.py']
1500 @end table
1502 @heading Links
1504 @c TODO: who is using 'links'? how is it being used?
1506 Finally, the Change might have a @code{links} list, which is intended
1507 to provide a list of URLs to a @emph{viewcvs}-style web page that
1508 provides more detail for this Change, perhaps including the full file
1509 diffs.
1512 @node Schedulers, BuildSet, Version Control Systems, Concepts
1513 @section Schedulers
1515 @cindex Scheduler
1517 Each Buildmaster has a set of @code{Scheduler} objects, each of which
1518 gets a copy of every incoming Change. The Schedulers are responsible
1519 for deciding when Builds should be run. Some Buildbot installations
1520 might have a single Scheduler, while others may have several, each for
1521 a different purpose.
1523 For example, a ``quick'' scheduler might exist to give immediate
1524 feedback to developers, hoping to catch obvious problems in the code
1525 that can be detected quickly. These typically do not run the full test
1526 suite, nor do they run on a wide variety of platforms. They also
1527 usually do a VC update rather than performing a brand-new checkout
1528 each time. You could have a ``quick'' scheduler which used a 30 second
1529 timeout, and feeds a single ``quick'' Builder that uses a VC
1530 @code{mode='update'} setting.
1532 A separate ``full'' scheduler would run more comprehensive tests a
1533 little while later, to catch more subtle problems. This scheduler
1534 would have a longer tree-stable-timer, maybe 30 minutes, and would
1535 feed multiple Builders (with a @code{mode=} of @code{'copy'},
1536 @code{'clobber'}, or @code{'export'}).
1538 The @code{tree-stable-timer} and @code{isFileImportant} decisions are
1539 made by the Scheduler. Dependencies are also implemented here.
1540 Periodic builds (those which are run every N seconds rather than after
1541 new Changes arrive) are triggered by a special @code{Periodic}
1542 Scheduler subclass. The default Scheduler class can also be told to
1543 watch for specific branches, ignoring Changes on other branches. This
1544 may be useful if you have a trunk and a few release branches which
1545 should be tracked, but when you don't want to have the Buildbot pay
1546 attention to several dozen private user branches.
1548 Some Schedulers may trigger builds for other reasons, other than
1549 recent Changes. For example, a Scheduler subclass could connect to a
1550 remote buildmaster and watch for builds of a library to succeed before
1551 triggering a local build that uses that library.
1553 Each Scheduler creates and submits @code{BuildSet} objects to the
1554 @code{BuildMaster}, which is then responsible for making sure the
1555 individual @code{BuildRequests} are delivered to the target
1556 @code{Builders}.
1558 @code{Scheduler} instances are activated by placing them in the
1559 @code{c['schedulers']} list in the buildmaster config file. Each
1560 Scheduler has a unique name.
1563 @node BuildSet, BuildRequest, Schedulers, Concepts
1564 @section BuildSet
1566 @cindex BuildSet
1568 A @code{BuildSet} is the name given to a set of Builds that all
1569 compile/test the same version of the tree on multiple Builders. In
1570 general, all these component Builds will perform the same sequence of
1571 Steps, using the same source code, but on different platforms or
1572 against a different set of libraries.
1574 The @code{BuildSet} is tracked as a single unit, which fails if any of
1575 the component Builds have failed, and therefore can succeed only if
1576 @emph{all} of the component Builds have succeeded. There are two kinds
1577 of status notification messages that can be emitted for a BuildSet:
1578 the @code{firstFailure} type (which fires as soon as we know the
1579 BuildSet will fail), and the @code{Finished} type (which fires once
1580 the BuildSet has completely finished, regardless of whether the
1581 overall set passed or failed).
1583 A @code{BuildSet} is created with a @emph{source stamp} tuple of
1584 (branch, revision, changes, patch), some of which may be None, and a
1585 list of Builders on which it is to be run. They are then given to the
1586 BuildMaster, which is responsible for creating a separate
1587 @code{BuildRequest} for each Builder.
1589 There are a couple of different likely values for the
1590 @code{SourceStamp}:
1592 @table @code
1593 @item (revision=None, changes=[CHANGES], patch=None)
1594 This is a @code{SourceStamp} used when a series of Changes have
1595 triggered a build. The VC step will attempt to check out a tree that
1596 contains CHANGES (and any changes that occurred before CHANGES, but
1597 not any that occurred after them).
1599 @item (revision=None, changes=None, patch=None)
1600 This builds the most recent code on the default branch. This is the
1601 sort of @code{SourceStamp} that would be used on a Build that was
1602 triggered by a user request, or a Periodic scheduler. It is also
1603 possible to configure the VC Source Step to always check out the
1604 latest sources rather than paying attention to the Changes in the
1605 SourceStamp, which will result in same behavior as this.
1607 @item (branch=BRANCH, revision=None, changes=None, patch=None)
1608 This builds the most recent code on the given BRANCH. Again, this is
1609 generally triggered by a user request or Periodic build.
1611 @item (revision=REV, changes=None, patch=(LEVEL, DIFF))
1612 This checks out the tree at the given revision REV, then applies a
1613 patch (using @code{diff -pLEVEL <DIFF}). The @ref{try} feature uses
1614 this kind of @code{SourceStamp}. If @code{patch} is None, the patching
1615 step is bypassed.
1617 @end table
1619 The buildmaster is responsible for turning the @code{BuildSet} into a
1620 set of @code{BuildRequest} objects and queueing them on the
1621 appropriate Builders.
1624 @node BuildRequest, Builder, BuildSet, Concepts
1625 @section BuildRequest
1627 @cindex BuildRequest
1629 A @code{BuildRequest} is a request to build a specific set of sources
1630 on a single specific Builder. Each Builder runs the
1631 @code{BuildRequest} as soon as it can (i.e. when an associated
1632 buildslave becomes free).
1634 The @code{BuildRequest} contains the @code{SourceStamp} specification.
1635 The actual process of running the build (the series of Steps that will
1636 be executed) is implemented by the @code{Build} object. In this future
1637 this might be changed, to have the @code{Build} define @emph{what}
1638 gets built, and a separate @code{BuildProcess} (provided by the
1639 Builder) to define @emph{how} it gets built.
1641 The @code{BuildRequest} may be mergeable with other compatible
1642 @code{BuildRequest}s. Builds that are triggered by incoming Changes
1643 will generally be mergeable. Builds that are triggered by user
1644 requests are generally not, unless they are multiple requests to build
1645 the @emph{latest sources} of the same branch.
1647 @node Builder, Users, BuildRequest, Concepts
1648 @section Builder
1650 @cindex Builder
1652 The @code{Builder} is a long-lived object which controls all Builds of
1653 a given type. Each one is created when the config file is first
1654 parsed, and lives forever (or rather until it is removed from the
1655 config file). It mediates the connections to the buildslaves that do
1656 all the work, and is responsible for creating the @code{Build} objects
1657 that decide @emph{how} a build is performed (i.e., which steps are
1658 executed in what order).
1660 Each @code{Builder} gets a unique name, and the path name of a
1661 directory where it gets to do all its work (there is a
1662 buildmaster-side directory for keeping status information, as well as
1663 a buildslave-side directory where the actual checkout/compile/test
1664 commands are executed). It also gets a @code{BuildFactory}, which is
1665 responsible for creating new @code{Build} instances: because the
1666 @code{Build} instance is what actually performs each build, choosing
1667 the @code{BuildFactory} is the way to specify what happens each time a
1668 build is done.
1670 Each @code{Builder} is associated with one of more @code{BuildSlaves}.
1671 A @code{Builder} which is used to perform OS-X builds (as opposed to
1672 Linux or Solaris builds) should naturally be associated with an
1673 OS-X-based buildslave.
1676 @node Users,  , Builder, Concepts
1677 @section Users
1679 @cindex Users
1681 Buildbot has a somewhat limited awareness of @emph{users}. It assumes
1682 the world consists of a set of developers, each of whom can be
1683 described by a couple of simple attributes. These developers make
1684 changes to the source code, causing builds which may succeed or fail.
1686 Each developer is primarily known through the source control system. Each
1687 Change object that arrives is tagged with a @code{who} field that
1688 typically gives the account name (on the repository machine) of the user
1689 responsible for that change. This string is the primary key by which the
1690 User is known, and is displayed on the HTML status pages and in each Build's
1691 ``blamelist''.
1693 To do more with the User than just refer to them, this username needs to
1694 be mapped into an address of some sort. The responsibility for this mapping
1695 is left up to the status module which needs the address. The core code knows
1696 nothing about email addresses or IRC nicknames, just user names.
1698 @menu
1699 * Doing Things With Users::     
1700 * Email Addresses::             
1701 * IRC Nicknames::               
1702 * Live Status Clients::         
1703 @end menu
1705 @node Doing Things With Users, Email Addresses, Users, Users
1706 @subsection Doing Things With Users
1708 Each Change has a single User who is responsible for that Change. Most
1709 Builds have a set of Changes: the Build represents the first time these
1710 Changes have been built and tested by the Buildbot. The build has a
1711 ``blamelist'' that consists of a simple union of the Users responsible
1712 for all the Build's Changes.
1714 The Build provides (through the IBuildStatus interface) a list of Users
1715 who are ``involved'' in the build. For now this is equal to the
1716 blamelist, but in the future it will be expanded to include a ``build
1717 sheriff'' (a person who is ``on duty'' at that time and responsible for
1718 watching over all builds that occur during their shift), as well as
1719 per-module owners who simply want to keep watch over their domain (chosen by
1720 subdirectory or a regexp matched against the filenames pulled out of the
1721 Changes). The Involved Users are those who probably have an interest in the
1722 results of any given build.
1724 In the future, Buildbot will acquire the concept of ``Problems'',
1725 which last longer than builds and have beginnings and ends. For example, a
1726 test case which passed in one build and then failed in the next is a
1727 Problem. The Problem lasts until the test case starts passing again, at
1728 which point the Problem is said to be ``resolved''.
1730 If there appears to be a code change that went into the tree at the
1731 same time as the test started failing, that Change is marked as being
1732 resposible for the Problem, and the user who made the change is added
1733 to the Problem's ``Guilty'' list. In addition to this user, there may
1734 be others who share responsibility for the Problem (module owners,
1735 sponsoring developers). In addition to the Responsible Users, there
1736 may be a set of Interested Users, who take an interest in the fate of
1737 the Problem.
1739 Problems therefore have sets of Users who may want to be kept aware of
1740 the condition of the problem as it changes over time. If configured, the
1741 Buildbot can pester everyone on the Responsible list with increasing
1742 harshness until the problem is resolved, with the most harshness reserved
1743 for the Guilty parties themselves. The Interested Users may merely be told
1744 when the problem starts and stops, as they are not actually responsible for
1745 fixing anything.
1747 @node Email Addresses, IRC Nicknames, Doing Things With Users, Users
1748 @subsection Email Addresses
1750 The @code{buildbot.status.mail.MailNotifier} class provides a
1751 status target which can send email about the results of each build. It
1752 accepts a static list of email addresses to which each message should be
1753 delivered, but it can also be configured to send mail to the Build's
1754 Interested Users. To do this, it needs a way to convert User names into
1755 email addresses.
1757 For many VC systems, the User Name is actually an account name on the
1758 system which hosts the repository. As such, turning the name into an
1759 email address is a simple matter of appending
1760 ``@@repositoryhost.com''. Some projects use other kinds of mappings
1761 (for example the preferred email address may be at ``project.org''
1762 despite the repository host being named ``cvs.project.org''), and some
1763 VC systems have full separation between the concept of a user and that
1764 of an account on the repository host (like Perforce). Some systems
1765 (like Arch) put a full contact email address in every change.
1767 To convert these names to addresses, the MailNotifier uses an EmailLookup
1768 object. This provides a .getAddress method which accepts a name and
1769 (eventually) returns an address. The default @code{MailNotifier}
1770 module provides an EmailLookup which simply appends a static string,
1771 configurable when the notifier is created. To create more complex behaviors
1772 (perhaps using an LDAP lookup, or using ``finger'' on a central host to
1773 determine a preferred address for the developer), provide a different object
1774 as the @code{lookup} argument.
1776 In the future, when the Problem mechanism has been set up, the Buildbot
1777 will need to send mail to arbitrary Users. It will do this by locating a
1778 MailNotifier-like object among all the buildmaster's status targets, and
1779 asking it to send messages to various Users. This means the User-to-address
1780 mapping only has to be set up once, in your MailNotifier, and every email
1781 message the buildbot emits will take advantage of it.
1783 @node IRC Nicknames, Live Status Clients, Email Addresses, Users
1784 @subsection IRC Nicknames
1786 Like MailNotifier, the @code{buildbot.status.words.IRC} class
1787 provides a status target which can announce the results of each build. It
1788 also provides an interactive interface by responding to online queries
1789 posted in the channel or sent as private messages.
1791 In the future, the buildbot can be configured map User names to IRC
1792 nicknames, to watch for the recent presence of these nicknames, and to
1793 deliver build status messages to the interested parties. Like
1794 @code{MailNotifier} does for email addresses, the @code{IRC} object
1795 will have an @code{IRCLookup} which is responsible for nicknames. The
1796 mapping can be set up statically, or it can be updated by online users
1797 themselves (by claiming a username with some kind of ``buildbot: i am
1798 user warner'' commands).
1800 Once the mapping is established, the rest of the buildbot can ask the
1801 @code{IRC} object to send messages to various users. It can report on
1802 the likelihood that the user saw the given message (based upon how long the
1803 user has been inactive on the channel), which might prompt the Problem
1804 Hassler logic to send them an email message instead.
1806 @node Live Status Clients,  , IRC Nicknames, Users
1807 @subsection Live Status Clients
1809 The Buildbot also offers a PB-based status client interface which can
1810 display real-time build status in a GUI panel on the developer's desktop.
1811 This interface is normally anonymous, but it could be configured to let the
1812 buildmaster know @emph{which} developer is using the status client. The
1813 status client could then be used as a message-delivery service, providing an
1814 alternative way to deliver low-latency high-interruption messages to the
1815 developer (like ``hey, you broke the build'').
1818 @node Configuration, Getting Source Code Changes, Concepts, Top
1819 @chapter Configuration
1821 @cindex Configuration
1823 The buildbot's behavior is defined by the ``config file'', which
1824 normally lives in the @file{master.cfg} file in the buildmaster's base
1825 directory (but this can be changed with an option to the
1826 @code{buildbot create-master} command). This file completely specifies
1827 which Builders are to be run, which slaves they should use, how
1828 Changes should be tracked, and where the status information is to be
1829 sent. The buildmaster's @file{buildbot.tac} file names the base
1830 directory; everything else comes from the config file.
1832 A sample config file was installed for you when you created the
1833 buildmaster, but you will need to edit it before your buildbot will do
1834 anything useful.
1836 This chapter gives an overview of the format of this file and the
1837 various sections in it. You will need to read the later chapters to
1838 understand how to fill in each section properly.
1840 @menu
1841 * Config File Format::          
1842 * Loading the Config File::     
1843 * Defining the Project::        
1844 * Listing Change Sources and Schedulers::  
1845 * Setting the slaveport::       
1846 * Buildslave Specifiers::       
1847 * Defining Builders::           
1848 * Defining Status Targets::     
1849 * Debug options::               
1850 @end menu
1852 @node Config File Format, Loading the Config File, Configuration, Configuration
1853 @section Config File Format
1855 The config file is, fundamentally, just a piece of Python code which
1856 defines a dictionary named @code{BuildmasterConfig}, with a number of
1857 keys that are treated specially. You don't need to know Python to do
1858 basic configuration, though, you can just copy the syntax of the
1859 sample file. If you @emph{are} comfortable writing Python code,
1860 however, you can use all the power of a full programming language to
1861 achieve more complicated configurations.
1863 The @code{BuildmasterConfig} name is the only one which matters: all
1864 other names defined during the execution of the file are discarded.
1865 When parsing the config file, the Buildmaster generally compares the
1866 old configuration with the new one and performs the minimum set of
1867 actions necessary to bring the buildbot up to date: Builders which are
1868 not changed are left untouched, and Builders which are modified get to
1869 keep their old event history.
1871 Basic Python syntax: comments start with a hash character (``#''),
1872 tuples are defined with @code{(parenthesis, pairs)}, arrays are
1873 defined with @code{[square, brackets]}, tuples and arrays are mostly
1874 interchangeable. Dictionaries (data structures which map ``keys'' to
1875 ``values'') are defined with curly braces: @code{@{'key1': 'value1',
1876 'key2': 'value2'@} }. Function calls (and object instantiation) can use
1877 named parameters, like @code{w = html.Waterfall(http_port=8010)}.
1879 The config file starts with a series of @code{import} statements,
1880 which make various kinds of Steps and Status targets available for
1881 later use. The main @code{BuildmasterConfig} dictionary is created,
1882 then it is populated with a variety of keys. These keys are broken
1883 roughly into the following sections, each of which is documented in
1884 the rest of this chapter:
1886 @itemize @bullet
1887 @item
1888 Project Definitions
1889 @item
1890 Change Sources / Schedulers
1891 @item
1892 Slaveport
1893 @item
1894 Buildslave Configuration
1895 @item
1896 Builders / Interlocks
1897 @item
1898 Status Targets
1899 @item
1900 Debug options
1901 @end itemize
1903 The config file can use a few names which are placed into its namespace:
1905 @table @code
1906 @item basedir
1907 the base directory for the buildmaster. This string has not been
1908 expanded, so it may start with a tilde. It needs to be expanded before
1909 use. The config file is located in
1910 @code{os.path.expanduser(os.path.join(basedir, 'master.cfg'))}
1912 @end table
1915 @node Loading the Config File, Defining the Project, Config File Format, Configuration
1916 @section Loading the Config File
1918 The config file is only read at specific points in time. It is first
1919 read when the buildmaster is launched. Once it is running, there are
1920 various ways to ask it to reload the config file. If you are on the
1921 system hosting the buildmaster, you can send a @code{SIGHUP} signal to
1922 it: the @command{buildbot} tool has a shortcut for this:
1924 @example
1925 buildbot reconfig @var{BASEDIR}
1926 @end example
1928 This command will show you all of the lines from @file{twistd.log}
1929 that relate to the reconfiguration. If there are any problems during
1930 the config-file reload, they will be displayed in these lines.
1932 The debug tool (@code{buildbot debugclient --master HOST:PORT}) has a
1933 ``Reload .cfg'' button which will also trigger a reload. In the
1934 future, there will be other ways to accomplish this step (probably a
1935 password-protected button on the web page, as well as a privileged IRC
1936 command).
1938 When reloading the config file, the buildmaster will endeavor to
1939 change as little as possible about the running system. For example,
1940 although old status targets may be shut down and new ones started up,
1941 any status targets that were not changed since the last time the
1942 config file was read will be left running and untouched. Likewise any
1943 Builders which have not been changed will be left running. If a
1944 Builder is modified (say, the build process is changed) while a Build
1945 is currently running, that Build will keep running with the old
1946 process until it completes. Any previously queued Builds (or Builds
1947 which get queued after the reconfig) will use the new process.
1949 @node Defining the Project, Listing Change Sources and Schedulers, Loading the Config File, Configuration
1950 @section Defining the Project
1952 There are a couple of basic settings that you use to tell the buildbot
1953 what project it is working on. This information is used by status
1954 reporters to let users find out more about the codebase being
1955 exercised by this particular Buildbot installation.
1957 @example
1958 c['projectName'] = "Buildbot"
1959 c['projectURL'] = "http://buildbot.sourceforge.net/"
1960 c['buildbotURL'] = "http://localhost:8010/"
1961 @end example
1963 @bcindex c['projectName']
1964 @code{projectName} is a short string will be used to describe the
1965 project that this buildbot is working on. For example, it is used as
1966 the title of the waterfall HTML page. 
1968 @bcindex c['projectURL']
1969 @code{projectURL} is a string that gives a URL for the project as a
1970 whole. HTML status displays will show @code{projectName} as a link to
1971 @code{projectURL}, to provide a link from buildbot HTML pages to your
1972 project's home page.
1974 @bcindex c['buildbotURL']
1975 The @code{buildbotURL} string should point to the location where the
1976 buildbot's internal web server (usually the @code{html.Waterfall}
1977 page) is visible. This typically uses the port number set when you
1978 create the @code{Waterfall} object: the buildbot needs your help to
1979 figure out a suitable externally-visible host name.
1981 When status notices are sent to users (either by email or over IRC),
1982 @code{buildbotURL} will be used to create a URL to the specific build
1983 or problem that they are being notified about. It will also be made
1984 available to queriers (over IRC) who want to find out where to get
1985 more information about this buildbot.
1988 @node Listing Change Sources and Schedulers, Setting the slaveport, Defining the Project, Configuration
1989 @section Listing Change Sources and Schedulers
1991 @bcindex c['sources']
1992 The @code{c['sources']} key is a list of ChangeSource
1993 instances@footnote{To be precise, it is a list of objects which all
1994 implement the @code{buildbot.interfaces.IChangeSource} Interface}.
1995 This defines how the buildmaster learns about source code changes.
1996 More information about what goes here is available in @xref{Getting
1997 Source Code Changes}.
1999 @example
2000 import buildbot.changes.pb
2001 c['sources'] = [buildbot.changes.pb.PBChangeSource()]
2002 @end example
2004 @bcindex c['schedulers']
2005 @code{c['schedulers']} is a list of Scheduler instances, each of which
2006 causes builds to be started on a particular set of Builders. The two
2007 basic Scheduler classes you are likely to start with are
2008 @code{Scheduler} and @code{Periodic}, but you can write a customized
2009 subclass to implement more complicated build scheduling.
2011 The docstring for @code{buildbot.scheduler.Scheduler} is the best
2012 place to see all the options that can be used. Type @code{pydoc
2013 buildbot.scheduler.Scheduler} to see it, or look in
2014 @file{buildbot/scheduler.py} directly.
2016 The basic Scheduler takes four arguments:
2018 @table @code
2019 @item name
2020 Each Scheduler must have a unique name. This is only used in status
2021 displays.
2023 @item branch
2024 This Scheduler will pay attention to a single branch, ignoring Changes
2025 that occur on other branches. Setting @code{branch} equal to the
2026 special value of @code{None} means it should only pay attention to the
2027 default branch. Note that @code{None} is a keyword, not a string, so
2028 you want to use @code{None} and not @code{"None"}.
2030 @item treeStableTimer
2031 The Scheduler will wait for this many seconds before starting the
2032 build. If new changes are made during this interval, the timer will be
2033 restarted, so really the build will be started after a change and then
2034 after this many seconds of inactivity.
2036 @item builderNames
2037 When the tree-stable-timer finally expires, builds will be started on
2038 these Builders. Each Builder gets a unique name: these strings must
2039 match.
2041 @end table
2043 @example
2044 from buildbot import scheduler
2045 quick = scheduler.Scheduler("quick", None, 60,
2046                             ["quick-linux", "quick-netbsd"])
2047 full = scheduler.Scheduler("full", None, 5*60,
2048                            ["full-linux", "full-netbsd", "full-OSX"])
2049 nightly = scheduler.Periodic("nightly", ["full-solaris"], 24*60*60)
2050 c['schedulers'] = [quick, full, nightly]
2051 @end example
2053 In this example, the two ``quick'' builds are triggered 60 seconds
2054 after the tree has been changed. The ``full'' builds do not run quite
2055 so quickly (they wait 5 minutes), so hopefully if the quick builds
2056 fail due to a missing file or really simple typo, the developer can
2057 discover and fix the problem before the full builds are started. Both
2058 Schedulers only pay attention to the default branch: any changes on
2059 other branches are ignored by these Schedulers. Each Scheduler
2060 triggers a different set of Builders, referenced by name.
2062 The third Scheduler in this example just runs the full solaris build
2063 once per day. (note that this Scheduler only lets you control the time
2064 between builds, not the absolute time-of-day of each Build, so this
2065 could easily wind up a ``daily'' or ``every afternoon'' scheduler
2066 depending upon when it was first activated).
2068 @menu
2069 * Scheduler Types::             
2070 * Build Dependencies::          
2071 @end menu
2073 @node Scheduler Types, Build Dependencies, Listing Change Sources and Schedulers, Listing Change Sources and Schedulers
2074 @subsection Scheduler Types
2076 @slindex buildbot.scheduler.Scheduler
2077 @slindex buildbot.scheduler.AnyBranchScheduler
2078 @slindex buildbot.scheduler.Periodic
2079 @slindex buildbot.scheduler.Nightly
2081 Here is a brief catalog of the available Scheduler types. All these
2082 Schedulers are classes in @code{buildbot.scheduler}, and the
2083 docstrings there are the best source of documentation on the arguments
2084 taken by each one.
2086 @table @code
2087 @item Scheduler
2088 This is the default Scheduler class. It follows exactly one branch,
2089 and starts a configurable tree-stable-timer after each change on that
2090 branch. When the timer expires, it starts a build on some set of
2091 Builders. The Scheduler accepts a @code{fileIsImportant} function
2092 which can be used to ignore some Changes if they do not affect any
2093 ``important'' files.
2095 @item AnyBranchScheduler
2096 This scheduler uses a tree-stable-timer like the default one, but
2097 follows multiple branches at once. Each branch gets a separate timer.
2099 @item Dependent
2100 This scheduler watches an ``upstream'' Builder. When that Builder
2101 successfully builds a particular set of Changes, it triggers builds of
2102 the same code on a configured set of ``downstream'' builders. The next
2103 section (@pxref{Build Dependencies}) describes this scheduler in more
2104 detail.
2106 @item Periodic
2107 This simple scheduler just triggers a build every N seconds.
2109 @item Nightly
2110 This is highly configurable periodic build scheduler, which triggers a
2111 build at particular times of day, week, month, or year. The
2112 configuration syntax is very similar to the well-known @code{crontab}
2113 format, in which you provide values for minute, hour, day, and month
2114 (some of which can be wildcards), and a build is triggered whenever
2115 the current time matches the given constraints. This can run a build
2116 every night, every morning, every weekend, alternate Thursdays, on
2117 your boss's birthday, etc.
2119 @item Try_Jobdir / Try_Userpass
2120 This scheduler allows developers to use the @code{buildbot try}
2121 command to trigger builds of code they have not yet committed. See
2122 @ref{try} for complete details.
2124 @end table
2126 @node Build Dependencies,  , Scheduler Types, Listing Change Sources and Schedulers
2127 @subsection Build Dependencies
2129 @cindex Dependent
2130 @cindex Dependencies
2131 @slindex buildbot.scheduler.Dependent
2133 It is common to wind up with one kind of build which should only be
2134 performed if the same source code was successfully handled by some
2135 other kind of build first. An example might be a packaging step: you
2136 might only want to produce .deb or RPM packages from a tree that was
2137 known to compile successfully and pass all unit tests. You could put
2138 the packaging step in the same Build as the compile and testing steps,
2139 but there might be other reasons to not do this (in particular you
2140 might have several Builders worth of compiles/tests, but only wish to
2141 do the packaging once). Another example is if you want to skip the
2142 ``full'' builds after a failing ``quick'' build of the same source
2143 code. Or, if one Build creates a product (like a compiled library)
2144 that is used by some other Builder, you'd want to make sure the
2145 consuming Build is run @emph{after} the producing one.
2147 You can use @code{Dependencies} to express this relationship to the
2148 Buildbot. There is a special kind of Scheduler named
2149 @code{scheduler.Dependent} that will watch an ``upstream'' Scheduler
2150 for builds to complete successfully (on all of its Builders). Each
2151 time that happens, the same source code (i.e. the same
2152 @code{SourceStamp}) will be used to start a new set of builds, on a
2153 different set of Builders. This ``downstream'' scheduler doesn't pay
2154 attention to Changes at all, it only pays attention to the upstream
2155 scheduler.
2157 If the SourceStamp fails on any of the Builders in the upstream set,
2158 the downstream builds will not fire.
2160 @example
2161 from buildbot import scheduler
2162 tests = scheduler.Scheduler("tests", None, 5*60,
2163                             ["full-linux", "full-netbsd", "full-OSX"])
2164 package = scheduler.Dependent("package",
2165                               tests, # upstream scheduler
2166                               ["make-tarball", "make-deb", "make-rpm"])
2167 c['schedulers'] = [tests, package]
2168 @end example
2170 Note that @code{Dependent}'s upstream scheduler argument is given as a
2171 @code{Scheduler} @emph{instance}, not a name. This makes it impossible
2172 to create circular dependencies in the config file.
2175 @node Setting the slaveport, Buildslave Specifiers, Listing Change Sources and Schedulers, Configuration
2176 @section Setting the slaveport
2178 @bcindex c['slavePortnum']
2180 The buildmaster will listen on a TCP port of your choosing for
2181 connections from buildslaves. It can also use this port for
2182 connections from remote Change Sources, status clients, and debug
2183 tools. This port should be visible to the outside world, and you'll
2184 need to tell your buildslave admins about your choice.
2186 It does not matter which port you pick, as long it is externally
2187 visible, however you should probably use something larger than 1024,
2188 since most operating systems don't allow non-root processes to bind to
2189 low-numbered ports. If your buildmaster is behind a firewall or a NAT
2190 box of some sort, you may have to configure your firewall to permit
2191 inbound connections to this port.
2193 @example
2194 c['slavePortnum'] = 10000
2195 @end example
2197 @code{c['slavePortnum']} is a @emph{strports} specification string,
2198 defined in the @code{twisted.application.strports} module (try
2199 @command{pydoc twisted.application.strports} to get documentation on
2200 the format). This means that you can have the buildmaster listen on a
2201 localhost-only port by doing:
2203 @example
2204 c['slavePortnum'] = "tcp:10000:interface=127.0.0.1"
2205 @end example
2207 This might be useful if you only run buildslaves on the same machine,
2208 and they are all configured to contact the buildmaster at
2209 @code{localhost:10000}.
2212 @node Buildslave Specifiers, Defining Builders, Setting the slaveport, Configuration
2213 @section Buildslave Specifiers
2215 @bcindex c['bots']
2217 The @code{c['bots']} key is a list of known buildslaves. Each
2218 buildslave is defined by a tuple of (slavename, slavepassword). These
2219 are the same two values that need to be provided to the buildslave
2220 administrator when they create the buildslave.
2222 @example
2223 c['bots'] = [('bot-solaris', 'solarispasswd'),
2224              ('bot-bsd', 'bsdpasswd'),
2225             ]
2226 @end example
2228 The slavenames must be unique, of course. The password exists to
2229 prevent evildoers from interfering with the buildbot by inserting
2230 their own (broken) buildslaves into the system and thus displacing the
2231 real ones.
2233 Buildslaves with an unrecognized slavename or a non-matching password
2234 will be rejected when they attempt to connect, and a message
2235 describing the problem will be put in the log file (see @ref{Logfiles}).
2238 @node Defining Builders, Defining Status Targets, Buildslave Specifiers, Configuration
2239 @section Defining Builders
2241 @bcindex c['builders']
2243 The @code{c['builders']} key is a list of dictionaries which specify
2244 the Builders. The Buildmaster runs a collection of Builders, each of
2245 which handles a single type of build (e.g. full versus quick), on a
2246 single build slave. A Buildbot which makes sure that the latest code
2247 (``HEAD'') compiles correctly across four separate architecture will
2248 have four Builders, each performing the same build but on different
2249 slaves (one per platform).
2251 Each Builder gets a separate column in the waterfall display. In
2252 general, each Builder runs independently (although various kinds of
2253 interlocks can cause one Builder to have an effect on another).
2255 Each Builder specification dictionary has several required keys:
2257 @table @code
2258 @item name
2259 This specifies the Builder's name, which is used in status
2260 reports.
2262 @item slavename
2263 This specifies which buildslave will be used by this Builder.
2264 @code{slavename} must appear in the @code{c['bots']} list. Each
2265 buildslave can accomodate multiple Builders.
2267 @item slavenames
2268 If you provide @code{slavenames} instead of @code{slavename}, you can
2269 give a list of buildslaves which are capable of running this Builder.
2270 If multiple buildslaves are available for any given Builder, you will
2271 have some measure of redundancy: in case one slave goes offline, the
2272 others can still keep the Builder working. In addition, multiple
2273 buildslaves will allow multiple simultaneous builds for the same
2274 Builder, which might be useful if you have a lot of forced or ``try''
2275 builds taking place.
2277 If you use this feature, it is important to make sure that the
2278 buildslaves are all, in fact, capable of running the given build. The
2279 slave hosts should be configured similarly, otherwise you will spend a
2280 lot of time trying (unsuccessfully) to reproduce a failure that only
2281 occurs on some of the buildslaves and not the others. Different
2282 platforms, operating systems, versions of major programs or libraries,
2283 all these things mean you should use separate Builders.
2285 @item builddir
2286 This specifies the name of a subdirectory (under the base directory)
2287 in which everything related to this builder will be placed. On the
2288 buildmaster, this holds build status information. On the buildslave,
2289 this is where checkouts, compiles, and tests are run.
2291 @item factory
2292 This is a @code{buildbot.process.factory.BuildFactory} instance which
2293 controls how the build is performed. Full details appear in their own
2294 chapter, @xref{Build Process}. Parameters like the location of the CVS
2295 repository and the compile-time options used for the build are
2296 generally provided as arguments to the factory's constructor.
2298 @end table
2300 Other optional keys may be set on each Builder:
2302 @table @code
2304 @item category
2305 If provided, this is a string that identifies a category for the
2306 builder to be a part of. Status clients can limit themselves to a
2307 subset of the available categories. A common use for this is to add
2308 new builders to your setup (for a new module, or for a new buildslave)
2309 that do not work correctly yet and allow you to integrate them with
2310 the active builders. You can put these new builders in a test
2311 category, make your main status clients ignore them, and have only
2312 private status clients pick them up. As soon as they work, you can
2313 move them over to the active category.
2315 @end table
2318 @node Defining Status Targets, Debug options, Defining Builders, Configuration
2319 @section Defining Status Targets
2321 The Buildmaster has a variety of ways to present build status to
2322 various users. Each such delivery method is a ``Status Target'' object
2323 in the configuration's @code{status} list. To add status targets, you
2324 just append more objects to this list:
2326 @bcindex c['status']
2328 @example
2329 c['status'] = []
2331 from buildbot.status import html
2332 c['status'].append(html.Waterfall(http_port=8010))
2334 from buildbot.status import mail
2335 m = mail.MailNotifier(fromaddr="buildbot@@localhost",
2336                       extraRecipients=["builds@@lists.example.com"],
2337                       sendToInterestedUsers=False)
2338 c['status'].append(m)
2340 from buildbot.status import words
2341 c['status'].append(words.IRC(host="irc.example.com", nick="bb",
2342                              channels=["#example"]))
2343 @end example
2345 Status delivery has its own chapter, @xref{Status Delivery}, in which
2346 all the built-in status targets are documented.
2349 @node Debug options,  , Defining Status Targets, Configuration
2350 @section Debug options
2353 @bcindex c['debugPassword']
2354 If you set @code{c['debugPassword']}, then you can connect to the
2355 buildmaster with the diagnostic tool launched by @code{buildbot
2356 debugclient MASTER:PORT}. From this tool, you can reload the config
2357 file, manually force builds, and inject changes, which may be useful
2358 for testing your buildmaster without actually commiting changes to
2359 your repository (or before you have the Change Sources set up). The
2360 debug tool uses the same port number as the slaves do:
2361 @code{c['slavePortnum']}, and is authenticated with this password.
2363 @example
2364 c['debugPassword'] = "debugpassword"
2365 @end example
2367 @bcindex c['manhole']
2368 If you set @code{c['manhole']} to an instance of one of the classes in
2369 @code{buildbot.manhole}, you can telnet or ssh into the buildmaster
2370 and get an interactive Python shell, which may be useful for debugging
2371 buildbot internals. It is probably only useful for buildbot
2372 developers. It exposes full access to the buildmaster's account
2373 (including the ability to modify and delete files), so it should not
2374 be enabled with a weak or easily guessable password.
2376 There are three separate @code{Manhole} classes. Two of them use SSH,
2377 one uses unencrypted telnet. Two of them use a username+password
2378 combination to grant access, one of them uses an SSH-style
2379 @file{authorized_keys} file which contains a list of ssh public keys.
2381 @table @code
2382 @item manhole.AuthorizedKeysManhole
2383 You construct this with the name of a file that contains one SSH
2384 public key per line, just like @file{~/.ssh/authorized_keys}. If you
2385 provide a non-absolute filename, it will be interpreted relative to
2386 the buildmaster's base directory.
2388 @item manhole.PasswordManhole
2389 This one accepts SSH connections but asks for a username and password
2390 when authenticating. It accepts only one such pair.
2393 @item manhole.TelnetManhole
2394 This accepts regular unencrypted telnet connections, and asks for a
2395 username/password pair before providing access. Because this
2396 username/password is transmitted in the clear, and because Manhole
2397 access to the buildmaster is equivalent to granting full shell
2398 privileges to both the buildmaster and all the buildslaves (and to all
2399 accounts which then run code produced by the buildslaves), it is
2400 highly recommended that you use one of the SSH manholes instead.
2402 @end table
2404 @example
2405 # some examples:
2406 from buildbot import manhole
2407 c['manhole'] = manhole.AuthorizedKeysManhole(1234, "authorized_keys")
2408 c['manhole'] = manhole.PasswordManhole(1234, "alice", "mysecretpassword")
2409 c['manhole'] = manhole.TelnetManhole(1234, "bob", "snoop_my_password_please")
2410 @end example
2412 The @code{Manhole} instance can be configured to listen on a specific
2413 port. You may wish to have this listening port bind to the loopback
2414 interface (sometimes known as ``lo0'', ``localhost'', or 127.0.0.1) to
2415 restrict access to clients which are running on the same host.
2417 @example
2418 from buildbot.manhole import PasswordManhole
2419 c['manhole'] = PasswordManhole("tcp:9999:interface=127.0.0.1","admin","passwd")
2420 @end example
2422 To have the @code{Manhole} listen on all interfaces, use
2423 @code{"tcp:9999"} or simply 9999. This port specification uses
2424 @code{twisted.application.strports}, so you can make it listen on SSL
2425 or even UNIX-domain sockets if you want.
2427 Note that using any Manhole requires that the TwistedConch package be
2428 installed, and that you be using Twisted version 2.0 or later.
2430 The buildmaster's SSH server will use a different host key than the
2431 normal sshd running on a typical unix host. This will cause the ssh
2432 client to complain about a ``host key mismatch'', because it does not
2433 realize there are two separate servers running on the same host. To
2434 avoid this, use a clause like the following in your @file{.ssh/config}
2435 file:
2437 @example
2438 Host remotehost-buildbot
2439  HostName remotehost
2440  HostKeyAlias remotehost-buildbot
2441  Port 9999
2442  # use 'user' if you use PasswordManhole and your name is not 'admin'.
2443  # if you use AuthorizedKeysManhole, this probably doesn't matter.
2444  User admin
2445 @end example
2448 @node Getting Source Code Changes, Build Process, Configuration, Top
2449 @chapter Getting Source Code Changes
2451 The most common way to use the Buildbot is centered around the idea of
2452 @code{Source Trees}: a directory tree filled with source code of some form
2453 which can be compiled and/or tested. Some projects use languages that don't
2454 involve any compilation step: nevertheless there may be a @code{build} phase
2455 where files are copied or rearranged into a form that is suitable for
2456 installation. Some projects do not have unit tests, and the Buildbot is
2457 merely helping to make sure that the sources can compile correctly. But in
2458 all of these cases, the thing-being-tested is a single source tree.
2460 A Version Control System mantains a source tree, and tells the
2461 buildmaster when it changes. The first step of each Build is typically
2462 to acquire a copy of some version of this tree.
2464 This chapter describes how the Buildbot learns about what Changes have
2465 occurred. For more information on VC systems and Changes, see
2466 @ref{Version Control Systems}.
2469 @menu
2470 * Change Sources::              
2471 @end menu
2475 @node Change Sources,  , Getting Source Code Changes, Getting Source Code Changes
2476 @section Change Sources
2478 @c TODO: rework this, the one-buildmaster-one-tree thing isn't quite
2479 @c so narrow-minded anymore
2481 Each Buildmaster watches a single source tree. Changes can be provided
2482 by a variety of ChangeSource types, however any given project will
2483 typically have only a single ChangeSource active. This section
2484 provides a description of all available ChangeSource types and
2485 explains how to set up each of them.
2487 There are a variety of ChangeSources available, some of which are
2488 meant to be used in conjunction with other tools to deliver Change
2489 events from the VC repository to the buildmaster.
2491 @itemize @bullet
2493 @item CVSToys
2494 This ChangeSource opens a TCP connection from the buildmaster to a
2495 waiting FreshCVS daemon that lives on the repository machine, and
2496 subscribes to hear about Changes.
2498 @item MaildirSource
2499 This one watches a local maildir-format inbox for email sent out by
2500 the repository when a change is made. When a message arrives, it is
2501 parsed to create the Change object. A variety of parsing functions are
2502 available to accomodate different email-sending tools.
2504 @item PBChangeSource
2505 This ChangeSource listens on a local TCP socket for inbound
2506 connections from a separate tool. Usually, this tool would be run on
2507 the VC repository machine in a commit hook. It is expected to connect
2508 to the TCP socket and send a Change message over the network
2509 connection. The @command{buildbot sendchange} command is one example
2510 of a tool that knows how to send these messages, so you can write a
2511 commit script for your VC system that calls it to deliver the Change.
2512 There are other tools in the contrib/ directory that use the same
2513 protocol.
2515 @end itemize
2517 As a quick guide, here is a list of VC systems and the ChangeSources
2518 that might be useful with them. All of these ChangeSources are in the
2519 @code{buildbot.changes} module.
2521 @table @code
2522 @item CVS
2524 @itemize @bullet
2525 @item freshcvs.FreshCVSSource (connected via TCP to the freshcvs daemon)
2526 @item mail.FCMaildirSource (watching for email sent by a freshcvs daemon)
2527 @item mail.BonsaiMaildirSource (watching for email sent by Bonsai)
2528 @item mail.SyncmailMaildirSource (watching for email sent by syncmail)
2529 @item pb.PBChangeSource (listening for connections from @code{buildbot
2530 sendchange} run in a loginfo script)
2531 @item pb.PBChangeSource (listening for connections from a long-running
2532 @code{contrib/viewcvspoll.py} polling process which examines the ViewCVS
2533 database directly
2534 @end itemize
2536 @item SVN
2537 @itemize @bullet
2538 @item pb.PBChangeSource (listening for connections from
2539 @code{contrib/svn_buildbot.py} run in a postcommit script)
2540 @item pb.PBChangeSource (listening for connections from a long-running
2541 @code{contrib/svn_watcher.py} or @code{contrib/svnpoller.py} polling
2542 process
2543 @item svnpoller.SVNPoller (polling the SVN repository)
2544 @end itemize
2546 @item Darcs
2547 @itemize @bullet
2548 @item pb.PBChangeSource (listening for connections from
2549 @code{contrib/darcs_buildbot.py} in a commit script
2550 @end itemize
2552 @item Mercurial
2553 @itemize @bullet
2554 @item pb.PBChangeSource (listening for connections from
2555 @code{contrib/hg_buildbot.py} run in an 'incoming' hook)
2556 @end itemize
2558 @item Arch/Bazaar
2559 @itemize @bullet
2560 @item pb.PBChangeSource (listening for connections from
2561 @code{contrib/arch_buildbot.py} run in a commit hook)
2562 @end itemize
2564 @end table
2566 All VC systems can be driven by a PBChangeSource and the
2567 @code{buildbot sendchange} tool run from some form of commit script.
2568 If you write an email parsing function, they can also all be driven by
2569 a suitable @code{MaildirSource}.
2572 @menu
2573 * Choosing ChangeSources::      
2574 * CVSToys - PBService::         
2575 * CVSToys - mail notification::  
2576 * Other mail notification ChangeSources::  
2577 * PBChangeSource::              
2578 * P4Source::                    
2579 * BonsaiPoller::                
2580 * SVNPoller::                   
2581 @end menu
2583 @node Choosing ChangeSources, CVSToys - PBService, Change Sources, Change Sources
2584 @subsection Choosing ChangeSources
2586 The @code{master.cfg} configuration file has a dictionary key named
2587 @code{BuildmasterConfig['sources']}, which holds a list of
2588 @code{IChangeSource} objects. The config file will typically create an
2589 object from one of the classes described below and stuff it into the
2590 list.
2592 @example
2593 s = FreshCVSSourceNewcred(host="host", port=4519,
2594                           user="alice", passwd="secret",
2595                           prefix="Twisted")
2596 BuildmasterConfig['sources'] = [s]
2597 @end example
2599 Each source tree has a nominal @code{top}. Each Change has a list of
2600 filenames, which are all relative to this top location. The
2601 ChangeSource is responsible for doing whatever is necessary to
2602 accomplish this. Most sources have a @code{prefix} argument: a partial
2603 pathname which is stripped from the front of all filenames provided to
2604 that @code{ChangeSource}. Files which are outside this sub-tree are
2605 ignored by the changesource: it does not generate Changes for those
2606 files.
2609 @node CVSToys - PBService, CVSToys - mail notification, Choosing ChangeSources, Change Sources
2610 @subsection CVSToys - PBService
2612 @csindex buildbot.changes.freshcvs.FreshCVSSource
2614 The @uref{http://purl.net/net/CVSToys, CVSToys} package provides a
2615 server which runs on the machine that hosts the CVS repository it
2616 watches. It has a variety of ways to distribute commit notifications,
2617 and offers a flexible regexp-based way to filter out uninteresting
2618 changes. One of the notification options is named @code{PBService} and
2619 works by listening on a TCP port for clients. These clients subscribe
2620 to hear about commit notifications.
2622 The buildmaster has a CVSToys-compatible @code{PBService} client built
2623 in. There are two versions of it, one for old versions of CVSToys
2624 (1.0.9 and earlier) which used the @code{oldcred} authentication
2625 framework, and one for newer versions (1.0.10 and later) which use
2626 @code{newcred}. Both are classes in the
2627 @code{buildbot.changes.freshcvs} package.
2629 @code{FreshCVSSourceNewcred} objects are created with the following
2630 parameters:
2632 @table @samp
2634 @item @code{host} and @code{port}
2635 these specify where the CVSToys server can be reached
2637 @item @code{user} and @code{passwd}
2638 these specify the login information for the CVSToys server
2639 (@code{freshcvs}). These must match the server's values, which are
2640 defined in the @code{freshCfg} configuration file (which lives in the
2641 CVSROOT directory of the repository).
2643 @item @code{prefix}
2644 this is the prefix to be found and stripped from filenames delivered
2645 by the CVSToys server. Most projects live in sub-directories of the
2646 main repository, as siblings of the CVSROOT sub-directory, so
2647 typically this prefix is set to that top sub-directory name.
2649 @end table
2651 @heading Example
2653 To set up the freshCVS server, add a statement like the following to
2654 your @file{freshCfg} file:
2656 @example
2657 pb = ConfigurationSet([
2658     (None, None, None, PBService(userpass=('foo', 'bar'), port=4519)),
2659     ])
2660 @end example
2662 This will announce all changes to a client which connects to port 4519
2663 using a username of 'foo' and a password of 'bar'.
2665 Then add a clause like this to your buildmaster's @file{master.cfg}:
2667 @example
2668 BuildmasterConfig['sources'] = [FreshCVSSource("cvs.example.com", 4519,
2669                                 "foo", "bar",
2670                                 prefix="glib/")]
2671 @end example
2673 where "cvs.example.com" is the host that is running the FreshCVS daemon, and
2674 "glib" is the top-level directory (relative to the repository's root) where
2675 all your source code lives. Most projects keep one or more projects in the
2676 same repository (along with CVSROOT/ to hold admin files like loginfo and
2677 freshCfg); the prefix= argument tells the buildmaster to ignore everything
2678 outside that directory, and to strip that common prefix from all pathnames
2679 it handles.
2683 @node CVSToys - mail notification, Other mail notification ChangeSources, CVSToys - PBService, Change Sources
2684 @subsection CVSToys - mail notification
2686 @csindex buildbot.changes.mail.FCMaildirSource
2688 CVSToys also provides a @code{MailNotification} action which will send
2689 email to a list of recipients for each commit. This tends to work
2690 better than using @code{/bin/mail} from within the CVSROOT/loginfo
2691 file directly, as CVSToys will batch together all files changed during
2692 the same CVS invocation, and can provide more information (like
2693 creating a ViewCVS URL for each file changed).
2695 The Buildbot's @code{FCMaildirSource} is a ChangeSource which knows
2696 how to parse these CVSToys messages and turn them into Change objects.
2697 It watches a Maildir for new messages. The usually installation
2698 process looks like:
2700 @enumerate
2701 @item
2702 Create a mailing list, @code{projectname-commits}.
2703 @item
2704 In CVSToys' freshCfg file, use a @code{MailNotification} action to
2705 send commit mail to this mailing list.
2706 @item
2707 Subscribe the buildbot user to the mailing list.
2708 @item
2709 Configure your .qmail or .forward file to deliver these messages into
2710 a maildir.
2711 @item
2712 In the Buildbot's master.cfg file, use a @code{FCMaildirSource} to
2713 watch the maildir for commit messages.
2714 @end enumerate
2716 The @code{FCMaildirSource} is created with two parameters: the
2717 directory name of the maildir root, and the prefix to strip.
2719 @node Other mail notification ChangeSources, PBChangeSource, CVSToys - mail notification, Change Sources
2720 @subsection Other mail notification ChangeSources
2722 @csindex buildbot.changes.mail.SyncmailMaildirSource
2723 @csindex buildbot.changes.mail.BonsaiMaildirSource
2725 There are other types of maildir-watching ChangeSources, which only
2726 differ in the function used to parse the message body.
2728 @code{SyncmailMaildirSource} knows how to parse the message format
2729 used in mail sent by Syncmail.
2731 @code{BonsaiMaildirSource} parses messages sent out by Bonsai.
2733 @node PBChangeSource, P4Source, Other mail notification ChangeSources, Change Sources
2734 @subsection PBChangeSource
2736 @csindex buildbot.changes.pb.PBChangeSource
2738 The last kind of ChangeSource actually listens on a TCP port for
2739 clients to connect and push change notices @emph{into} the
2740 Buildmaster. This is used by the built-in @code{buildbot sendchange}
2741 notification tool, as well as the VC-specific
2742 @file{contrib/svn_buildbot.py} and @file{contrib/arch_buildbot.py}
2743 tools. These tools are run by the repository (in a commit hook
2744 script), and connect to the buildmaster directly each time a file is
2745 comitted. This is also useful for creating new kinds of change sources
2746 that work on a @code{push} model instead of some kind of subscription
2747 scheme, for example a script which is run out of an email .forward
2748 file.
2750 This ChangeSource can be configured to listen on its own TCP port, or
2751 it can share the port that the buildmaster is already using for the
2752 buildslaves to connect. (This is possible because the
2753 @code{PBChangeSource} uses the same protocol as the buildslaves, and
2754 they can be distinguished by the @code{username} attribute used when
2755 the initial connection is established). It might be useful to have it
2756 listen on a different port if, for example, you wanted to establish
2757 different firewall rules for that port. You could allow only the SVN
2758 repository machine access to the @code{PBChangeSource} port, while
2759 allowing only the buildslave machines access to the slave port. Or you
2760 could just expose one port and run everything over it. @emph{Note:
2761 this feature is not yet implemented, the PBChangeSource will always
2762 share the slave port and will always have a @code{user} name of
2763 @code{change}, and a passwd of @code{changepw}. These limitations will
2764 be removed in the future.}.
2767 The @code{PBChangeSource} is created with the following arguments. All
2768 are optional.
2770 @table @samp
2771 @item @code{port}
2772 which port to listen on. If @code{None} (which is the default), it
2773 shares the port used for buildslave connections. @emph{Not
2774 Implemented, always set to @code{None}}.
2776 @item @code{user} and @code{passwd}
2777 The user/passwd account information that the client program must use
2778 to connect. Defaults to @code{change} and @code{changepw}. @emph{Not
2779 Implemented, @code{user} is currently always set to @code{change},
2780 @code{passwd} is always set to @code{changepw}}.
2782 @item @code{prefix}
2783 The prefix to be found and stripped from filenames delivered over the
2784 connection. Any filenames which do not start with this prefix will be
2785 removed. If all the filenames in a given Change are removed, the that
2786 whole Change will be dropped. This string should probably end with a
2787 directory separator.
2789 This is useful for changes coming from version control systems that
2790 represent branches as parent directories within the repository (like
2791 SVN and Perforce). Use a prefix of 'trunk/' or
2792 'project/branches/foobranch/' to only follow one branch and to get
2793 correct tree-relative filenames. Without a prefix, the PBChangeSource
2794 will probably deliver Changes with filenames like @file{trunk/foo.c}
2795 instead of just @file{foo.c}. Of course this also depends upon the
2796 tool sending the Changes in (like @command{buildbot sendchange}) and
2797 what filenames it is delivering: that tool may be filtering and
2798 stripping prefixes at the sending end.
2800 @end table
2802 @node P4Source, BonsaiPoller, PBChangeSource, Change Sources
2803 @subsection P4Source
2805 @csindex buildbot.changes.p4poller.P4Source
2807 The @code{P4Source} periodically polls a @uref{http://www.perforce.com/,
2808 Perforce} depot for changes. It accepts the following arguments:
2810 @table @samp
2811 @item @code{p4base}
2812 The base depot path to watch, without the trailing '/...'.
2814 @item @code{p4port}
2815 The Perforce server to connect to (as host:port).
2817 @item @code{p4user}
2818 The Perforce user.
2820 @item @code{p4passwd}
2821 The Perforce password.
2823 @item @code{split_file}
2824 A function that maps a pathname, without the leading @code{p4base}, to a
2825 (branch, filename) tuple. The default just returns (None, branchfile),
2826 which effectively disables branch support. You should supply a function
2827 which understands your repository structure.
2829 @item @code{pollinterval}
2830 How often to poll, in seconds. Defaults to 600 (10 minutes).
2832 @item @code{histmax}
2833 The maximum number of changes to inspect at a time. If more than this
2834 number occur since the last poll, older changes will be silently
2835 ignored.
2836 @end table
2838 @heading Example
2840 This configuration uses the @code{P4PORT}, @code{P4USER}, and @code{P4PASSWD}
2841 specified in the buildmaster's environment. It watches a project in which the
2842 branch name is simply the next path component, and the file is all path
2843 components after.
2845 @example
2846 import buildbot.changes.p4poller
2847 c['sources'].append(p4poller.P4Source(
2848         p4base='//depot/project/',
2849         split_file=lambda branchfile: branchfile.split('/',1)
2851 @end example
2853 @node BonsaiPoller, SVNPoller, P4Source, Change Sources
2854 @subsection BonsaiPoller
2856 @csindex buildbot.changes.bonsaipoller.BonsaiPoller
2858 The @code{BonsaiPoller} periodically polls a Bonsai server. This is a
2859 CGI script accessed through a web server that provides information
2860 about a CVS tree, for example the Mozilla bonsai server at
2861 @uref{http://bonsai.mozilla.org}. Bonsai servers are usable by both
2862 humans and machines. In this case, the buildbot's change source forms
2863 a query which asks about any files in the specified branch which have
2864 changed since the last query.
2866 Please take a look at the BonsaiPoller docstring for details about the
2867 arguments it accepts.
2870 @node SVNPoller,  , BonsaiPoller, Change Sources
2871 @subsection SVNPoller
2873 @csindex buildbot.changes.svnpoller.SVNPoller
2875 The @code{buildbot.changes.svnpoller.SVNPoller} is a ChangeSource
2876 which periodically polls a @uref{http://subversion.tigris.org/,
2877 Subversion} repository for new revisions, by running the @code{svn
2878 log} command in a subshell. It can watch a single branch or multiple
2879 branches.
2881 @code{SVNPoller} accepts the following arguments:
2883 @table @code
2884 @item svnurl
2885 The base URL path to watch, like
2886 @code{svn://svn.twistedmatrix.com/svn/Twisted/trunk}, or
2887 @code{http://divmod.org/svn/Divmod/}, or even
2888 @code{file:///home/svn/Repository/ProjectA/branches/1.5/}. This must
2889 include the access scheme, the location of the repository (both the
2890 hostname for remote ones, and any additional directory names necessary
2891 to get to the repository), and the sub-path within the repository's
2892 virtual filesystem for the project and branch of interest.
2894 The @code{SVNPoller} will only pay attention to files inside the
2895 subdirectory specified by the complete svnurl.
2897 @item split_file
2898 A function to convert pathnames into (branch, relative_pathname)
2899 tuples. Use this to explain your repository's branch-naming policy to
2900 @code{SVNPoller}. This function must accept a single string and return
2901 a two-entry tuple. There are a few utility functions in
2902 @code{buildbot.changes.svnpoller} that can be used as a
2903 @code{split_file} function, see below for details.
2905 The default value always returns (None, path), which indicates that
2906 all files are on the trunk.
2908 Subclasses of @code{SVNPoller} can override the @code{split_file}
2909 method instead of using the @code{split_file=} argument.
2911 @item svnuser
2912 An optional string parameter. If set, the @code{--user} argument will
2913 be added to all @code{svn} commands. Use this if you have to
2914 authenticate to the svn server before you can do @code{svn info} or
2915 @code{svn log} commands.
2917 @item svnpasswd
2918 Like @code{svnuser}, this will cause a @code{--password} argument to
2919 be passed to all svn commands.
2921 @item pollinterval
2922 How often to poll, in seconds. Defaults to 600 (checking once every 10
2923 minutes). Lower this if you want the buildbot to notice changes
2924 faster, raise it if you want to reduce the network and CPU load on
2925 your svn server. Please be considerate of public SVN repositories by
2926 using a large interval when polling them.
2928 @item histmax
2929 The maximum number of changes to inspect at a time. Every POLLINTERVAL
2930 seconds, the @code{SVNPoller} asks for the last HISTMAX changes and
2931 looks through them for any ones it does not already know about. If
2932 more than HISTMAX revisions have been committed since the last poll,
2933 older changes will be silently ignored. Larger values of histmax will
2934 cause more time and memory to be consumed on each poll attempt.
2935 @code{histmax} defaults to 100.
2937 @item svnbin
2938 This controls the @code{svn} executable to use. If subversion is
2939 installed in a weird place on your system (outside of the
2940 buildmaster's @code{$PATH}), use this to tell @code{SVNPoller} where
2941 to find it. The default value of ``svn'' will almost always be
2942 sufficient.
2944 @end table
2946 @heading Branches
2948 Each source file that is tracked by a Subversion repository has a
2949 fully-qualified SVN URL in the following form:
2950 (REPOURL)(PROJECT-plus-BRANCH)(FILEPATH). When you create the
2951 @code{SVNPoller}, you give it a @code{svnurl} value that includes all
2952 of the REPOURL and possibly some portion of the PROJECT-plus-BRANCH
2953 string. The @code{SVNPoller} is responsible for producing Changes that
2954 contain a branch name and a FILEPATH (which is relative to the top of
2955 a checked-out tree). The details of how these strings are split up
2956 depend upon how your repository names its branches.
2958 @subheading PROJECT/BRANCHNAME/FILEPATH repositories
2960 One common layout is to have all the various projects that share a
2961 repository get a single top-level directory each. Then under a given
2962 project's directory, you get two subdirectories, one named ``trunk''
2963 and another named ``branches''. Under ``branches'' you have a bunch of
2964 other directories, one per branch, with names like ``1.5.x'' and
2965 ``testing''. It is also common to see directories like ``tags'' and
2966 ``releases'' next to ``branches'' and ``trunk''.
2968 For example, the Twisted project has a subversion server on
2969 ``svn.twistedmatrix.com'' that hosts several sub-projects. The
2970 repository is available through a SCHEME of ``svn:''. The primary
2971 sub-project is Twisted, of course, with a repository root of
2972 ``svn://svn.twistedmatrix.com/svn/Twisted''. Another sub-project is
2973 Informant, with a root of
2974 ``svn://svn.twistedmatrix.com/svn/Informant'', etc. Inside any
2975 checked-out Twisted tree, there is a file named bin/trial (which is
2976 used to run unit test suites).
2978 The trunk for Twisted is in
2979 ``svn://svn.twistedmatrix.com/svn/Twisted/trunk'', and the
2980 fully-qualified SVN URL for the trunk version of @code{trial} would be
2981 ``svn://svn.twistedmatrix.com/svn/Twisted/trunk/bin/trial''. The same
2982 SVNURL for that file on a branch named ``1.5.x'' would be
2983 ``svn://svn.twistedmatrix.com/svn/Twisted/branches/1.5.x/bin/trial''.
2985 To set up a @code{SVNPoller} that watches the Twisted trunk (and
2986 nothing else), we would use the following:
2988 @example
2989 from buildbot.changes.svnpoller import SVNPoller
2990 s = SVNPoller("svn://svn.twistedmatrix.com/svn/Twisted/trunk")
2991 c['sources'].append(ss)
2992 @end example
2994 In this case, every Change that our @code{SVNPoller} produces will
2995 have @code{.branch=None}, to indicate that the Change is on the trunk.
2996 No other sub-projects or branches will be tracked.
2998 If we want our ChangeSource to follow multiple branches, we have to do
2999 two things. First we have to change our @code{svnurl=} argument to
3000 watch more than just ``.../Twisted/trunk''. We will set it to
3001 ``.../Twisted'' so that we'll see both the trunk and all the branches.
3002 Second, we have to tell @code{SVNPoller} how to split the
3003 (PROJECT-plus-BRANCH)(FILEPATH) strings it gets from the repository
3004 out into (BRANCH) and (FILEPATH) pairs.
3006 We do the latter by providing a ``split_file'' function. This function
3007 is responsible for splitting something like
3008 ``branches/1.5.x/bin/trial'' into @code{branch}=''branches/1.5.x'' and
3009 @code{filepath}=''bin/trial''. This function is always given a string
3010 that names a file relative to the subdirectory pointed to by the
3011 @code{SVNPoller}'s @code{svnurl=} argument. It is expected to return a
3012 (BRANCHNAME, FILEPATH) tuple (in which FILEPATH is relative to the
3013 branch indicated), or None to indicate that the file is outside any
3014 project of interest.
3016 (note that we want to see ``branches/1.5.x'' rather than just
3017 ``1.5.x'' because when we perform the SVN checkout, we will probably
3018 append the branch name to the baseURL, which requires that we keep the
3019 ``branches'' component in there. Other VC schemes use a different
3020 approach towards branches and may not require this artifact.)
3022 If your repository uses this same PROJECT/BRANCH/FILEPATH naming
3023 scheme, the following function will work:
3025 @example
3026 def split_file_branches(path):
3027     pieces = path.split('/')
3028     if pieces[0] == 'trunk':
3029         return (None, '/'.join(pieces[1:]))
3030     elif pieces[0] == 'branches':
3031         return ('/'.join(pieces[0:2]),
3032                 '/'.join(pieces[2:]))
3033     else:
3034         return None
3035 @end example
3037 This function is provided as
3038 @code{buildbot.changes.svnpoller.split_file_branches} for your
3039 convenience. So to have our Twisted-watching @code{SVNPoller} follow
3040 multiple branches, we would use this:
3042 @example
3043 from buildbot.changes.svnpoller import SVNPoller, split_file_branches
3044 s = SVNPoller("svn://svn.twistedmatrix.com/svn/Twisted",
3045               split_file=split_file_branches)
3046 c['sources'].append(ss)
3047 @end example
3049 Changes for all sorts of branches (with names like ``branches/1.5.x'',
3050 and None to indicate the trunk) will be delivered to the Schedulers.
3051 Each Scheduler is then free to use or ignore each branch as it sees
3052 fit.
3054 @subheading BRANCHNAME/PROJECT/FILEPATH repositories
3056 Another common way to organize a Subversion repository is to put the
3057 branch name at the top, and the projects underneath. This is
3058 especially frequent when there are a number of related sub-projects
3059 that all get released in a group.
3061 For example, Divmod.org hosts a project named ``Nevow'' as well as one
3062 named ``Quotient''. In a checked-out Nevow tree there is a directory
3063 named ``formless'' that contains a python source file named
3064 ``webform.py''. This repository is accessible via webdav (and thus
3065 uses an ``http:'' scheme) through the divmod.org hostname. There are
3066 many branches in this repository, and they use a
3067 (BRANCHNAME)/(PROJECT) naming policy.
3069 The fully-qualified SVN URL for the trunk version of webform.py is
3070 @code{http://divmod.org/svn/Divmod/trunk/Nevow/formless/webform.py}.
3071 You can do an @code{svn co} with that URL and get a copy of the latest
3072 version. The 1.5.x branch version of this file would have a URL of
3073 @code{http://divmod.org/svn/Divmod/branches/1.5.x/Nevow/formless/webform.py}.
3074 The whole Nevow trunk would be checked out with
3075 @code{http://divmod.org/svn/Divmod/trunk/Nevow}, while the Quotient
3076 trunk would be checked out using
3077 @code{http://divmod.org/svn/Divmod/trunk/Quotient}.
3079 Now suppose we want to have an @code{SVNPoller} that only cares about
3080 the Nevow trunk. This case looks just like the PROJECT/BRANCH layout
3081 described earlier:
3083 @example
3084 from buildbot.changes.svnpoller import SVNPoller
3085 s = SVNPoller("http://divmod.org/svn/Divmod/trunk/Nevow")
3086 c['sources'].append(ss)
3087 @end example
3089 But what happens when we want to track multiple Nevow branches? We
3090 have to point our @code{svnurl=} high enough to see all those
3091 branches, but we also don't want to include Quotient changes (since
3092 we're only building Nevow). To accomplish this, we must rely upon the
3093 @code{split_file} function to help us tell the difference between
3094 files that belong to Nevow and those that belong to Quotient, as well
3095 as figuring out which branch each one is on.
3097 @example
3098 from buildbot.changes.svnpoller import SVNPoller
3099 s = SVNPoller("http://divmod.org/svn/Divmod",
3100               split_file=my_file_splitter)
3101 c['sources'].append(ss)
3102 @end example
3104 The @code{my_file_splitter} function will be called with
3105 repository-relative pathnames like:
3107 @table @code
3108 @item trunk/Nevow/formless/webform.py
3109 This is a Nevow file, on the trunk. We want the Change that includes this
3110 to see a filename of @code{formless/webform.py"}, and a branch of None
3112 @item branches/1.5.x/Nevow/formless/webform.py
3113 This is a Nevow file, on a branch. We want to get
3114 branch=''branches/1.5.x'' and filename=''formless/webform.py''.
3116 @item trunk/Quotient/setup.py
3117 This is a Quotient file, so we want to ignore it by having
3118 @code{my_file_splitter} return None.
3120 @item branches/1.5.x/Quotient/setup.py
3121 This is also a Quotient file, which should be ignored.
3122 @end table
3124 The following definition for @code{my_file_splitter} will do the job:
3126 @example
3127 def my_file_splitter(path):
3128     pieces = path.split('/')
3129     if pieces[0] == 'trunk':
3130         branch = None
3131         pieces.pop(0) # remove 'trunk'
3132     elif pieces[0] == 'branches':
3133         pieces.pop(0) # remove 'branches'
3134         # grab branch name
3135         branch = 'branches/' + pieces.pop(0)
3136     else:
3137         return None # something weird
3138     projectname = pieces.pop(0)
3139     if projectname != 'Nevow':
3140         return None # wrong project
3141     return (branch, '/'.join(pieces))
3142 @end example
3145 @node Build Process, Status Delivery, Getting Source Code Changes, Top
3146 @chapter Build Process
3148 A @code{Build} object is responsible for actually performing a build.
3149 It gets access to a remote @code{SlaveBuilder} where it may run
3150 commands, and a @code{BuildStatus} object where it must emit status
3151 events. The @code{Build} is created by the Builder's
3152 @code{BuildFactory}.
3154 The default @code{Build} class is made up of a fixed sequence of
3155 @code{BuildSteps}, executed one after another until all are complete
3156 (or one of them indicates that the build should be halted early). The
3157 default @code{BuildFactory} creates instances of this @code{Build}
3158 class with a list of @code{BuildSteps}, so the basic way to configure
3159 the build is to provide a list of @code{BuildSteps} to your
3160 @code{BuildFactory}.
3162 More complicated @code{Build} subclasses can make other decisions:
3163 execute some steps only if certain files were changed, or if certain
3164 previous steps passed or failed. The base class has been written to
3165 allow users to express basic control flow without writing code, but
3166 you can always subclass and customize to achieve more specialized
3167 behavior.
3169 @menu
3170 * Build Steps::                 
3171 * Interlocks::                  
3172 * Build Factories::             
3173 @end menu
3175 @node Build Steps, Interlocks, Build Process, Build Process
3176 @section Build Steps
3178 @code{BuildStep}s are usually specified in the buildmaster's
3179 configuration file, in a list of ``step specifications'' that is used
3180 to create the @code{BuildFactory}. These ``step specifications'' are
3181 not actual steps, but rather a tuple of the @code{BuildStep} subclass
3182 to be created and a dictionary of arguments. (the actual
3183 @code{BuildStep} instances are not created until the Build is started,
3184 so that each Build gets an independent copy of each BuildStep). The
3185 preferred way to create these step specifications is with the
3186 @code{BuildFactory}'s @code{addStep} method:
3188 @example
3189 from buildbot.steps import source, shell
3190 from buildbot.process import factory
3192 f = factory.BuildFactory()
3193 f.addStep(source.SVN, svnurl="http://svn.example.org/Trunk/")
3194 f.addStep(shell.ShellCommand, command=["make", "all"])
3195 f.addStep(shell.ShellCommand, command=["make", "test"])
3196 @end example
3198 The rest of this section lists all the standard BuildStep objects
3199 available for use in a Build, and the parameters which can be used to
3200 control each.
3202 @menu
3203 * Common Parameters::           
3204 * Source Checkout::             
3205 * ShellCommand::                
3206 * Simple ShellCommand Subclasses::  
3207 * Python BuildSteps::           
3208 * Transferring Files::          
3209 * Writing New BuildSteps::      
3210 @end menu
3212 @node Common Parameters, Source Checkout, Build Steps, Build Steps
3213 @subsection Common Parameters
3215 The standard @code{Build} runs a series of @code{BuildStep}s in order,
3216 only stopping when it runs out of steps or if one of them requests
3217 that the build be halted. It collects status information from each one
3218 to create an overall build status (of SUCCESS, WARNINGS, or FAILURE).
3220 All BuildSteps accept some common parameters. Some of these control
3221 how their individual status affects the overall build. Others are used
3222 to specify which @code{Locks} (see @pxref{Interlocks}) should be
3223 acquired before allowing the step to run.
3225 Arguments common to all @code{BuildStep} subclasses:
3228 @table @code
3229 @item name
3230 the name used to describe the step on the status display. It is also
3231 used to give a name to any LogFiles created by this step.
3233 @item haltOnFailure
3234 if True, a FAILURE of this build step will cause the build to halt
3235 immediately with an overall result of FAILURE.
3237 @item flunkOnWarnings
3238 when True, a WARNINGS or FAILURE of this build step will mark the
3239 overall build as FAILURE. The remaining steps will still be executed.
3241 @item flunkOnFailure
3242 when True, a FAILURE of this build step will mark the overall build as
3243 a FAILURE. The remaining steps will still be executed.
3245 @item warnOnWarnings
3246 when True, a WARNINGS or FAILURE of this build step will mark the
3247 overall build as having WARNINGS. The remaining steps will still be
3248 executed.
3250 @item warnOnFailure
3251 when True, a FAILURE of this build step will mark the overall build as
3252 having WARNINGS. The remaining steps will still be executed.
3254 @item locks
3255 a list of Locks (instances of @code{buildbot.locks.SlaveLock} or
3256 @code{buildbot.locks.MasterLock}) that should be acquired before
3257 starting this Step. The Locks will be released when the step is
3258 complete. Note that this is a list of actual Lock instances, not
3259 names. Also note that all Locks must have unique names.
3261 @end table
3264 @node Source Checkout, ShellCommand, Common Parameters, Build Steps
3265 @subsection Source Checkout
3267 The first step of any build is typically to acquire the source code
3268 from which the build will be performed. There are several classes to
3269 handle this, one for each of the different source control system that
3270 Buildbot knows about. For a description of how Buildbot treats source
3271 control in general, see @ref{Version Control Systems}.
3273 All source checkout steps accept some common parameters to control how
3274 they get the sources and where they should be placed. The remaining
3275 per-VC-system parameters are mostly to specify where exactly the
3276 sources are coming from.
3278 @table @code
3279 @item mode
3281 a string describing the kind of VC operation that is desired. Defaults
3282 to @code{update}.
3284 @table @code
3285 @item update
3286 specifies that the CVS checkout/update should be performed directly
3287 into the workdir. Each build is performed in the same directory,
3288 allowing for incremental builds. This minimizes disk space, bandwidth,
3289 and CPU time. However, it may encounter problems if the build process
3290 does not handle dependencies properly (sometimes you must do a ``clean
3291 build'' to make sure everything gets compiled), or if source files are
3292 deleted but generated files can influence test behavior (e.g. python's
3293 .pyc files), or when source directories are deleted but generated
3294 files prevent CVS from removing them. Builds ought to be correct
3295 regardless of whether they are done ``from scratch'' or incrementally,
3296 but it is useful to test both kinds: this mode exercises the
3297 incremental-build style.
3299 @item copy
3300 specifies that the CVS workspace should be maintained in a separate
3301 directory (called the 'copydir'), using checkout or update as
3302 necessary. For each build, a new workdir is created with a copy of the
3303 source tree (rm -rf workdir; cp -r copydir workdir). This doubles the
3304 disk space required, but keeps the bandwidth low (update instead of a
3305 full checkout). A full 'clean' build is performed each time. This
3306 avoids any generated-file build problems, but is still occasionally
3307 vulnerable to CVS problems such as a repository being manually
3308 rearranged, causing CVS errors on update which are not an issue with a
3309 full checkout.
3311 @c TODO: something is screwy about this, revisit. Is it the source
3312 @c directory or the working directory that is deleted each time?
3314 @item clobber
3315 specifes that the working directory should be deleted each time,
3316 necessitating a full checkout for each build. This insures a clean
3317 build off a complete checkout, avoiding any of the problems described
3318 above. This mode exercises the ``from-scratch'' build style.
3320 @item export
3321 this is like @code{clobber}, except that the 'cvs export' command is
3322 used to create the working directory. This command removes all CVS
3323 metadata files (the CVS/ directories) from the tree, which is
3324 sometimes useful for creating source tarballs (to avoid including the
3325 metadata in the tar file).
3326 @end table
3328 @item workdir
3329 like all Steps, this indicates the directory where the build will take
3330 place. Source Steps are special in that they perform some operations
3331 outside of the workdir (like creating the workdir itself).
3333 @item alwaysUseLatest
3334 if True, bypass the usual ``update to the last Change'' behavior, and
3335 always update to the latest changes instead.
3337 @item retry
3338 If set, this specifies a tuple of @code{(delay, repeats)} which means
3339 that when a full VC checkout fails, it should be retried up to
3340 @var{repeats} times, waiting @var{delay} seconds between attempts. If
3341 you don't provide this, it defaults to @code{None}, which means VC
3342 operations should not be retried. This is provided to make life easier
3343 for buildslaves which are stuck behind poor network connections.
3345 @end table
3348 My habit as a developer is to do a @code{cvs update} and @code{make} each
3349 morning. Problems can occur, either because of bad code being checked in, or
3350 by incomplete dependencies causing a partial rebuild to fail where a
3351 complete from-scratch build might succeed. A quick Builder which emulates
3352 this incremental-build behavior would use the @code{mode='update'}
3353 setting.
3355 On the other hand, other kinds of dependency problems can cause a clean
3356 build to fail where a partial build might succeed. This frequently results
3357 from a link step that depends upon an object file that was removed from a
3358 later version of the tree: in the partial tree, the object file is still
3359 around (even though the Makefiles no longer know how to create it).
3361 ``official'' builds (traceable builds performed from a known set of
3362 source revisions) are always done as clean builds, to make sure it is
3363 not influenced by any uncontrolled factors (like leftover files from a
3364 previous build). A ``full'' Builder which behaves this way would want
3365 to use the @code{mode='clobber'} setting.
3367 Each VC system has a corresponding source checkout class: their
3368 arguments are described on the following pages.
3371 @menu
3372 * CVS::                         
3373 * SVN::                         
3374 * Darcs::                       
3375 * Mercurial::                   
3376 * Arch::                        
3377 * Bazaar::                      
3378 * Bzr::                         
3379 * P4::                          
3380 @end menu
3382 @node CVS, SVN, Source Checkout, Source Checkout
3383 @subsubsection CVS
3385 @cindex CVS Checkout
3386 @bsindex buildbot.steps.source.CVS
3389 The @code{CVS} build step performs a @uref{http://www.nongnu.org/cvs/,
3390 CVS} checkout or update. It takes the following arguments:
3392 @table @code
3393 @item cvsroot
3394 (required): specify the CVSROOT value, which points to a CVS
3395 repository, probably on a remote machine. For example, the cvsroot
3396 value you would use to get a copy of the Buildbot source code is
3397 @code{:pserver:anonymous@@cvs.sourceforge.net:/cvsroot/buildbot}
3399 @item cvsmodule
3400 (required): specify the cvs @code{module}, which is generally a
3401 subdirectory of the CVSROOT. The cvsmodule for the Buildbot source
3402 code is @code{buildbot}.
3404 @item branch
3405 a string which will be used in a @code{-r} argument. This is most
3406 useful for specifying a branch to work on. Defaults to @code{HEAD}.
3408 @item global_options
3409 a list of flags to be put before the verb in the CVS command.
3411 @item checkoutDelay
3412 if set, the number of seconds to put between the timestamp of the last
3413 known Change and the value used for the @code{-D} option. Defaults to
3414 half of the parent Build's treeStableTimer.
3416 @end table
3419 @node SVN, Darcs, CVS, Source Checkout
3420 @subsubsection SVN
3422 @cindex SVN Checkout
3423 @bsindex buildbot.steps.source.SVN
3426 The @code{SVN} build step performs a
3427 @uref{http://subversion.tigris.org, Subversion} checkout or update.
3428 There are two basic ways of setting up the checkout step, depending
3429 upon whether you are using multiple branches or not.
3431 If all of your builds use the same branch, then you should create the
3432 @code{SVN} step with the @code{svnurl} argument:
3434 @table @code
3435 @item svnurl
3436 (required): this specifies the @code{URL} argument that will be given
3437 to the @code{svn checkout} command. It dictates both where the
3438 repository is located and which sub-tree should be extracted. In this
3439 respect, it is like a combination of the CVS @code{cvsroot} and
3440 @code{cvsmodule} arguments. For example, if you are using a remote
3441 Subversion repository which is accessible through HTTP at a URL of
3442 @code{http://svn.example.com/repos}, and you wanted to check out the
3443 @code{trunk/calc} sub-tree, you would use
3444 @code{svnurl="http://svn.example.com/repos/trunk/calc"} as an argument
3445 to your @code{SVN} step.
3446 @end table
3448 If, on the other hand, you are building from multiple branches, then
3449 you should create the @code{SVN} step with the @code{baseURL} and
3450 @code{defaultBranch} arguments instead:
3452 @table @code
3453 @item baseURL
3454 (required): this specifies the base repository URL, to which a branch
3455 name will be appended. It should probably end in a slash.
3457 @item defaultBranch
3458 this specifies the name of the branch to use when a Build does not
3459 provide one of its own. This will be appended to @code{baseURL} to
3460 create the string that will be passed to the @code{svn checkout}
3461 command.
3462 @end table
3464 If you are using branches, you must also make sure your
3465 @code{ChangeSource} will report the correct branch names.
3467 @heading branch example
3469 Let's suppose that the ``MyProject'' repository uses branches for the
3470 trunk, for various users' individual development efforts, and for
3471 several new features that will require some amount of work (involving
3472 multiple developers) before they are ready to merge onto the trunk.
3473 Such a repository might be organized as follows:
3475 @example
3476 svn://svn.example.org/MyProject/trunk
3477 svn://svn.example.org/MyProject/branches/User1/foo
3478 svn://svn.example.org/MyProject/branches/User1/bar
3479 svn://svn.example.org/MyProject/branches/User2/baz
3480 svn://svn.example.org/MyProject/features/newthing
3481 svn://svn.example.org/MyProject/features/otherthing
3482 @end example
3484 Further assume that we want the Buildbot to run tests against the
3485 trunk and against all the feature branches (i.e., do a
3486 checkout/compile/build of branch X when a file has been changed on
3487 branch X, when X is in the set [trunk, features/newthing,
3488 features/otherthing]). We do not want the Buildbot to automatically
3489 build any of the user branches, but it should be willing to build a
3490 user branch when explicitly requested (most likely by the user who
3491 owns that branch).
3493 There are three things that need to be set up to accomodate this
3494 system. The first is a ChangeSource that is capable of identifying the
3495 branch which owns any given file. This depends upon a user-supplied
3496 function, in an external program that runs in the SVN commit hook and
3497 connects to the buildmaster's @code{PBChangeSource} over a TCP
3498 connection. (you can use the ``@code{buildbot sendchange}'' utility
3499 for this purpose, but you will still need an external program to
3500 decide what value should be passed to the @code{--branch=} argument).
3501 For example, a change to a file with the SVN url of
3502 ``svn://svn.example.org/MyProject/features/newthing/src/foo.c'' should
3503 be broken down into a Change instance with
3504 @code{branch='features/newthing'} and @code{file='src/foo.c'}.
3506 The second piece is an @code{AnyBranchScheduler} which will pay
3507 attention to the desired branches. It will not pay attention to the
3508 user branches, so it will not automatically start builds in response
3509 to changes there. The AnyBranchScheduler class requires you to
3510 explicitly list all the branches you want it to use, but it would not
3511 be difficult to write a subclass which used
3512 @code{branch.startswith('features/'} to remove the need for this
3513 explicit list. Or, if you want to build user branches too, you can use
3514 AnyBranchScheduler with @code{branches=None} to indicate that you want
3515 it to pay attention to all branches.
3517 The third piece is an @code{SVN} checkout step that is configured to
3518 handle the branches correctly, with a @code{baseURL} value that
3519 matches the way the ChangeSource splits each file's URL into base,
3520 branch, and file.
3522 @example
3523 from buildbot.changes.pb import PBChangeSource
3524 from buildbot.scheduler import AnyBranchScheduler
3525 from buildbot.process import source, factory
3526 from buildbot.steps import source, shell
3528 c['sources'] = [PBChangeSource()]
3529 s1 = AnyBranchScheduler('main',
3530                         ['trunk', 'features/newthing', 'features/otherthing'],
3531                         10*60, ['test-i386', 'test-ppc'])
3532 c['schedulers'] = [s1]
3534 f = factory.BuildFactory()
3535 f.addStep(source.SVN, mode='update',
3536           baseURL='svn://svn.example.org/MyProject/',
3537           defaultBranch='trunk')
3538 f.addStep(shell.Compile, command="make all")
3539 f.addStep(shell.Test, command="make test")
3541 c['builders'] = [
3542   @{'name':'test-i386', 'slavename':'bot-i386', 'builddir':'test-i386',
3543                        'factory':f @},
3544   @{'name':'test-ppc', 'slavename':'bot-ppc', 'builddir':'test-ppc',
3545                       'factory':f @},
3547 @end example
3549 In this example, when a change arrives with a @code{branch} attribute
3550 of ``trunk'', the resulting build will have an SVN step that
3551 concatenates ``svn://svn.example.org/MyProject/'' (the baseURL) with
3552 ``trunk'' (the branch name) to get the correct svn command. If the
3553 ``newthing'' branch has a change to ``src/foo.c'', then the SVN step
3554 will concatenate ``svn://svn.example.org/MyProject/'' with
3555 ``features/newthing'' to get the svnurl for checkout.
3557 @node Darcs, Mercurial, SVN, Source Checkout
3558 @subsubsection Darcs
3560 @cindex Darcs Checkout
3561 @bsindex buildbot.steps.source.Darcs
3564 The @code{Darcs} build step performs a
3565 @uref{http://abridgegame.org/darcs/, Darcs} checkout or update.
3567 Like @xref{SVN}, this step can either be configured to always check
3568 out a specific tree, or set up to pull from a particular branch that
3569 gets specified separately for each build. Also like SVN, the
3570 repository URL given to Darcs is created by concatenating a
3571 @code{baseURL} with the branch name, and if no particular branch is
3572 requested, it uses a @code{defaultBranch}. The only difference in
3573 usage is that each potential Darcs repository URL must point to a
3574 fully-fledged repository, whereas SVN URLs usually point to sub-trees
3575 of the main Subversion repository. In other words, doing an SVN
3576 checkout of @code{baseURL} is legal, but silly, since you'd probably
3577 wind up with a copy of every single branch in the whole repository.
3578 Doing a Darcs checkout of @code{baseURL} is just plain wrong, since
3579 the parent directory of a collection of Darcs repositories is not
3580 itself a valid repository.
3582 The Darcs step takes the following arguments:
3584 @table @code
3585 @item repourl
3586 (required unless @code{baseURL} is provided): the URL at which the
3587 Darcs source repository is available.
3589 @item baseURL
3590 (required unless @code{repourl} is provided): the base repository URL,
3591 to which a branch name will be appended. It should probably end in a
3592 slash.
3594 @item defaultBranch
3595 (allowed if and only if @code{baseURL} is provided): this specifies
3596 the name of the branch to use when a Build does not provide one of its
3597 own. This will be appended to @code{baseURL} to create the string that
3598 will be passed to the @code{darcs get} command.
3599 @end table
3601 @node Mercurial, Arch, Darcs, Source Checkout
3602 @subsubsection Mercurial
3604 @cindex Mercurial Checkout
3605 @bsindex buildbot.steps.source.Mercurial
3608 The @code{Mercurial} build step performs a
3609 @uref{http://selenic.com/mercurial, Mercurial} (aka ``hg'') checkout
3610 or update.
3612 Branches are handled just like @xref{Darcs}.
3614 The Mercurial step takes the following arguments:
3616 @table @code
3617 @item repourl
3618 (required unless @code{baseURL} is provided): the URL at which the
3619 Mercurial source repository is available.
3621 @item baseURL
3622 (required unless @code{repourl} is provided): the base repository URL,
3623 to which a branch name will be appended. It should probably end in a
3624 slash.
3626 @item defaultBranch
3627 (allowed if and only if @code{baseURL} is provided): this specifies
3628 the name of the branch to use when a Build does not provide one of its
3629 own. This will be appended to @code{baseURL} to create the string that
3630 will be passed to the @code{hg clone} command.
3631 @end table
3634 @node Arch, Bazaar, Mercurial, Source Checkout
3635 @subsubsection Arch
3637 @cindex Arch Checkout
3638 @bsindex buildbot.steps.source.Arch
3641 The @code{Arch} build step performs an @uref{http://gnuarch.org/,
3642 Arch} checkout or update using the @code{tla} client. It takes the
3643 following arguments:
3645 @table @code
3646 @item url
3647 (required): this specifies the URL at which the Arch source archive is
3648 available.
3650 @item version
3651 (required): this specifies which ``development line'' (like a branch)
3652 should be used. This provides the default branch name, but individual
3653 builds may specify a different one.
3655 @item archive
3656 (optional): Each repository knows its own archive name. If this
3657 parameter is provided, it must match the repository's archive name.
3658 The parameter is accepted for compatibility with the @code{Bazaar}
3659 step, below.
3661 @end table
3663 @node Bazaar, Bzr, Arch, Source Checkout
3664 @subsubsection Bazaar
3666 @cindex Bazaar Checkout
3667 @bsindex buildbot.steps.source.Bazaar
3670 @code{Bazaar} is an alternate implementation of the Arch VC system,
3671 which uses a client named @code{baz}. The checkout semantics are just
3672 different enough from @code{tla} that there is a separate BuildStep for
3675 It takes exactly the same arguments as @code{Arch}, except that the
3676 @code{archive=} parameter is required. (baz does not emit the archive
3677 name when you do @code{baz register-archive}, so we must provide it
3678 ourselves).
3681 @node Bzr, P4, Bazaar, Source Checkout
3682 @subsubsection Bzr
3684 @cindex Bzr Checkout
3685 @bsindex buildbot.steps.source.Bzr
3687 @code{bzr} is a descendant of Arch/Baz, and is frequently referred to
3688 as simply ``Bazaar''. The repository-vs-workspace model is similar to
3689 Darcs, but it uses a strictly linear sequence of revisions (one
3690 history per branch) like Arch. Branches are put in subdirectories.
3691 This makes it look very much like Mercurial, so it takes the same
3692 arguments:
3694 @table @code
3696 @item repourl
3697 (required unless @code{baseURL} is provided): the URL at which the
3698 Bzr source repository is available.
3700 @item baseURL
3701 (required unless @code{repourl} is provided): the base repository URL,
3702 to which a branch name will be appended. It should probably end in a
3703 slash.
3705 @item defaultBranch
3706 (allowed if and only if @code{baseURL} is provided): this specifies
3707 the name of the branch to use when a Build does not provide one of its
3708 own. This will be appended to @code{baseURL} to create the string that
3709 will be passed to the @code{bzr checkout} command.
3710 @end table
3714 @node P4,  , Bzr, Source Checkout
3715 @subsubsection P4
3717 @cindex Perforce Update
3718 @bsindex buildbot.steps.source.P4
3719 @c TODO @bsindex buildbot.steps.source.P4Sync
3722 The @code{P4} build step creates a @uref{http://www.perforce.com/,
3723 Perforce} client specification and performs an update.
3725 @table @code
3726 @item p4base
3727 A view into the Perforce depot without branch name or trailing "...".
3728 Typically "//depot/proj/".
3729 @item defaultBranch
3730 A branch name to append on build requests if none is specified.
3731 Typically "trunk".
3732 @item p4port
3733 (optional): the host:port string describing how to get to the P4 Depot
3734 (repository), used as the -p argument for all p4 commands.
3735 @item p4user
3736 (optional): the Perforce user, used as the -u argument to all p4
3737 commands.
3738 @item p4passwd
3739 (optional): the Perforce password, used as the -p argument to all p4
3740 commands.
3741 @item p4extra_views
3742 (optional): a list of (depotpath, clientpath) tuples containing extra
3743 views to be mapped into the client specification. Both will have
3744 "/..." appended automatically. The client name and source directory
3745 will be prepended to the client path.
3746 @item p4client
3747 (optional): The name of the client to use. In mode='copy' and
3748 mode='update', it's particularly important that a unique name is used
3749 for each checkout directory to avoid incorrect synchronization. For
3750 this reason, Python percent substitution will be performed on this value
3751 to replace %(slave)s with the slave name and %(builder)s with the
3752 builder name. The default is "buildbot_%(slave)s_%(build)s".
3753 @end table
3755 @node ShellCommand, Simple ShellCommand Subclasses, Source Checkout, Build Steps
3756 @subsection ShellCommand
3758 @bsindex buildbot.steps.shell.ShellCommand
3759 @c TODO @bsindex buildbot.steps.shell.TreeSize
3761 This is a useful base class for just about everything you might want
3762 to do during a build (except for the initial source checkout). It runs
3763 a single command in a child shell on the buildslave. All stdout/stderr
3764 is recorded into a LogFile. The step finishes with a status of FAILURE
3765 if the command's exit code is non-zero, otherwise it has a status of
3766 SUCCESS.
3768 The preferred way to specify the command is with a list of argv strings,
3769 since this allows for spaces in filenames and avoids doing any fragile
3770 shell-escaping. You can also specify the command with a single string, in
3771 which case the string is given to '/bin/sh -c COMMAND' for parsing.
3773 All ShellCommands are run by default in the ``workdir'', which
3774 defaults to the ``@file{build}'' subdirectory of the slave builder's
3775 base directory. The absolute path of the workdir will thus be the
3776 slave's basedir (set as an option to @code{buildbot create-slave},
3777 @pxref{Creating a buildslave}) plus the builder's basedir (set in the
3778 builder's @code{c['builddir']} key in master.cfg) plus the workdir
3779 itself (a class-level attribute of the BuildFactory, defaults to
3780 ``@file{build}'').
3782 @code{ShellCommand} arguments:
3784 @table @code
3785 @item command
3786 a list of strings (preferred) or single string (discouraged) which
3787 specifies the command to be run. A list of strings is preferred
3788 because it can be used directly as an argv array. Using a single
3789 string (with embedded spaces) requires the buildslave to pass the
3790 string to /bin/sh for interpretation, which raises all sorts of
3791 difficult questions about how to escape or interpret shell
3792 metacharacters.
3794 @item env
3795 a dictionary of environment strings which will be added to the child
3796 command's environment. For example, to run tests with a different i18n
3797 language setting, you might use
3799 @example
3800 f.addStep(ShellCommand, command=["make", "test"],
3801           env=@{'LANG': 'fr_FR'@})
3802 @end example
3804 These variable settings will override any existing ones in the
3805 buildslave's environment. The exception is PYTHONPATH, which is merged
3806 with (actually prepended to) any existing $PYTHONPATH setting. The
3807 value is treated as a list of directories to prepend, and a single
3808 string is treated like a one-item list. For example, to prepend both
3809 @file{/usr/local/lib/python2.3} and @file{/home/buildbot/lib/python}
3810 to any existing $PYTHONPATH setting, you would do something like the
3811 following:
3813 @example
3814 f.addStep(ShellCommand, command=["make", "test"],
3815           env=@{'PYTHONPATH': ["/usr/local/lib/python2.3",
3816                               "/home/buildbot/lib/python"] @})
3817 @end example
3819 @item want_stdout
3820 if False, stdout from the child process is discarded rather than being
3821 sent to the buildmaster for inclusion in the step's LogFile.
3823 @item want_stderr
3824 like @code{want_stdout} but for stderr. Note that commands run through
3825 a PTY do not have separate stdout/stderr streams: both are merged into
3826 stdout.
3828 @item logfiles
3829 Sometimes commands will log interesting data to a local file, rather
3830 than emitting everything to stdout or stderr. For example, Twisted's
3831 ``trial'' command (which runs unit tests) only presents summary
3832 information to stdout, and puts the rest into a file named
3833 @file{_trial_temp/test.log}. It is often useful to watch these files
3834 as the command runs, rather than using @command{/bin/cat} to dump
3835 their contents afterwards.
3837 The @code{logfiles=} argument allows you to collect data from these
3838 secondary logfiles in near-real-time, as the step is running. It
3839 accepts a dictionary which maps from a local Log name (which is how
3840 the log data is presented in the build results) to a remote filename
3841 (interpreted relative to the build's working directory). Each named
3842 file will be polled on a regular basis (every couple of seconds) as
3843 the build runs, and any new text will be sent over to the buildmaster.
3845 @example
3846 f.addStep(ShellCommand, command=["make", "test"],
3847           logfiles=@{"triallog": "_trial_temp/test.log"@})
3848 @end example
3851 @item timeout
3852 if the command fails to produce any output for this many seconds, it
3853 is assumed to be locked up and will be killed.
3855 @item description
3856 This will be used to describe the command (on the Waterfall display)
3857 while the command is still running. It should be a single
3858 imperfect-tense verb, like ``compiling'' or ``testing''. The preferred
3859 form is a list of short strings, which allows the HTML Waterfall
3860 display to create narrower columns by emitting a <br> tag between each
3861 word. You may also provide a single string.
3863 @item descriptionDone
3864 This will be used to describe the command once it has finished. A
3865 simple noun like ``compile'' or ``tests'' should be used. Like
3866 @code{description}, this may either be a list of short strings or a
3867 single string.
3869 If neither @code{description} nor @code{descriptionDone} are set, the
3870 actual command arguments will be used to construct the description.
3871 This may be a bit too wide to fit comfortably on the Waterfall
3872 display.
3874 @example
3875 f.addStep(ShellCommand, command=["make", "test"],
3876           description=["testing"],
3877           descriptionDone=["tests"])
3878 @end example
3880 @end table
3882 @node Simple ShellCommand Subclasses, Python BuildSteps, ShellCommand, Build Steps
3883 @subsection Simple ShellCommand Subclasses
3885 Several subclasses of ShellCommand are provided as starting points for
3886 common build steps. These are all very simple: they just override a few
3887 parameters so you don't have to specify them yourself, making the master.cfg
3888 file less verbose.
3890 @menu
3891 * Configure::                   
3892 * Compile::                     
3893 * Test::                        
3894 * Build Properties::            
3895 @end menu
3897 @node Configure, Compile, Simple ShellCommand Subclasses, Simple ShellCommand Subclasses
3898 @subsubsection Configure
3900 @bsindex buildbot.steps.shell.Configure
3902 This is intended to handle the @code{./configure} step from
3903 autoconf-style projects, or the @code{perl Makefile.PL} step from perl
3904 MakeMaker.pm-style modules. The default command is @code{./configure}
3905 but you can change this by providing a @code{command=} parameter.
3907 @node Compile, Test, Configure, Simple ShellCommand Subclasses
3908 @subsubsection Compile
3910 @bsindex buildbot.steps.shell.Compile
3912 This is meant to handle compiling or building a project written in C. The
3913 default command is @code{make all}. When the compile is finished, the
3914 log file is scanned for GCC error/warning messages and a summary log is
3915 created with any problems that were seen (TODO: the summary is not yet
3916 created).
3918 @node Test, Build Properties, Compile, Simple ShellCommand Subclasses
3919 @subsubsection Test
3921 @bsindex buildbot.steps.shell.Test
3923 This is meant to handle unit tests. The default command is @code{make
3924 test}, and the @code{warnOnFailure} flag is set.
3928 @node Build Properties,  , Test, Simple ShellCommand Subclasses
3929 @subsubsection Build Properties
3931 @cindex build properties
3933 Each build has a set of ``Build Properties'', which can be used by its
3934 BuildStep to modify their actions. For example, the SVN revision
3935 number of the source code being built is available as a build
3936 property, and a ShellCommand step could incorporate this number into a
3937 command which create a numbered release tarball.
3939 Some build properties are set when the build starts, such as the
3940 SourceStamp information. Other properties can be set by BuildSteps as
3941 they run, for example the various Source steps will set the
3942 @code{got_revision} property to the source revision that was actually
3943 checked out (which can be useful when the SourceStamp in use merely
3944 requested the ``latest revision'': @code{got_revision} will tell you
3945 what was actually built).
3947 In custom BuildSteps, you can get and set the build properties with
3948 the @code{getProperty}/@code{setProperty} methods. Each takes a string
3949 for the name of the property, and returns or accepts an
3950 arbitrary@footnote{Build properties are serialized along with the
3951 build results, so they must be serializable. For this reason, the
3952 value of any build property should be simple inert data: strings,
3953 numbers, lists, tuples, and dictionaries. They should not contain
3954 class instances.} object. For example:
3956 @example
3957 class MakeTarball(ShellCommand):
3958     def start(self):
3959         self.setCommand(["tar", "czf",
3960                          "build-%s.tar.gz" % self.getProperty("revision"),
3961                          "source"])
3962         ShellCommand.start(self)
3963 @end example
3965 @cindex WithProperties
3967 You can use build properties in ShellCommands by using the
3968 @code{WithProperties} wrapper when setting the arguments of the
3969 ShellCommand. This interpolates the named build properties into the
3970 generated shell command.
3972 @example
3973 from buildbot.steps.shell import ShellCommand, WithProperties
3975 f.addStep(ShellCommand,
3976           command=["tar", "czf",
3977                    WithProperties("build-%s.tar.gz", "revision"),
3978                    "source"])
3979 @end example
3981 If this BuildStep were used in a tree obtained from Subversion, it
3982 would create a tarball with a name like @file{build-1234.tar.gz}.
3984 The @code{WithProperties} function does @code{printf}-style string
3985 interpolation, using strings obtained by calling
3986 @code{build.getProperty(propname)}. Note that for every @code{%s} (or
3987 @code{%d}, etc), you must have exactly one additional argument to
3988 indicate which build property you want to insert.
3991 You can also use python dictionary-style string interpolation by using
3992 the @code{%(propname)s} syntax. In this form, the property name goes
3993 in the parentheses, and WithProperties takes @emph{no} additional
3994 arguments:
3996 @example
3997 f.addStep(ShellCommand,
3998           command=["tar", "czf",
3999                    WithProperties("build-%(revision)s.tar.gz"),
4000                    "source"])
4001 @end example
4003 Don't forget the extra ``s'' after the closing parenthesis! This is
4004 the cause of many confusing errors. Also note that you can only use
4005 WithProperties in the list form of the command= definition. You cannot
4006 currently use it in the (discouraged) @code{command="stuff"}
4007 single-string form. However, you can use something like
4008 @code{command=["/bin/sh", "-c", "stuff", WithProperties(stuff)]} to
4009 use both shell expansion and WithProperties interpolation.
4011 Note that, like python, you can either do positional-argument
4012 interpolation @emph{or} keyword-argument interpolation, not both. Thus
4013 you cannot use a string like
4014 @code{WithProperties("foo-%(revision)s-%s", "branch")}.
4016 At the moment, the only way to set build properties is by writing a
4017 custom BuildStep.
4019 @heading Common Build Properties
4021 The following build properties are set when the build is started, and
4022 are available to all steps.
4024 @table @code
4025 @item branch
4027 This comes from the build's SourceStamp, and describes which branch is
4028 being checked out. This will be @code{None} (which interpolates into
4029 @code{WithProperties} as an empty string) if the build is on the
4030 default branch, which is generally the trunk. Otherwise it will be a
4031 string like ``branches/beta1.4''. The exact syntax depends upon the VC
4032 system being used.
4034 @item revision
4036 This also comes from the SourceStamp, and is the revision of the
4037 source code tree that was requested from the VC system. When a build
4038 is requested of a specific revision (as is generally the case when the
4039 build is triggered by Changes), this will contain the revision
4040 specification. The syntax depends upon the VC system in use: for SVN
4041 it is an integer, for Mercurial it is a short string, for Darcs it is
4042 a rather large string, etc.
4044 If the ``force build'' button was pressed, the revision will be
4045 @code{None}, which means to use the most recent revision available.
4046 This is a ``trunk build''. This will be interpolated as an empty
4047 string.
4049 @item got_revision
4051 This is set when a Source step checks out the source tree, and
4052 provides the revision that was actually obtained from the VC system.
4053 In general this should be the same as @code{revision}, except for
4054 trunk builds, where @code{got_revision} indicates what revision was
4055 current when the checkout was performed. This can be used to rebuild
4056 the same source code later.
4058 Note that for some VC systems (Darcs in particular), the revision is a
4059 large string containing newlines, and is not suitable for
4060 interpolation into a filename.
4062 @item buildername
4064 This is a string that indicates which Builder the build was a part of.
4065 The combination of buildername and buildnumber uniquely identify a
4066 build.
4068 @item buildnumber
4070 Each build gets a number, scoped to the Builder (so the first build
4071 performed on any given Builder will have a build number of 0). This
4072 integer property contains the build's number.
4074 @item slavename
4076 This is a string which identifies which buildslave the build is
4077 running on.
4079 @end table
4081 @node Python BuildSteps, Transferring Files, Simple ShellCommand Subclasses, Build Steps
4082 @subsection Python BuildSteps
4084 Here are some BuildSteps that are specifcally useful for projects
4085 implemented in Python.
4087 @menu
4088 * BuildEPYDoc::                 
4089 * PyFlakes::                    
4090 @end menu
4092 @node BuildEPYDoc, PyFlakes, Python BuildSteps, Python BuildSteps
4093 @subsubsection BuildEPYDoc
4095 @bsindex buildbot.steps.python.BuildEPYDoc
4097 @url{http://epydoc.sourceforge.net/, epydoc} is a tool for generating
4098 API documentation for Python modules from their docstrings. It reads
4099 all the .py files from your source tree, processes the docstrings
4100 therein, and creates a large tree of .html files (or a single .pdf
4101 file).
4103 The @code{buildbot.steps.python.BuildEPYDoc} step will run
4104 @command{epydoc} to produce this API documentation, and will count the
4105 errors and warnings from its output.
4107 You must supply the command line to be used. The default is
4108 @command{make epydocs}, which assumes that your project has a Makefile
4109 with an ``epydocs'' target. You might wish to use something like
4110 @command{epydoc -o apiref source/PKGNAME} instead. You might also want
4111 to add @command{--pdf} to generate a PDF file instead of a large tree
4112 of HTML files.
4114 The API docs are generated in-place in the build tree (under the
4115 workdir, in the subdirectory controlled by the ``-o'' argument). To
4116 make them useful, you will probably have to copy them to somewhere
4117 they can be read. A command like @command{rsync -ad apiref/
4118 dev.example.com:~public_html/current-apiref/} might be useful. You
4119 might instead want to bundle them into a tarball and publish it in the
4120 same place where the generated install tarball is placed.
4122 @example
4123 from buildbot.steps.python import BuildEPYDoc
4126 f.addStep(BuildEPYDoc, command=["epydoc", "-o", "apiref", "source/mypkg"])
4127 @end example
4130 @node PyFlakes,  , BuildEPYDoc, Python BuildSteps
4131 @subsubsection PyFlakes
4133 @bsindex buildbot.steps.python.PyFlakes
4135 @url{http://divmod.org/trac/wiki/DivmodPyflakes, PyFlakes} is a tool
4136 to perform basic static analysis of Python code to look for simple
4137 errors, like missing imports and references of undefined names. It is
4138 like a fast and simple form of the C ``lint'' program. Other tools
4139 (like pychecker) provide more detailed results but take longer to run.
4141 The @code{buildbot.steps.python.PyFlakes} step will run pyflakes and
4142 count the various kinds of errors and warnings it detects.
4144 You must supply the command line to be used. The default is
4145 @command{make pyflakes}, which assumes you have a top-level Makefile
4146 with a ``pyflakes'' target. You might want to use something like
4147 @command{pyflakes .} or @command{pyflakes src}.
4149 @example
4150 from buildbot.steps.python import PyFlakes
4153 f.addStep(PyFlakes, command=["pyflakes", "src"])
4154 @end example
4157 @node Transferring Files, Writing New BuildSteps, Python BuildSteps, Build Steps
4158 @subsection Transferring Files
4160 @cindex File Transfer
4161 @bsindex buildbot.steps.transfer.FileUpload
4162 @bsindex buildbot.steps.transfer.FileDownload
4164 Most of the work involved in a build will take place on the
4165 buildslave. But occasionally it is useful to do some work on the
4166 buildmaster side. The most basic way to involve the buildmaster is
4167 simply to move a file from the slave to the master, or vice versa.
4168 There are a pair of BuildSteps named @code{FileUpload} and
4169 @code{FileDownload} to provide this functionality. @code{FileUpload}
4170 moves a file @emph{up to} the master, while @code{FileDownload} moves
4171 a file @emph{down from} the master.
4173 As an example, let's assume that there is a step which produces an
4174 HTML file within the source tree that contains some sort of generated
4175 project documentation. We want to move this file to the buildmaster,
4176 into a @file{~/public_html} directory, so it can be visible to
4177 developers. This file will wind up in the slave-side working directory
4178 under the name @file{docs/reference.html}. We want to put it into the
4179 master-side @file{~/public_html/ref.html}.
4181 @example
4182 from buildbot.steps.shell import ShellCommand
4183 from buildbot.steps.transfer import FileUpload
4185 f.addStep(ShellCommand, command=["make", "docs"])
4186 f.addStep(FileUpload,
4187           slavesrc="docs/reference.html",
4188           masterdest="~/public_html/ref.html")
4189 @end example
4191 The @code{masterdest=} argument will be passed to os.path.expanduser,
4192 so things like ``~'' will be expanded properly. Non-absolute paths
4193 will be interpreted relative to the buildmaster's base directory.
4194 Likewise, the @code{slavesrc=} argument will be expanded and
4195 interpreted relative to the builder's working directory.
4198 To move a file from the master to the slave, use the
4199 @code{FileDownload} command. For example, let's assume that some step
4200 requires a configuration file that, for whatever reason, could not be
4201 recorded in the source code repository or generated on the buildslave
4202 side:
4204 @example
4205 from buildbot.steps.shell import ShellCommand
4206 from buildbot.steps.transfer import FileUpload
4208 f.addStep(FileDownload
4209           mastersrc="~/todays_build_config.txt",
4210           slavedest="build_config.txt")
4211 f.addStep(ShellCommand, command=["make", "config"])
4212 @end example
4214 Like @code{FileUpload}, the @code{mastersrc=} argument is interpreted
4215 relative to the buildmaster's base directory, and the
4216 @code{slavedest=} argument is relative to the builder's working
4217 directory. If the buildslave is running in @file{~buildslave}, and the
4218 builder's ``builddir'' is something like @file{tests-i386}, then the
4219 workdir is going to be @file{~buildslave/tests-i386/build}, and a
4220 @code{slavedest=} of @file{foo/bar.html} will get put in
4221 @file{~buildslave/tests-i386/build/foo/bar.html}. Remember that
4222 neither of these commands will create missing directories for you.
4225 @subheading Other Parameters
4227 The @code{maxsize=} argument lets you set a maximum size for the file
4228 to be transferred. This may help to avoid surprises: transferring a
4229 100MB coredump when you were expecting to move a 10kB status file
4230 might take an awfully long time. The @code{blocksize=} argument
4231 controls how the file is sent over the network: larger blocksizes are
4232 slightly more efficient but also consume more memory on each end, and
4233 there is a hard-coded limit of about 640kB.
4235 The @code{mode=} argument allows you to control the access permissions
4236 of the target file, traditionally expressed as an octal integer. The
4237 most common value is probably 0755, which sets the ``x'' executable
4238 bit on the file (useful for shell scripts and the like). The default
4239 value for @code{mode=} is None, which means the permission bits will
4240 default to whatever the umask of the writing process is. The default
4241 umask tends to be fairly restrictive, but at least on the buildslave
4242 you can make it less restrictive with a --umask command-line option at
4243 creation time (@pxref{Buildslave Options}).
4246 @node Writing New BuildSteps,  , Transferring Files, Build Steps
4247 @subsection Writing New BuildSteps
4249 While it is a good idea to keep your build process self-contained in
4250 the source code tree, sometimes it is convenient to put more
4251 intelligence into your Buildbot configuration. One was to do this is
4252 to write a custom BuildStep. Once written, this Step can be used in
4253 the @file{master.cfg} file.
4255 The best reason for writing a custom BuildStep is to better parse the
4256 results of the command being run. For example, a BuildStep that knows
4257 about JUnit could look at the logfiles to determine which tests had
4258 been run, how many passed and how many failed, and then report more
4259 detailed information than a simple @code{rc==0} -based ``good/bad''
4260 decision.
4262 TODO: add more description of BuildSteps.
4264 @menu
4265 * BuildStep LogFiles::          
4266 * Adding LogObservers::         
4267 * BuildStep URLs::              
4268 @end menu
4270 @node BuildStep LogFiles, Adding LogObservers, Writing New BuildSteps, Writing New BuildSteps
4271 @subsubsection BuildStep LogFiles
4273 Each BuildStep has a collection of ``logfiles''. Each one has a short
4274 name, like ``stdio'' or ``warnings''. Each LogFile contains an
4275 arbitrary amount of text, usually the contents of some output file
4276 generated during a build or test step, or a record of everything that
4277 was printed to stdout/stderr during the execution of some command.
4279 These LogFiles are stored to disk, so they can be retrieved later.
4281 Each can contain multiple ``channels'', generally limited to three
4282 basic ones: stdout, stderr, and ``headers''. For example, when a
4283 ShellCommand runs, it writes a few lines to the ``headers'' channel to
4284 indicate the exact argv strings being run, which directory the command
4285 is being executed in, and the contents of the current environment
4286 variables. Then, as the command runs, it adds a lot of ``stdout'' and
4287 ``stderr'' messages. When the command finishes, a final ``header''
4288 line is added with the exit code of the process.
4290 Status display plugins can format these different channels in
4291 different ways. For example, the web page shows LogFiles as text/html,
4292 with header lines in blue text, stdout in black, and stderr in red. A
4293 different URL is available which provides a text/plain format, in
4294 which stdout and stderr are collapsed together, and header lines are
4295 stripped completely. This latter option makes it easy to save the
4296 results to a file and run @command{grep} or whatever against the
4297 output.
4299 Each BuildStep contains a mapping (implemented in a python dictionary)
4300 from LogFile name to the actual LogFile objects. Status plugins can
4301 get a list of LogFiles to display, for example, a list of HREF links
4302 that, when clicked, provide the full contents of the LogFile.
4304 @heading Using LogFiles in custom BuildSteps
4306 The most common way for a custom BuildStep to use a LogFile is to
4307 summarize the results of a ShellCommand (after the command has
4308 finished running). For example, a compile step with thousands of lines
4309 of output might want to create a summary of just the warning messages.
4310 If you were doing this from a shell, you would use something like:
4312 @example
4313 grep "warning:" output.log >warnings.log
4314 @end example
4316 In a custom BuildStep, you could instead create a ``warnings'' LogFile
4317 that contained the same text. To do this, you would add code to your
4318 @code{createSummary} method that pulls lines from the main output log
4319 and creates a new LogFile with the results:
4321 @example
4322     def createSummary(self, log):
4323         warnings = []
4324         for line in log.readlines():
4325             if "warning:" in line:
4326                 warnings.append()
4327         self.addCompleteLog('warnings', "".join(warnings))
4328 @end example
4330 This example uses the @code{addCompleteLog} method, which creates a
4331 new LogFile, puts some text in it, and then ``closes'' it, meaning
4332 that no further contents will be added. This LogFile will appear in
4333 the HTML display under an HREF with the name ``warnings'', since that
4334 is the name of the LogFile.
4336 You can also use @code{addHTMLLog} to create a complete (closed)
4337 LogFile that contains HTML instead of plain text. The normal LogFile
4338 will be HTML-escaped if presented through a web page, but the HTML
4339 LogFile will not. At the moment this is only used to present a pretty
4340 HTML representation of an otherwise ugly exception traceback when
4341 something goes badly wrong during the BuildStep.
4343 In contrast, you might want to create a new LogFile at the beginning
4344 of the step, and add text to it as the command runs. You can create
4345 the LogFile and attach it to the build by calling @code{addLog}, which
4346 returns the LogFile object. You then add text to this LogFile by
4347 calling methods like @code{addStdout} and @code{addHeader}. When you
4348 are done, you must call the @code{finish} method so the LogFile can be
4349 closed. It may be useful to create and populate a LogFile like this
4350 from a LogObserver method @xref{Adding LogObservers}.
4352 The @code{logfiles=} argument to @code{ShellCommand} (see
4353 @pxref{ShellCommand}) creates new LogFiles and fills them in realtime
4354 by asking the buildslave to watch a actual file on disk. The
4355 buildslave will look for additions in the target file and report them
4356 back to the BuildStep. These additions will be added to the LogFile by
4357 calling @code{addStdout}. These secondary LogFiles can be used as the
4358 source of a LogObserver just like the normal ``stdio'' LogFile.
4361 @node Adding LogObservers, BuildStep URLs, BuildStep LogFiles, Writing New BuildSteps
4362 @subsubsection Adding LogObservers
4364 @cindex LogObserver
4365 @cindex LogLineObserver
4367 Most shell commands emit messages to stdout or stderr as they operate,
4368 especially if you ask them nicely with a @code{--verbose} flag of some
4369 sort. They may also write text to a log file while they run. Your
4370 BuildStep can watch this output as it arrives, to keep track of how
4371 much progress the command has made. You can get a better measure of
4372 progress by counting the number of source files compiled or test cases
4373 run than by merely tracking the number of bytes that have been written
4374 to stdout. This improves the accuracy and the smoothness of the ETA
4375 display.
4377 To accomplish this, you will need to attach a @code{LogObserver} to
4378 one of the log channels, most commonly to the ``stdio'' channel but
4379 perhaps to another one which tracks a log file. This observer is given
4380 all text as it is emitted from the command, and has the opportunity to
4381 parse that output incrementally. Once the observer has decided that
4382 some event has occurred (like a source file being compiled), it can
4383 use the @code{setProgress} method to tell the BuildStep about the
4384 progress that this event represents.
4386 There are a number of pre-built @code{LogObserver} classes that you
4387 can choose from (defined in @code{buildbot.process.buildstep}, and of
4388 course you can subclass them to add further customization. The
4389 @code{LogLineObserver} class handles the grunt work of buffering and
4390 scanning for end-of-line delimiters, allowing your parser to operate
4391 on complete stdout/stderr lines.
4393 For example, let's take a look at the @code{TrialTestCaseCounter},
4394 which is used by the Trial step to count test cases as they are run.
4395 As Trial executes, it emits lines like the following:
4397 @example
4398 buildbot.test.test_config.ConfigTest.testDebugPassword ... [OK]
4399 buildbot.test.test_config.ConfigTest.testEmpty ... [OK]
4400 buildbot.test.test_config.ConfigTest.testIRC ... [FAIL]
4401 buildbot.test.test_config.ConfigTest.testLocks ... [OK]
4402 @end example
4404 When the tests are finished, trial emits a long line of ``======'' and
4405 then some lines which summarize the tests that failed. We want to
4406 avoid parsing these trailing lines, because their format is less
4407 well-defined than the ``[OK]'' lines.
4409 The parser class looks like this:
4411 @example
4412 from buildbot.process.buildstep import LogLineObserver
4414 class TrialTestCaseCounter(LogLineObserver):
4415     _line_re = re.compile(r'^([\w\.]+) \.\.\. \[([^\]]+)\]$')
4416     numTests = 0
4417     finished = False
4419     def outLineReceived(self, line):
4420         if self.finished:
4421             return
4422         if line.startswith("=" * 40):
4423             self.finished = True
4424             return
4426         m = self._line_re.search(line.strip())
4427         if m:
4428             testname, result = m.groups()
4429             self.numTests += 1
4430             self.step.setProgress('tests', self.numTests)
4431 @end example
4433 This parser only pays attention to stdout, since that's where trial
4434 writes the progress lines. It has a mode flag named @code{finished} to
4435 ignore everything after the ``===='' marker, and a scary-looking
4436 regular expression to match each line while hopefully ignoring other
4437 messages that might get displayed as the test runs.
4439 Each time it identifies a test has been completed, it increments its
4440 counter and delivers the new progress value to the step with
4441 @code{self.step.setProgress}. This class is specifically measuring
4442 progress along the ``tests'' metric, in units of test cases (as
4443 opposed to other kinds of progress like the ``output'' metric, which
4444 measures in units of bytes). The Progress-tracking code uses each
4445 progress metric separately to come up with an overall completion
4446 percentage and an ETA value.
4448 To connect this parser into the @code{Trial} BuildStep,
4449 @code{Trial.__init__} ends with the following clause:
4451 @example
4452         # this counter will feed Progress along the 'test cases' metric
4453         counter = TrialTestCaseCounter()
4454         self.addLogObserver('stdio', counter)
4455 @end example
4457 This creates a TrialTestCaseCounter and tells the step that the
4458 counter wants to watch the ``stdio'' log. The observer is
4459 automatically given a reference to the step in its @code{.step}
4460 attribute.
4462 @subheading A Somewhat Whimsical Example
4464 Let's say that we've got some snazzy new unit-test framework called
4465 Framboozle. It's the hottest thing since sliced bread. It slices, it
4466 dices, it runs unit tests like there's no tomorrow. Plus if your unit
4467 tests fail, you can use its name for a Web 2.1 startup company, make
4468 millions of dollars, and hire engineers to fix the bugs for you, while
4469 you spend your afternoons lazily hang-gliding along a scenic pacific
4470 beach, blissfully unconcerned about the state of your
4471 tests.@footnote{framboozle.com is still available. Remember, I get 10%
4472 :).}
4474 To run a Framboozle-enabled test suite, you just run the 'framboozler'
4475 command from the top of your source code tree. The 'framboozler'
4476 command emits a bunch of stuff to stdout, but the most interesting bit
4477 is that it emits the line "FNURRRGH!" every time it finishes running a
4478 test case@footnote{Framboozle gets very excited about running unit
4479 tests.}. You'd like to have a test-case counting LogObserver that
4480 watches for these lines and counts them, because counting them will
4481 help the buildbot more accurately calculate how long the build will
4482 take, and this will let you know exactly how long you can sneak out of
4483 the office for your hang-gliding lessons without anyone noticing that
4484 you're gone.
4486 This will involve writing a new BuildStep (probably named
4487 "Framboozle") which inherits from ShellCommand. The BuildStep class
4488 definition itself will look something like this:
4490 @example
4491 # START
4492 from buildbot.steps.shell import ShellCommand
4493 from buildbot.process.buildstep import LogLineObserver
4495 class FNURRRGHCounter(LogLineObserver):
4496     numTests = 0
4497     def outLineReceived(self, line):
4498         if "FNURRRGH!" in line:
4499             self.numTests += 1
4500             self.step.setProgress('tests', self.numTests)
4502 class Framboozle(ShellCommand):
4503     command = ["framboozler"]
4505     def __init__(self, **kwargs):
4506         ShellCommand.__init__(self, **kwargs)   # always upcall!
4507         counter = FNURRRGHCounter())
4508         self.addLogObserver(counter)
4509 # FINISH
4510 @end example
4512 So that's the code that we want to wind up using. How do we actually
4513 deploy it?
4515 You have a couple of different options.
4517 Option 1: The simplest technique is to simply put this text
4518 (everything from START to FINISH) in your master.cfg file, somewhere
4519 before the BuildFactory definition where you actually use it in a
4520 clause like:
4522 @example
4523 f = BuildFactory()
4524 f.addStep(SVN, svnurl="stuff")
4525 f.addStep(Framboozle)
4526 @end example
4528 Remember that master.cfg is secretly just a python program with one
4529 job: populating the BuildmasterConfig dictionary. And python programs
4530 are allowed to define as many classes as they like. So you can define
4531 classes and use them in the same file, just as long as the class is
4532 defined before some other code tries to use it.
4534 This is easy, and it keeps the point of definition very close to the
4535 point of use, and whoever replaces you after that unfortunate
4536 hang-gliding accident will appreciate being able to easily figure out
4537 what the heck this stupid "Framboozle" step is doing anyways. The
4538 downside is that every time you reload the config file, the Framboozle
4539 class will get redefined, which means that the buildmaster will think
4540 that you've reconfigured all the Builders that use it, even though
4541 nothing changed. Bleh.
4543 Option 2: Instead, we can put this code in a separate file, and import
4544 it into the master.cfg file just like we would the normal buildsteps
4545 like ShellCommand and SVN.
4547 Create a directory named ~/lib/python, put everything from START to
4548 FINISH in ~/lib/python/framboozle.py, and run your buildmaster using:
4550 @example
4551  PYTHONPATH=~/lib/python buildbot start MASTERDIR
4552 @end example
4554 or use the @file{Makefile.buildbot} to control the way
4555 @command{buildbot start} works. Or add something like this to
4556 something like your ~/.bashrc or ~/.bash_profile or ~/.cshrc:
4558 @example
4559  export PYTHONPATH=~/lib/python
4560 @end example
4562 Once we've done this, our master.cfg can look like:
4564 @example
4565 from framboozle import Framboozle
4566 f = BuildFactory()
4567 f.addStep(SVN, svnurl="stuff")
4568 f.addStep(Framboozle)
4569 @end example
4573 @example
4574 import framboozle
4575 f = BuildFactory()
4576 f.addStep(SVN, svnurl="stuff")
4577 f.addStep(framboozle.Framboozle)
4578 @end example
4580 (check out the python docs for details about how "import" and "from A
4581 import B" work).
4583 What we've done here is to tell python that every time it handles an
4584 "import" statement for some named module, it should look in our
4585 ~/lib/python/ for that module before it looks anywhere else. After our
4586 directories, it will try in a bunch of standard directories too
4587 (including the one where buildbot is installed). By setting the
4588 PYTHONPATH environment variable, you can add directories to the front
4589 of this search list.
4591 Python knows that once it "import"s a file, it doesn't need to
4592 re-import it again. This means that reconfiguring the buildmaster
4593 (with "buildbot reconfig", for example) won't make it think the
4594 Framboozle class has changed every time, so the Builders that use it
4595 will not be spuriously restarted. On the other hand, you either have
4596 to start your buildmaster in a slightly weird way, or you have to
4597 modify your environment to set the PYTHONPATH variable.
4600 Option 3: Install this code into a standard python library directory
4602 Find out what your python's standard include path is by asking it:
4604 @example
4605 80:warner@@luther% python
4606 Python 2.4.4c0 (#2, Oct  2 2006, 00:57:46) 
4607 [GCC 4.1.2 20060928 (prerelease) (Debian 4.1.1-15)] on linux2
4608 Type "help", "copyright", "credits" or "license" for more information.
4609 >>> import sys
4610 >>> print sys.path
4611 ['', '/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']
4612 >>> 
4613 @end example
4615 In this case, putting the code into
4616 /usr/local/lib/python2.4/site-packages/framboozle.py would work just
4617 fine. We can use the same master.cfg "import framboozle" statement as
4618 in Option 2. By putting it in a standard include directory (instead of
4619 the decidedly non-standard ~/lib/python), we don't even have to set
4620 PYTHONPATH to anything special. The downside is that you probably have
4621 to be root to write to one of those standard include directories.
4624 Option 4: Submit the code for inclusion in the Buildbot distribution
4626 Contribute the code in an Enhancement Request on SourceForge, via
4627 http://buildbot.sf.net . Lobby, convince, coerce, bribe, badger,
4628 harass, threaten, or otherwise encourage the author to accept the
4629 patch. This lets you do something like:
4631 @example
4632 from buildbot.steps import framboozle
4633 f = BuildFactory()
4634 f.addStep(SVN, svnurl="stuff")
4635 f.addStep(framboozle.Framboozle)
4636 @end example
4638 And then you don't even have to install framboozle.py anywhere on your
4639 system, since it will ship with Buildbot. You don't have to be root,
4640 you don't have to set PYTHONPATH. But you do have to make a good case
4641 for Framboozle being worth going into the main distribution, you'll
4642 probably have to provide docs and some unit test cases, you'll need to
4643 figure out what kind of beer the author likes, and then you'll have to
4644 wait until the next release. But in some environments, all this is
4645 easier than getting root on your buildmaster box, so the tradeoffs may
4646 actually be worth it.
4650 Putting the code in master.cfg (1) makes it available to that
4651 buildmaster instance. Putting it in a file in a personal library
4652 directory (2) makes it available for any buildmasters you might be
4653 running. Putting it in a file in a system-wide shared library
4654 directory (3) makes it available for any buildmasters that anyone on
4655 that system might be running. Getting it into the buildbot's upstream
4656 repository (4) makes it available for any buildmasters that anyone in
4657 the world might be running. It's all a matter of how widely you want
4658 to deploy that new class.
4662 @node BuildStep URLs,  , Adding LogObservers, Writing New BuildSteps
4663 @subsubsection BuildStep URLs
4665 @cindex links
4666 @cindex BuildStep URLs
4667 @cindex addURL
4669 Each BuildStep has a collection of ``links''. Like its collection of
4670 LogFiles, each link has a name and a target URL. The web status page
4671 creates HREFs for each link in the same box as it does for LogFiles,
4672 except that the target of the link is the external URL instead of an
4673 internal link to a page that shows the contents of the LogFile.
4675 These external links can be used to point at build information hosted
4676 on other servers. For example, the test process might produce an
4677 intricate description of which tests passed and failed, or some sort
4678 of code coverage data in HTML form, or a PNG or GIF image with a graph
4679 of memory usage over time. The external link can provide an easy way
4680 for users to navigate from the buildbot's status page to these
4681 external web sites or file servers. Note that the step itself is
4682 responsible for insuring that there will be a document available at
4683 the given URL (perhaps by using @command{scp} to copy the HTML output
4684 to a @file{~/public_html/} directory on a remote web server). Calling
4685 @code{addURL} does not magically populate a web server.
4687 To set one of these links, the BuildStep should call the @code{addURL}
4688 method with the name of the link and the target URL. Multiple URLs can
4689 be set.
4691 In this example, we assume that the @command{make test} command causes
4692 a collection of HTML files to be created and put somewhere on the
4693 coverage.example.org web server, in a filename that incorporates the
4694 build number.
4696 @example
4697 class TestWithCodeCoverage(BuildStep):
4698     command = ["make", "test",
4699                WithProperties("buildnum=%s" % "buildnumber")]
4701     def createSummary(self, log):
4702         buildnumber = self.getProperty("buildnumber")
4703         url = "http://coverage.example.org/builds/%s.html" % buildnumber
4704         self.addURL("coverage", url)
4705 @end example
4707 You might also want to extract the URL from some special message
4708 output by the build process itself:
4710 @example
4711 class TestWithCodeCoverage(BuildStep):
4712     command = ["make", "test",
4713                WithProperties("buildnum=%s" % "buildnumber")]
4715     def createSummary(self, log):
4716         output = StringIO(log.getText())
4717         for line in output.readlines():
4718             if line.startswith("coverage-url:"):
4719                 url = line[len("coverage-url:"):].strip()
4720                 self.addURL("coverage", url)
4721                 return
4722 @end example
4724 Note that a build process which emits both stdout and stderr might
4725 cause this line to be split or interleaved between other lines. It
4726 might be necessary to restrict the getText() call to only stdout with
4727 something like this:
4729 @example
4730         output = StringIO("".join([c[1]
4731                                    for c in log.getChunks()
4732                                    if c[0] == LOG_CHANNEL_STDOUT]))
4733 @end example
4735 Of course if the build is run under a PTY, then stdout and stderr will
4736 be merged before the buildbot ever sees them, so such interleaving
4737 will be unavoidable.
4740 @node Interlocks, Build Factories, Build Steps, Build Process
4741 @section Interlocks
4743 @cindex locks
4744 @slindex buildbot.locks.MasterLock
4745 @slindex buildbot.locks.SlaveLock
4747 For various reasons, you may want to prevent certain Steps (or perhaps
4748 entire Builds) from running simultaneously. Limited CPU speed or
4749 network bandwidth to the VC server, problems with simultaneous access
4750 to a database server used by unit tests, or multiple Builds which
4751 access shared state may all require some kind of interlock to prevent
4752 corruption, confusion, or resource overload. These resources might
4753 require completely exclusive access, or it might be sufficient to
4754 establish a limit of two or three simultaneous builds.
4756 @code{Locks} are the mechanism used to express these kinds of
4757 constraints on when Builds or Steps can be run. There are two kinds of
4758 @code{Locks}, each with their own scope: @code{MasterLock} instances
4759 are scoped to the buildbot as a whole, while @code{SlaveLock}s are
4760 scoped to a single buildslave. This means that each buildslave has a
4761 separate copy of each @code{SlaveLock}, which could enforce a
4762 one-Build-at-a-time limit for each machine, but still allow as many
4763 simultaneous builds as there are machines.
4765 Each @code{Lock} is created with a unique name. Each lock gets a count
4766 of how many owners it may have: how many processes can claim it at ths
4767 same time. This limit defaults to one, and is controllable through the
4768 @code{maxCount} argument. On @code{SlaveLock}s you can set the owner
4769 count on a per-slave basis by providing a dictionary (that maps from
4770 slavename to maximum owner count) to its @code{maxCountForSlave}
4771 argument. Any buildslaves that aren't mentioned in
4772 @code{maxCountForSlave} get their owner count from @code{maxCount}.
4774 To use a lock, simply include it in the @code{locks=} argument of the
4775 @code{BuildStep} object that should obtain the lock before it runs.
4776 This argument accepts a list of @code{Lock} objects: the Step will
4777 acquire all of them before it runs.
4779 To claim a lock for the whole Build, add a @code{'locks'} key to the
4780 builder specification dictionary with the same list of @code{Lock}
4781 objects. (This is the dictionary that has the @code{'name'},
4782 @code{'slavename'}, @code{'builddir'}, and @code{'factory'} keys). The
4783 @code{Build} object also accepts a @code{locks=} argument, but unless
4784 you are writing your own @code{BuildFactory} subclass then it will be
4785 easier to set the locks in the builder dictionary.
4787 Note that there are no partial-acquire or partial-release semantics:
4788 this prevents deadlocks caused by two Steps each waiting for a lock
4789 held by the other@footnote{Also note that a clever buildmaster admin
4790 could still create the opportunity for deadlock: Build A obtains Lock
4791 1, inside which Step A.two tries to acquire Lock 2 at the Step level.
4792 Meanwhile Build B obtains Lock 2, and has a Step B.two which wants to
4793 acquire Lock 1 at the Step level. Don't Do That.}. This also means
4794 that waiting to acquire a @code{Lock} can take an arbitrarily long
4795 time: if the buildmaster is very busy, a Step or Build which requires
4796 only one @code{Lock} may starve another that is waiting for that
4797 @code{Lock} plus some others.
4800 In the following example, we run the same build on three different
4801 platforms. The unit-test steps of these builds all use a common
4802 database server, and would interfere with each other if allowed to run
4803 simultaneously. The @code{Lock} prevents more than one of these builds
4804 from happening at the same time.
4806 @example
4807 from buildbot import locks
4808 from buildbot.steps import source, shell
4809 from buildbot.process import factory
4811 db_lock = locks.MasterLock("database")
4812 f = factory.BuildFactory()
4813 f.addStep(source.SVN, svnurl="http://example.org/svn/Trunk")
4814 f.addStep(shell.ShellCommand, command="make all")
4815 f.addStep(shell.ShellCommand, command="make test", locks=[db_lock])
4816 b1 = @{'name': 'full1', 'slavename': 'bot-1', builddir='f1', 'factory': f@}
4817 b2 = @{'name': 'full2', 'slavename': 'bot-2', builddir='f2', 'factory': f@}
4818 b3 = @{'name': 'full3', 'slavename': 'bot-3', builddir='f3', 'factory': f@}
4819 c['builders'] = [b1, b2, b3]
4820 @end example
4822 In the next example, we have one buildslave hosting three separate
4823 Builders (each running tests against a different version of Python).
4824 The machine which hosts this buildslave is not particularly fast, so
4825 we want to prevent all three builds from all happening at the same
4826 time. (Assume we've experimentally determined that one build leaves
4827 unused CPU capacity, three builds causes a lot of disk thrashing, but
4828 two builds at a time is Just Right). We use a @code{SlaveLock} because
4829 the builds happening on this one slow slave should not affect builds
4830 running on other slaves, and we use the lock on the build as a whole
4831 because the slave is so slow that even multiple simultaneous SVN
4832 checkouts would be too taxing. We set @code{maxCount=2} to achieve our
4833 goal of two simultaneous builds per slave.
4835 @example
4836 from buildbot import locks
4837 from buildbot.steps import source
4838 from buildbot.process import s, factory
4840 slow_lock = locks.SlaveLock("cpu", maxCount=2)
4841 source = s(source.SVN, svnurl="http://example.org/svn/Trunk")
4842 f22 = factory.Trial(source, trialpython=["python2.2"])
4843 f23 = factory.Trial(source, trialpython=["python2.3"])
4844 f24 = factory.Trial(source, trialpython=["python2.4"])
4845 b1 = @{'name': 'p22', 'slavename': 'bot-1', builddir='p22', 'factory': f22,
4846       'locks': [slow_lock] @}
4847 b2 = @{'name': 'p23', 'slavename': 'bot-1', builddir='p23', 'factory': f23,
4848       'locks': [slow_lock] @}
4849 b3 = @{'name': 'p24', 'slavename': 'bot-1', builddir='p24', 'factory': f24,
4850       'locks': [slow_lock] @}
4851 c['builders'] = [b1, b2, b3]
4852 @end example
4854 In the last example, we use two Locks at the same time. In this case,
4855 we're concerned about both of the previous constraints, but we'll say
4856 that only the tests are computationally intensive, and that they have
4857 been split into those which use the database and those which do not.
4858 In addition, two of the Builds run on a fast machine which does not
4859 need to worry about the cpu lock, but which still must be prevented
4860 from simultaneous database access. We use @code{maxCountForSlave} to
4861 limit the slow machine to one simultanous build, but allow practically
4862 unlimited concurrent builds on the fast machine.
4864 @example
4865 from buildbot import locks
4866 from buildbot.steps import source, shell
4867 from buildbot.process import factory
4869 db_lock = locks.MasterLock("database")
4870 slavecounts = @{"bot-slow": 1, "bot-fast": 100@}
4871 cpu_lock = locks.SlaveLock("cpu", maxCountForSlave=slavecounts)
4872 f = factory.BuildFactory()
4873 f.addStep(source.SVN, svnurl="http://example.org/svn/Trunk")
4874 f.addStep(shell.ShellCommand, command="make all", locks=[cpu_lock])
4875 f.addStep(shell.ShellCommand, command="make test", locks=[cpu_lock])
4876 f.addStep(shell.ShellCommand, command="make db-test",
4877                               locks=[db_lock, cpu_lock])
4879 b1 = @{'name': 'full1', 'slavename': 'bot-slow', builddir='full1',
4880       'factory': f@}
4881 b2 = @{'name': 'full2', 'slavename': 'bot-slow', builddir='full2',
4882       'factory': f@}
4883 b3 = @{'name': 'full3', 'slavename': 'bot-fast', builddir='full3',
4884       'factory': f@}
4885 b4 = @{'name': 'full4', 'slavename': 'bot-fast', builddir='full4',
4886       'factory': f@}
4887 c['builders'] = [b1, b2, b3, b4]
4888 @end example
4890 As a final note, remember that a unit test system which breaks when
4891 multiple people run it at the same time is fragile and should be
4892 fixed. Asking your human developers to serialize themselves when
4893 running unit tests will just discourage them from running the unit
4894 tests at all. Find a way to fix this: change the database tests to
4895 create a new (uniquely-named) user or table for each test run, don't
4896 use fixed listening TCP ports for network tests (instead listen on
4897 port 0 to let the kernel choose a port for you and then query the
4898 socket to find out what port was allocated). @code{MasterLock}s can be
4899 used to accomodate broken test systems like this, but are really
4900 intended for other purposes: build processes that store or retrieve
4901 products in shared directories, or which do things that human
4902 developers would not (or which might slow down or break in ways that
4903 require human attention to deal with).
4905 @code{SlaveLocks}s can be used to keep automated performance tests
4906 from interfering with each other, when there are multiple Builders all
4907 using the same buildslave. But they can't prevent other users from
4908 running CPU-intensive jobs on that host while the tests are running.
4910 @node Build Factories,  , Interlocks, Build Process
4911 @section Build Factories
4914 Each Builder is equipped with a ``build factory'', which is
4915 responsible for producing the actual @code{Build} objects that perform
4916 each build. This factory is created in the configuration file, and
4917 attached to a Builder through the @code{factory} element of its
4918 dictionary.
4920 The standard @code{BuildFactory} object creates @code{Build} objects
4921 by default. These Builds will each execute a collection of BuildSteps
4922 in a fixed sequence. Each step can affect the results of the build,
4923 but in general there is little intelligence to tie the different steps
4924 together. You can create subclasses of @code{Build} to implement more
4925 sophisticated build processes, and then use a subclass of
4926 @code{BuildFactory} (or simply set the @code{buildClass} attribute) to
4927 create instances of your new Build subclass.
4930 @menu
4931 * BuildStep Objects::           
4932 * BuildFactory::                
4933 * Process-Specific build factories::  
4934 @end menu
4936 @node BuildStep Objects, BuildFactory, Build Factories, Build Factories
4937 @subsection BuildStep Objects
4939 The steps used by these builds are all subclasses of @code{BuildStep}.
4940 The standard ones provided with Buildbot are documented later,
4941 @xref{Build Steps}. You can also write your own subclasses to use in
4942 builds.
4944 The basic behavior for a @code{BuildStep} is to:
4946 @itemize @bullet
4947 @item
4948 run for a while, then stop
4949 @item
4950 possibly invoke some RemoteCommands on the attached build slave
4951 @item
4952 possibly produce a set of log files
4953 @item
4954 finish with a status described by one of four values defined in
4955 buildbot.status.builder: SUCCESS, WARNINGS, FAILURE, SKIPPED
4956 @item
4957 provide a list of short strings to describe the step
4958 @item
4959 define a color (generally green, orange, or red) with which the
4960 step should be displayed
4961 @end itemize
4964 More sophisticated steps may produce additional information and
4965 provide it to later build steps, or store it in the factory to provide
4966 to later builds.
4969 @menu
4970 * BuildFactory Attributes::     
4971 * Quick builds::                
4972 @end menu
4974 @node BuildFactory, Process-Specific build factories, BuildStep Objects, Build Factories
4975 @subsection BuildFactory
4977 @bfindex buildbot.process.factory.BuildFactory
4978 @bfindex buildbot.process.factory.BasicBuildFactory
4979 @c TODO: what is BasicSVN anyway?
4980 @bfindex buildbot.process.factory.BasicSVN
4982 The default @code{BuildFactory}, provided in the
4983 @code{buildbot.process.factory} module, contains a list of ``BuildStep
4984 specifications'': a list of @code{(step_class, kwargs)} tuples for
4985 each. When asked to create a Build, it loads the list of steps into
4986 the new Build object. When the Build is actually started, these step
4987 specifications are used to create the actual set of BuildSteps, which
4988 are then executed one at a time. For example, a build which consists
4989 of a CVS checkout followed by a @code{make build} would be constructed
4990 as follows:
4992 @example
4993 from buildbot.steps import source, shell
4994 from buildbot.process import factory
4996 f = factory.BuildFactory()
4997 f.addStep(source.CVS, cvsroot=CVSROOT, cvsmodule="project", mode="update")
4998 f.addStep(shell.Compile, command=["make", "build"])
4999 @end example
5001 It is also possible to pass a list of step specifications into the
5002 @code{BuildFactory} when it is created. Using @code{addStep} is
5003 usually simpler, but there are cases where is is more convenient to
5004 create the list of steps ahead of time. To make this approach easier,
5005 a convenience function named @code{s} is available:
5007 @example
5008 from buildbot.steps import source, shell
5009 from buildbot.process import factory
5010 from buildbot.factory import s
5011 # s is a convenience function, defined with:
5012 # def s(steptype, **kwargs): return (steptype, kwargs)
5014 all_steps = [s(source.CVS, cvsroot=CVSROOT, cvsmodule="project",
5015                mode="update"),
5016              s(shell.Compile, command=["make", "build"]),
5017             ]
5018 f = factory.BuildFactory(all_steps)
5019 @end example
5022 Each step can affect the build process in the following ways:
5024 @itemize @bullet
5025 @item
5026 If the step's @code{haltOnFailure} attribute is True, then a failure
5027 in the step (i.e. if it completes with a result of FAILURE) will cause
5028 the whole build to be terminated immediately: no further steps will be
5029 executed. This is useful for setup steps upon which the rest of the
5030 build depends: if the CVS checkout or @code{./configure} process
5031 fails, there is no point in trying to compile or test the resulting
5032 tree.
5034 @item
5035 If the @code{flunkOnFailure} or @code{flunkOnWarnings} flag is set,
5036 then a result of FAILURE or WARNINGS will mark the build as a whole as
5037 FAILED. However, the remaining steps will still be executed. This is
5038 appropriate for things like multiple testing steps: a failure in any
5039 one of them will indicate that the build has failed, however it is
5040 still useful to run them all to completion.
5042 @item
5043 Similarly, if the @code{warnOnFailure} or @code{warnOnWarnings} flag
5044 is set, then a result of FAILURE or WARNINGS will mark the build as
5045 having WARNINGS, and the remaining steps will still be executed. This
5046 may be appropriate for certain kinds of optional build or test steps.
5047 For example, a failure experienced while building documentation files
5048 should be made visible with a WARNINGS result but not be serious
5049 enough to warrant marking the whole build with a FAILURE.
5051 @end itemize
5053 In addition, each Step produces its own results, may create logfiles,
5054 etc. However only the flags described above have any effect on the
5055 build as a whole.
5057 The pre-defined BuildSteps like @code{CVS} and @code{Compile} have
5058 reasonably appropriate flags set on them already. For example, without
5059 a source tree there is no point in continuing the build, so the
5060 @code{CVS} class has the @code{haltOnFailure} flag set to True. Look
5061 in @file{buildbot/process/step.py} to see how the other Steps are
5062 marked.
5064 Each Step is created with an additional @code{workdir} argument that
5065 indicates where its actions should take place. This is specified as a
5066 subdirectory of the slave builder's base directory, with a default
5067 value of @code{build}. This is only implemented as a step argument (as
5068 opposed to simply being a part of the base directory) because the
5069 CVS/SVN steps need to perform their checkouts from the parent
5070 directory.
5072 @menu
5073 * BuildFactory Attributes::     
5074 * Quick builds::                
5075 @end menu
5077 @node BuildFactory Attributes, Quick builds, BuildFactory, BuildFactory
5078 @subsubsection BuildFactory Attributes
5080 Some attributes from the BuildFactory are copied into each Build.
5082 @cindex treeStableTimer
5084 @table @code
5085 @item useProgress
5086 (defaults to True): if True, the buildmaster keeps track of how long
5087 each step takes, so it can provide estimates of how long future builds
5088 will take. If builds are not expected to take a consistent amount of
5089 time (such as incremental builds in which a random set of files are
5090 recompiled or tested each time), this should be set to False to
5091 inhibit progress-tracking.
5093 @end table
5096 @node Quick builds,  , BuildFactory Attributes, BuildFactory
5097 @subsubsection Quick builds
5099 @bfindex buildbot.process.factory.QuickBuildFactory
5101 The difference between a ``full build'' and a ``quick build'' is that
5102 quick builds are generally done incrementally, starting with the tree
5103 where the previous build was performed. That simply means that the
5104 source-checkout step should be given a @code{mode='update'} flag, to
5105 do the source update in-place.
5107 In addition to that, the @code{useProgress} flag should be set to
5108 False. Incremental builds will (or at least the ought to) compile as
5109 few files as necessary, so they will take an unpredictable amount of
5110 time to run. Therefore it would be misleading to claim to predict how
5111 long the build will take.
5114 @node Process-Specific build factories,  , BuildFactory, Build Factories
5115 @subsection Process-Specific build factories
5117 Many projects use one of a few popular build frameworks to simplify
5118 the creation and maintenance of Makefiles or other compilation
5119 structures. Buildbot provides several pre-configured BuildFactory
5120 subclasses which let you build these projects with a minimum of fuss.
5122 @menu
5123 * GNUAutoconf::                 
5124 * CPAN::                        
5125 * Python distutils::            
5126 * Python/Twisted/trial projects::  
5127 @end menu
5129 @node GNUAutoconf, CPAN, Process-Specific build factories, Process-Specific build factories
5130 @subsubsection GNUAutoconf
5132 @bfindex buildbot.process.factory.GNUAutoconf
5134 @uref{http://www.gnu.org/software/autoconf/, GNU Autoconf} is a
5135 software portability tool, intended to make it possible to write
5136 programs in C (and other languages) which will run on a variety of
5137 UNIX-like systems. Most GNU software is built using autoconf. It is
5138 frequently used in combination with GNU automake. These tools both
5139 encourage a build process which usually looks like this:
5141 @example
5142 % CONFIG_ENV=foo ./configure --with-flags
5143 % make all
5144 % make check
5145 # make install
5146 @end example
5148 (except of course the Buildbot always skips the @code{make install}
5149 part).
5151 The Buildbot's @code{buildbot.process.factory.GNUAutoconf} factory is
5152 designed to build projects which use GNU autoconf and/or automake. The
5153 configuration environment variables, the configure flags, and command
5154 lines used for the compile and test are all configurable, in general
5155 the default values will be suitable.
5157 Example:
5159 @example
5160 # use the s() convenience function defined earlier
5161 f = factory.GNUAutoconf(source=s(step.SVN, svnurl=URL, mode="copy"),
5162                         flags=["--disable-nls"])
5163 @end example
5165 Required Arguments:
5167 @table @code
5168 @item source
5169 This argument must be a step specification tuple that provides a
5170 BuildStep to generate the source tree.
5171 @end table
5173 Optional Arguments:
5175 @table @code
5176 @item configure
5177 The command used to configure the tree. Defaults to
5178 @code{./configure}. Accepts either a string or a list of shell argv
5179 elements.
5181 @item configureEnv
5182 The environment used for the initial configuration step. This accepts
5183 a dictionary which will be merged into the buildslave's normal
5184 environment. This is commonly used to provide things like
5185 @code{CFLAGS="-O2 -g"} (to turn off debug symbols during the compile).
5186 Defaults to an empty dictionary.
5188 @item configureFlags
5189 A list of flags to be appended to the argument list of the configure
5190 command. This is commonly used to enable or disable specific features
5191 of the autoconf-controlled package, like @code{["--without-x"]} to
5192 disable windowing support. Defaults to an empty list.
5194 @item compile
5195 this is a shell command or list of argv values which is used to
5196 actually compile the tree. It defaults to @code{make all}. If set to
5197 None, the compile step is skipped.
5199 @item test
5200 this is a shell command or list of argv values which is used to run
5201 the tree's self-tests. It defaults to @code{make check}. If set to
5202 None, the test step is skipped.
5204 @end table
5207 @node CPAN, Python distutils, GNUAutoconf, Process-Specific build factories
5208 @subsubsection CPAN
5210 @bfindex buildbot.process.factory.CPAN
5212 Most Perl modules available from the @uref{http://www.cpan.org/, CPAN}
5213 archive use the @code{MakeMaker} module to provide configuration,
5214 build, and test services. The standard build routine for these modules
5215 looks like:
5217 @example
5218 % perl Makefile.PL
5219 % make
5220 % make test
5221 # make install
5222 @end example
5224 (except again Buildbot skips the install step)
5226 Buildbot provides a @code{CPAN} factory to compile and test these
5227 projects.
5230 Arguments:
5231 @table @code
5232 @item source
5233 (required): A step specification tuple, that that used by GNUAutoconf.
5235 @item perl
5236 A string which specifies the @code{perl} executable to use. Defaults
5237 to just @code{perl}.
5239 @end table
5242 @node Python distutils, Python/Twisted/trial projects, CPAN, Process-Specific build factories
5243 @subsubsection Python distutils
5245 @bfindex buildbot.process.factory.Distutils
5247 Most Python modules use the @code{distutils} package to provide
5248 configuration and build services. The standard build process looks
5249 like:
5251 @example
5252 % python ./setup.py build
5253 % python ./setup.py install
5254 @end example
5256 Unfortunately, although Python provides a standard unit-test framework
5257 named @code{unittest}, to the best of my knowledge @code{distutils}
5258 does not provide a standardized target to run such unit tests. (please
5259 let me know if I'm wrong, and I will update this factory).
5261 The @code{Distutils} factory provides support for running the build
5262 part of this process. It accepts the same @code{source=} parameter as
5263 the other build factories.
5266 Arguments:
5267 @table @code
5268 @item source
5269 (required): A step specification tuple, that that used by GNUAutoconf.
5270   
5271 @item python
5272 A string which specifies the @code{python} executable to use. Defaults
5273 to just @code{python}.
5275 @item test
5276 Provides a shell command which runs unit tests. This accepts either a
5277 string or a list. The default value is None, which disables the test
5278 step (since there is no common default command to run unit tests in
5279 distutils modules).
5281 @end table
5284 @node Python/Twisted/trial projects,  , Python distutils, Process-Specific build factories
5285 @subsubsection Python/Twisted/trial projects
5287 @bfindex buildbot.process.factory.Trial
5288 @c TODO: document these steps better
5289 @bsindex buildbot.steps.python_twisted.HLint
5290 @bsindex buildbot.steps.python_twisted.Trial
5291 @bsindex buildbot.steps.python_twisted.ProcessDocs
5292 @bsindex buildbot.steps.python_twisted.BuildDebs
5293 @bsindex buildbot.steps.python_twisted.RemovePYCs
5295 Twisted provides a unit test tool named @code{trial} which provides a
5296 few improvements over Python's built-in @code{unittest} module. Many
5297 python projects which use Twisted for their networking or application
5298 services also use trial for their unit tests. These modules are
5299 usually built and tested with something like the following:
5301 @example
5302 % python ./setup.py build
5303 % PYTHONPATH=build/lib.linux-i686-2.3 trial -v PROJECTNAME.test
5304 % python ./setup.py install
5305 @end example
5307 Unfortunately, the @file{build/lib} directory into which the
5308 built/copied .py files are placed is actually architecture-dependent,
5309 and I do not yet know of a simple way to calculate its value. For many
5310 projects it is sufficient to import their libraries ``in place'' from
5311 the tree's base directory (@code{PYTHONPATH=.}).
5313 In addition, the @var{PROJECTNAME} value where the test files are
5314 located is project-dependent: it is usually just the project's
5315 top-level library directory, as common practice suggests the unit test
5316 files are put in the @code{test} sub-module. This value cannot be
5317 guessed, the @code{Trial} class must be told where to find the test
5318 files.
5320 The @code{Trial} class provides support for building and testing
5321 projects which use distutils and trial. If the test module name is
5322 specified, trial will be invoked. The library path used for testing
5323 can also be set.
5325 One advantage of trial is that the Buildbot happens to know how to
5326 parse trial output, letting it identify which tests passed and which
5327 ones failed. The Buildbot can then provide fine-grained reports about
5328 how many tests have failed, when individual tests fail when they had
5329 been passing previously, etc.
5331 Another feature of trial is that you can give it a series of source
5332 .py files, and it will search them for special @code{test-case-name}
5333 tags that indicate which test cases provide coverage for that file.
5334 Trial can then run just the appropriate tests. This is useful for
5335 quick builds, where you want to only run the test cases that cover the
5336 changed functionality.
5338 Arguments:
5339 @table @code
5340 @item source
5341 (required): A step specification tuple, like that used by GNUAutoconf.
5343 @item buildpython
5344 A list (argv array) of strings which specifies the @code{python}
5345 executable to use when building the package. Defaults to just
5346 @code{['python']}. It may be useful to add flags here, to supress
5347 warnings during compilation of extension modules. This list is
5348 extended with @code{['./setup.py', 'build']} and then executed in a
5349 ShellCommand.
5351 @item testpath
5352 Provides a directory to add to @code{PYTHONPATH} when running the unit
5353 tests, if tests are being run. Defaults to @code{.} to include the
5354 project files in-place. The generated build library is frequently
5355 architecture-dependent, but may simply be @file{build/lib} for
5356 pure-python modules.
5358 @item trialpython
5359 Another list of strings used to build the command that actually runs
5360 trial. This is prepended to the contents of the @code{trial} argument
5361 below. It may be useful to add @code{-W} flags here to supress
5362 warnings that occur while tests are being run. Defaults to an empty
5363 list, meaning @code{trial} will be run without an explicit
5364 interpreter, which is generally what you want if you're using
5365 @file{/usr/bin/trial} instead of, say, the @file{./bin/trial} that
5366 lives in the Twisted source tree.
5368 @item trial
5369 provides the name of the @code{trial} command. It is occasionally
5370 useful to use an alternate executable, such as @code{trial2.2} which
5371 might run the tests under an older version of Python. Defaults to
5372 @code{trial}.
5374 @item tests
5375 Provides a module name or names which contain the unit tests for this
5376 project. Accepts a string, typically @code{PROJECTNAME.test}, or a
5377 list of strings. Defaults to None, indicating that no tests should be
5378 run. You must either set this or @code{useTestCaseNames} to do anyting
5379 useful with the Trial factory.
5381 @item useTestCaseNames
5382 Tells the Step to provide the names of all changed .py files to trial,
5383 so it can look for test-case-name tags and run just the matching test
5384 cases. Suitable for use in quick builds. Defaults to False.
5386 @item randomly
5387 If @code{True}, tells Trial (with the @code{--random=0} argument) to
5388 run the test cases in random order, which sometimes catches subtle
5389 inter-test dependency bugs. Defaults to @code{False}.
5391 @item recurse
5392 If @code{True}, tells Trial (with the @code{--recurse} argument) to
5393 look in all subdirectories for additional test cases. It isn't clear
5394 to me how this works, but it may be useful to deal with the
5395 unknown-PROJECTNAME problem described above, and is currently used in
5396 the Twisted buildbot to accomodate the fact that test cases are now
5397 distributed through multiple twisted.SUBPROJECT.test directories.
5399 @end table  
5401 Unless one of @code{trialModule} or @code{useTestCaseNames}
5402 are set, no tests will be run.
5404 Some quick examples follow. Most of these examples assume that the
5405 target python code (the ``code under test'') can be reached directly
5406 from the root of the target tree, rather than being in a @file{lib/}
5407 subdirectory.
5409 @example
5410 #  Trial(source, tests="toplevel.test") does:
5411 #   python ./setup.py build
5412 #   PYTHONPATH=. trial -to toplevel.test
5414 #  Trial(source, tests=["toplevel.test", "other.test"]) does:
5415 #   python ./setup.py build
5416 #   PYTHONPATH=. trial -to toplevel.test other.test
5418 #  Trial(source, useTestCaseNames=True) does:
5419 #   python ./setup.py build
5420 #   PYTHONPATH=. trial -to --testmodule=foo/bar.py..  (from Changes)
5422 #  Trial(source, buildpython=["python2.3", "-Wall"], tests="foo.tests"):
5423 #   python2.3 -Wall ./setup.py build
5424 #   PYTHONPATH=. trial -to foo.tests
5426 #  Trial(source, trialpython="python2.3", trial="/usr/bin/trial",
5427 #        tests="foo.tests") does:
5428 #   python2.3 -Wall ./setup.py build
5429 #   PYTHONPATH=. python2.3 /usr/bin/trial -to foo.tests
5431 # For running trial out of the tree being tested (only useful when the
5432 # tree being built is Twisted itself):
5433 #  Trial(source, trialpython=["python2.3", "-Wall"], trial="./bin/trial",
5434 #        tests="foo.tests") does:
5435 #   python2.3 -Wall ./setup.py build
5436 #   PYTHONPATH=. python2.3 -Wall ./bin/trial -to foo.tests
5437 @end example
5439 If the output directory of @code{./setup.py build} is known, you can
5440 pull the python code from the built location instead of the source
5441 directories. This should be able to handle variations in where the
5442 source comes from, as well as accomodating binary extension modules:
5444 @example
5445 # Trial(source,tests="toplevel.test",testpath='build/lib.linux-i686-2.3')
5446 # does:
5447 #  python ./setup.py build
5448 #  PYTHONPATH=build/lib.linux-i686-2.3 trial -to toplevel.test
5449 @end example
5452 @node Status Delivery, Command-line tool, Build Process, Top
5453 @chapter Status Delivery
5455 More details are available in the docstrings for each class, use
5456 @code{pydoc buildbot.status.html.Waterfall} to see them. Most status
5457 delivery objects take a @code{categories=} argument, which can contain
5458 a list of ``category'' names: in this case, it will only show status
5459 for Builders that are in one of the named categories.
5461 (implementor's note: each of these objects should be a
5462 service.MultiService which will be attached to the BuildMaster object
5463 when the configuration is processed. They should use
5464 @code{self.parent.getStatus()} to get access to the top-level IStatus
5465 object, either inside @code{startService} or later. They may call
5466 @code{status.subscribe()} in @code{startService} to receive
5467 notifications of builder events, in which case they must define
5468 @code{builderAdded} and related methods. See the docstrings in
5469 @file{buildbot/interfaces.py} for full details.)
5471 @menu
5472 * HTML Waterfall::              
5473 * IRC Bot::                     
5474 * PBListener::                  
5475 * Writing New Status Plugins::  
5476 @end menu
5478 @c @node Email Delivery,  , Status Delivery, Status Delivery
5479 @c @subsection Email Delivery
5481 @c DOCUMENT THIS
5483 @node HTML Waterfall, IRC Bot, Status Delivery, Status Delivery
5484 @section HTML Waterfall
5486 @cindex Waterfall
5487 @stindex buildbot.status.html.Waterfall
5490 @example
5491 from buildbot.status import html
5492 w = html.Waterfall(http_port=8080)
5493 c['status'].append(w)
5494 @end example
5496 The @code{buildbot.status.html.Waterfall} status target creates an
5497 HTML ``waterfall display'', which shows a time-based chart of events.
5498 This display provides detailed information about all steps of all
5499 recent builds, and provides hyperlinks to look at individual build
5500 logs and source changes. If the @code{http_port} argument is provided,
5501 it provides a strports specification for the port that the web server
5502 should listen on. This can be a simple port number, or a string like
5503 @code{tcp:8080:interface=127.0.0.1} (to limit connections to the
5504 loopback interface, and therefore to clients running on the same
5505 host)@footnote{It may even be possible to provide SSL access by using
5506 a specification like
5507 @code{"ssl:12345:privateKey=mykey.pen:certKey=cert.pem"}, but this is
5508 completely untested}.
5510 If instead (or in addition) you provide the @code{distrib_port}
5511 argument, a twisted.web distributed server will be started either on a
5512 TCP port (if @code{distrib_port} is like @code{"tcp:12345"}) or more
5513 likely on a UNIX socket (if @code{distrib_port} is like
5514 @code{"unix:/path/to/socket"}).
5516 The @code{distrib_port} option means that, on a host with a
5517 suitably-configured twisted-web server, you do not need to consume a
5518 separate TCP port for the buildmaster's status web page. When the web
5519 server is constructed with @code{mktap web --user}, URLs that point to
5520 @code{http://host/~username/} are dispatched to a sub-server that is
5521 listening on a UNIX socket at @code{~username/.twisted-web-pb}. On
5522 such a system, it is convenient to create a dedicated @code{buildbot}
5523 user, then set @code{distrib_port} to
5524 @code{"unix:"+os.path.expanduser("~/.twistd-web-pb")}. This
5525 configuration will make the HTML status page available at
5526 @code{http://host/~buildbot/} . Suitable URL remapping can make it
5527 appear at @code{http://host/buildbot/}, and the right virtual host
5528 setup can even place it at @code{http://buildbot.host/} .
5530 Other arguments:
5532 @table @code
5533 @item allowForce
5534 If set to True (the default), then the web page will provide a ``Force
5535 Build'' button that allows visitors to manually trigger builds. This
5536 is useful for developers to re-run builds that have failed because of
5537 intermittent problems in the test suite, or because of libraries that
5538 were not installed at the time of the previous build. You may not wish
5539 to allow strangers to cause a build to run: in that case, set this to
5540 False to remove these buttons.
5542 @item favicon
5543 If set to a string, this will be interpreted as a filename containing
5544 a ``favicon'': a small image that contains an icon for the web site.
5545 This is returned to browsers that request the @code{favicon.ico} file,
5546 and should point to a .png or .ico image file. The default value uses
5547 the buildbot/buildbot.png image (a small hex nut) contained in the
5548 buildbot distribution. You can set this to None to avoid using a
5549 favicon at all.
5551 @item robots_txt
5552 If set to a string, this will be interpreted as a filename containing
5553 the contents of ``robots.txt''. Many search engine spiders request
5554 this file before indexing the site. Setting it to a file which
5555 contains:
5556 @example
5557 User-agent: *
5558 Disallow: /
5559 @end example
5560 will prevent most search engines from trawling the (voluminous)
5561 generated status pages.
5563 @end table
5566 @node IRC Bot, PBListener, HTML Waterfall, Status Delivery
5567 @section IRC Bot
5569 @cindex IRC
5570 @stindex buildbot.status.words.IRC
5573 The @code{buildbot.status.words.IRC} status target creates an IRC bot
5574 which will attach to certain channels and be available for status
5575 queries. It can also be asked to announce builds as they occur, or be
5576 told to shut up.
5578 @example
5579 from twisted.status import words
5580 irc = words.IRC("irc.example.org", "botnickname", 
5581                 channels=["channel1", "channel2"],
5582                 password="mysecretpassword")
5583 c['status'].append(irc)
5584 @end example
5586 Take a look at the docstring for @code{words.IRC} for more details on
5587 configuring this service. The @code{password} argument, if provided,
5588 will be sent to Nickserv to claim the nickname: some IRC servers will
5589 not allow clients to send private messages until they have logged in
5590 with a password.
5592 To use the service, you address messages at the buildbot, either
5593 normally (@code{botnickname: status}) or with private messages
5594 (@code{/msg botnickname status}). The buildbot will respond in kind.
5596 Some of the commands currently available:
5598 @table @code
5600 @item list builders
5601 Emit a list of all configured builders
5602 @item status BUILDER
5603 Announce the status of a specific Builder: what it is doing right now.
5604 @item status all
5605 Announce the status of all Builders
5606 @item watch BUILDER
5607 If the given Builder is currently running, wait until the Build is
5608 finished and then announce the results.
5609 @item last BUILDER
5610 Return the results of the last build to run on the given Builder.
5612 @item help COMMAND
5613 Describe a command. Use @code{help commands} to get a list of known
5614 commands.
5615 @item source
5616 Announce the URL of the Buildbot's home page.
5617 @item version
5618 Announce the version of this Buildbot.
5619 @end table
5621 If the @code{allowForce=True} option was used, some addtional commands
5622 will be available:
5624 @table @code
5625 @item force build BUILDER REASON
5626 Tell the given Builder to start a build of the latest code. The user
5627 requesting the build and REASON are recorded in the Build status. The
5628 buildbot will announce the build's status when it finishes.
5630 @item stop build BUILDER REASON
5631 Terminate any running build in the given Builder. REASON will be added
5632 to the build status to explain why it was stopped. You might use this
5633 if you committed a bug, corrected it right away, and don't want to
5634 wait for the first build (which is destined to fail) to complete
5635 before starting the second (hopefully fixed) build.
5636 @end table
5638 @node PBListener, Writing New Status Plugins, IRC Bot, Status Delivery
5639 @section PBListener
5641 @cindex PBListener
5642 @stindex buildbot.status.client.PBListener
5645 @example
5646 import buildbot.status.client
5647 pbl = buildbot.status.client.PBListener(port=int, user=str,
5648                                         passwd=str)
5649 c['status'].append(pbl)
5650 @end example
5652 This sets up a PB listener on the given TCP port, to which a PB-based
5653 status client can connect and retrieve status information.
5654 @code{buildbot statusgui} (@pxref{statusgui}) is an example of such a
5655 status client. The @code{port} argument can also be a strports
5656 specification string.
5658 @node Writing New Status Plugins,  , PBListener, Status Delivery
5659 @section Writing New Status Plugins
5661 TODO: this needs a lot more examples
5663 Each status plugin is an object which provides the
5664 @code{twisted.application.service.IService} interface, which creates a
5665 tree of Services with the buildmaster at the top [not strictly true].
5666 The status plugins are all children of an object which implements
5667 @code{buildbot.interfaces.IStatus}, the main status object. From this
5668 object, the plugin can retrieve anything it wants about current and
5669 past builds. It can also subscribe to hear about new and upcoming
5670 builds.
5672 Status plugins which only react to human queries (like the Waterfall
5673 display) never need to subscribe to anything: they are idle until
5674 someone asks a question, then wake up and extract the information they
5675 need to answer it, then they go back to sleep. Plugins which need to
5676 act spontaneously when builds complete (like the Mail plugin) need to
5677 subscribe to hear about new builds.
5679 If the status plugin needs to run network services (like the HTTP
5680 server used by the Waterfall plugin), they can be attached as Service
5681 children of the plugin itself, using the @code{IServiceCollection}
5682 interface.
5686 @node Command-line tool, Resources, Status Delivery, Top
5687 @chapter Command-line tool
5689 The @command{buildbot} command-line tool can be used to start or stop a
5690 buildmaster or buildbot, and to interact with a running buildmaster.
5691 Some of its subcommands are intended for buildmaster admins, while
5692 some are for developers who are editing the code that the buildbot is
5693 monitoring.
5695 @menu
5696 * Administrator Tools::         
5697 * Developer Tools::             
5698 * Other Tools::                 
5699 * .buildbot config directory::  
5700 @end menu
5702 @node Administrator Tools, Developer Tools, Command-line tool, Command-line tool
5703 @section Administrator Tools
5705 The following @command{buildbot} sub-commands are intended for
5706 buildmaster administrators:
5708 @heading create-master
5710 This creates a new directory and populates it with files that allow it
5711 to be used as a buildmaster's base directory.
5713 @example
5714 buildbot create-master BASEDIR
5715 @end example
5717 @heading create-slave
5719 This creates a new directory and populates it with files that let it
5720 be used as a buildslave's base directory. You must provide several
5721 arguments, which are used to create the initial @file{buildbot.tac}
5722 file.
5724 @example
5725 buildbot create-slave @var{BASEDIR} @var{MASTERHOST}:@var{PORT} @var{SLAVENAME} @var{PASSWORD}
5726 @end example
5728 @heading start
5730 This starts a buildmaster or buildslave which was already created in
5731 the given base directory. The daemon is launched in the background,
5732 with events logged to a file named @file{twistd.log}.
5734 @example
5735 buildbot start BASEDIR
5736 @end example
5738 @heading stop
5740 This terminates the daemon (either buildmaster or buildslave) running
5741 in the given directory.
5743 @example
5744 buildbot stop BASEDIR
5745 @end example
5747 @heading sighup
5749 This sends a SIGHUP to the buildmaster running in the given directory,
5750 which causes it to re-read its @file{master.cfg} file.
5752 @example
5753 buildbot sighup BASEDIR
5754 @end example
5756 @node Developer Tools, Other Tools, Administrator Tools, Command-line tool
5757 @section Developer Tools
5759 These tools are provided for use by the developers who are working on
5760 the code that the buildbot is monitoring.
5762 @menu
5763 * statuslog::                   
5764 * statusgui::                   
5765 * try::                         
5766 @end menu
5768 @node statuslog, statusgui, Developer Tools, Developer Tools
5769 @subsection statuslog
5771 @example
5772 buildbot statuslog --master @var{MASTERHOST}:@var{PORT}
5773 @end example
5775 This command starts a simple text-based status client, one which just
5776 prints out a new line each time an event occurs on the buildmaster.
5778 The @option{--master} option provides the location of the
5779 @code{buildbot.status.client.PBListener} status port, used to deliver
5780 build information to realtime status clients. The option is always in
5781 the form of a string, with hostname and port number separated by a
5782 colon (@code{HOSTNAME:PORTNUM}). Note that this port is @emph{not} the
5783 same as the slaveport (although a future version may allow the same
5784 port number to be used for both purposes). If you get an error message
5785 to the effect of ``Failure: twisted.cred.error.UnauthorizedLogin:'',
5786 this may indicate that you are connecting to the slaveport rather than
5787 a @code{PBListener} port.
5789 The @option{--master} option can also be provided by the
5790 @code{masterstatus} name in @file{.buildbot/options} (@pxref{.buildbot
5791 config directory}).
5793 @node statusgui, try, statuslog, Developer Tools
5794 @subsection statusgui
5796 @cindex statusgui
5798 If you have set up a PBListener (@pxref{PBListener}), you will be able
5799 to monitor your Buildbot using a simple Gtk+ application invoked with
5800 the @code{buildbot statusgui} command:
5802 @example
5803 buildbot statusgui --master @var{MASTERHOST}:@var{PORT}
5804 @end example
5806 This command starts a simple Gtk+-based status client, which contains
5807 a few boxes for each Builder that change color as events occur. It
5808 uses the same @option{--master} argument as the @command{buildbot
5809 statuslog} command (@pxref{statuslog}).
5811 @node try,  , statusgui, Developer Tools
5812 @subsection try
5814 This lets a developer to ask the question ``What would happen if I
5815 committed this patch right now?''. It runs the unit test suite (across
5816 multiple build platforms) on the developer's current code, allowing
5817 them to make sure they will not break the tree when they finally
5818 commit their changes.
5820 The @command{buildbot try} command is meant to be run from within a
5821 developer's local tree, and starts by figuring out the base revision
5822 of that tree (what revision was current the last time the tree was
5823 updated), and a patch that can be applied to that revision of the tree
5824 to make it match the developer's copy. This (revision, patch) pair is
5825 then sent to the buildmaster, which runs a build with that
5826 SourceStamp. If you want, the tool will emit status messages as the
5827 builds run, and will not terminate until the first failure has been
5828 detected (or the last success).
5830 For this command to work, several pieces must be in place:
5833 @heading TryScheduler
5835 @slindex buildbot.scheduler.Try_Jobdir
5836 @slindex buildbot.scheduler.Try_Userpass
5838 The buildmaster must have a @code{scheduler.Try} instance in
5839 the config file's @code{c['schedulers']} list. This lets the
5840 administrator control who may initiate these ``trial'' builds, which
5841 branches are eligible for trial builds, and which Builders should be
5842 used for them.
5844 The @code{TryScheduler} has various means to accept build requests:
5845 all of them enforce more security than the usual buildmaster ports do.
5846 Any source code being built can be used to compromise the buildslave
5847 accounts, but in general that code must be checked out from the VC
5848 repository first, so only people with commit privileges can get
5849 control of the buildslaves. The usual force-build control channels can
5850 waste buildslave time but do not allow arbitrary commands to be
5851 executed by people who don't have those commit privileges. However,
5852 the source code patch that is provided with the trial build does not
5853 have to go through the VC system first, so it is important to make
5854 sure these builds cannot be abused by a non-committer to acquire as
5855 much control over the buildslaves as a committer has. Ideally, only
5856 developers who have commit access to the VC repository would be able
5857 to start trial builds, but unfortunately the buildmaster does not, in
5858 general, have access to VC system's user list.
5860 As a result, the @code{TryScheduler} requires a bit more
5861 configuration. There are currently two ways to set this up:
5863 @table @strong
5864 @item jobdir (ssh)
5866 This approach creates a command queue directory, called the
5867 ``jobdir'', in the buildmaster's working directory. The buildmaster
5868 admin sets the ownership and permissions of this directory to only
5869 grant write access to the desired set of developers, all of whom must
5870 have accounts on the machine. The @code{buildbot try} command creates
5871 a special file containing the source stamp information and drops it in
5872 the jobdir, just like a standard maildir. When the buildmaster notices
5873 the new file, it unpacks the information inside and starts the builds.
5875 The config file entries used by 'buildbot try' either specify a local
5876 queuedir (for which write and mv are used) or a remote one (using scp
5877 and ssh).
5879 The advantage of this scheme is that it is quite secure, the
5880 disadvantage is that it requires fiddling outside the buildmaster
5881 config (to set the permissions on the jobdir correctly). If the
5882 buildmaster machine happens to also house the VC repository, then it
5883 can be fairly easy to keep the VC userlist in sync with the
5884 trial-build userlist. If they are on different machines, this will be
5885 much more of a hassle. It may also involve granting developer accounts
5886 on a machine that would not otherwise require them.
5888 To implement this, the buildslave invokes 'ssh -l username host
5889 buildbot tryserver ARGS', passing the patch contents over stdin. The
5890 arguments must include the inlet directory and the revision
5891 information.
5893 @item user+password (PB)
5895 In this approach, each developer gets a username/password pair, which
5896 are all listed in the buildmaster's configuration file. When the
5897 developer runs @code{buildbot try}, their machine connects to the
5898 buildmaster via PB and authenticates themselves using that username
5899 and password, then sends a PB command to start the trial build.
5901 The advantage of this scheme is that the entire configuration is
5902 performed inside the buildmaster's config file. The disadvantages are
5903 that it is less secure (while the ``cred'' authentication system does
5904 not expose the password in plaintext over the wire, it does not offer
5905 most of the other security properties that SSH does). In addition, the
5906 buildmaster admin is responsible for maintaining the username/password
5907 list, adding and deleting entries as developers come and go.
5909 @end table
5912 For example, to set up the ``jobdir'' style of trial build, using a
5913 command queue directory of @file{MASTERDIR/jobdir} (and assuming that
5914 all your project developers were members of the @code{developers} unix
5915 group), you would first create that directory (with @command{mkdir
5916 MASTERDIR/jobdir MASTERDIR/jobdir/new MASTERDIR/jobdir/cur
5917 MASTERDIR/jobdir/tmp; chgrp developers MASTERDIR/jobdir
5918 MASTERDIR/jobdir/*; chmod g+rwx,o-rwx MASTERDIR/jobdir
5919 MASTERDIR/jobdir/*}), and then use the following scheduler in the
5920 buildmaster's config file:
5922 @example
5923 from buildbot.scheduler import Try_Jobdir
5924 s = Try_Jobdir("try1", ["full-linux", "full-netbsd", "full-OSX"],
5925                jobdir="jobdir")
5926 c['schedulers'] = [s]
5927 @end example
5929 Note that you must create the jobdir before telling the buildmaster to
5930 use this configuration, otherwise you will get an error. Also remember
5931 that the buildmaster must be able to read and write to the jobdir as
5932 well. Be sure to watch the @file{twistd.log} file (@pxref{Logfiles})
5933 as you start using the jobdir, to make sure the buildmaster is happy
5934 with it.
5936 To use the username/password form of authentication, create a
5937 @code{Try_Userpass} instance instead. It takes the same
5938 @code{builderNames} argument as the @code{Try_Jobdir} form, but
5939 accepts an addtional @code{port} argument (to specify the TCP port to
5940 listen on) and a @code{userpass} list of username/password pairs to
5941 accept. Remember to use good passwords for this: the security of the
5942 buildslave accounts depends upon it:
5944 @example
5945 from buildbot.scheduler import Try_Userpass
5946 s = Try_Userpass("try2", ["full-linux", "full-netbsd", "full-OSX"],
5947                  port=8031, userpass=[("alice","pw1"), ("bob", "pw2")] )
5948 c['schedulers'] = [s]
5949 @end example
5951 Like most places in the buildbot, the @code{port} argument takes a
5952 strports specification. See @code{twisted.application.strports} for
5953 details.
5956 @heading locating the master
5958 The @command{try} command needs to be told how to connect to the
5959 @code{TryScheduler}, and must know which of the authentication
5960 approaches described above is in use by the buildmaster. You specify
5961 the approach by using @option{--connect=ssh} or @option{--connect=pb}
5962 (or @code{try_connect = 'ssh'} or @code{try_connect = 'pb'} in
5963 @file{.buildbot/options}).
5965 For the PB approach, the command must be given a @option{--master}
5966 argument (in the form HOST:PORT) that points to TCP port that you
5967 picked in the @code{Try_Userpass} scheduler. It also takes a
5968 @option{--username} and @option{--passwd} pair of arguments that match
5969 one of the entries in the buildmaster's @code{userpass} list. These
5970 arguments can also be provided as @code{try_master},
5971 @code{try_username}, and @code{try_password} entries in the
5972 @file{.buildbot/options} file.
5974 For the SSH approach, the command must be given @option{--tryhost},
5975 @option{--username}, and optionally @option{--password} (TODO:
5976 really?) to get to the buildmaster host. It must also be given
5977 @option{--trydir}, which points to the inlet directory configured
5978 above. The trydir can be relative to the user's home directory, but
5979 most of the time you will use an explicit path like
5980 @file{~buildbot/project/trydir}. These arguments can be provided in
5981 @file{.buildbot/options} as @code{try_host}, @code{try_username},
5982 @code{try_password}, and @code{try_dir}.
5984 In addition, the SSH approach needs to connect to a PBListener status
5985 port, so it can retrieve and report the results of the build (the PB
5986 approach uses the existing connection to retrieve status information,
5987 so this step is not necessary). This requires a @option{--master}
5988 argument, or a @code{masterstatus} entry in @file{.buildbot/options},
5989 in the form of a HOSTNAME:PORT string.
5992 @heading choosing the Builders
5994 A trial build is performed on multiple Builders at the same time, and
5995 the developer gets to choose which Builders are used (limited to a set
5996 selected by the buildmaster admin with the TryScheduler's
5997 @code{builderNames=} argument). The set you choose will depend upon
5998 what your goals are: if you are concerned about cross-platform
5999 compatibility, you should use multiple Builders, one from each
6000 platform of interest. You might use just one builder if that platform
6001 has libraries or other facilities that allow better test coverage than
6002 what you can accomplish on your own machine, or faster test runs.
6004 The set of Builders to use can be specified with multiple
6005 @option{--builder} arguments on the command line. It can also be
6006 specified with a single @code{try_builders} option in
6007 @file{.buildbot/options} that uses a list of strings to specify all
6008 the Builder names:
6010 @example
6011 try_builders = ["full-OSX", "full-win32", "full-linux"]
6012 @end example
6014 @heading specifying the VC system
6016 The @command{try} command also needs to know how to take the
6017 developer's current tree and extract the (revision, patch)
6018 source-stamp pair. Each VC system uses a different process, so you
6019 start by telling the @command{try} command which VC system you are
6020 using, with an argument like @option{--vc=cvs} or @option{--vc=tla}.
6021 This can also be provided as @code{try_vc} in
6022 @file{.buildbot/options}.
6024 The following names are recognized: @code{cvs} @code{svn} @code{baz}
6025 @code{tla} @code{hg} @code{darcs}
6028 @heading finding the top of the tree
6030 Some VC systems (notably CVS and SVN) track each directory
6031 more-or-less independently, which means the @command{try} command
6032 needs to move up to the top of the project tree before it will be able
6033 to construct a proper full-tree patch. To accomplish this, the
6034 @command{try} command will crawl up through the parent directories
6035 until it finds a marker file. The default name for this marker file is
6036 @file{.buildbot-top}, so when you are using CVS or SVN you should
6037 @code{touch .buildbot-top} from the top of your tree before running
6038 @command{buildbot try}. Alternatively, you can use a filename like
6039 @file{ChangeLog} or @file{README}, since many projects put one of
6040 these files in their top-most directory (and nowhere else). To set
6041 this filename, use @option{--try-topfile=ChangeLog}, or set it in the
6042 options file with @code{try_topfile = 'ChangeLog'}.
6044 You can also manually set the top of the tree with
6045 @option{--try-topdir=~/trees/mytree}, or @code{try_topdir =
6046 '~/trees/mytree'}. If you use @code{try_topdir}, in a
6047 @file{.buildbot/options} file, you will need a separate options file
6048 for each tree you use, so it may be more convenient to use the
6049 @code{try_topfile} approach instead.
6051 Other VC systems which work on full projects instead of individual
6052 directories (tla, baz, darcs, monotone, mercurial) do not require
6053 @command{try} to know the top directory, so the @option{--try-topfile}
6054 and @option{--try-topdir} arguments will be ignored.
6055 @c is this true? I think I currently require topdirs all the time.
6057 If the @command{try} command cannot find the top directory, it will
6058 abort with an error message.
6060 @heading determining the branch name
6062 Some VC systems record the branch information in a way that ``try''
6063 can locate it, in particular Arch (both @command{tla} and
6064 @command{baz}). For the others, if you are using something other than
6065 the default branch, you will have to tell the buildbot which branch
6066 your tree is using. You can do this with either the @option{--branch}
6067 argument, or a @option{try_branch} entry in the
6068 @file{.buildbot/options} file.
6070 @heading determining the revision and patch
6072 Each VC system has a separate approach for determining the tree's base
6073 revision and computing a patch.
6075 @table @code
6077 @item CVS
6079 @command{try} pretends that the tree is up to date. It converts the
6080 current time into a @code{-D} time specification, uses it as the base
6081 revision, and computes the diff between the upstream tree as of that
6082 point in time versus the current contents. This works, more or less,
6083 but requires that the local clock be in reasonably good sync with the
6084 repository.
6086 @item SVN
6087 @command{try} does a @code{svn status -u} to find the latest
6088 repository revision number (emitted on the last line in the ``Status
6089 against revision: NN'' message). It then performs an @code{svn diff
6090 -rNN} to find out how your tree differs from the repository version,
6091 and sends the resulting patch to the buildmaster. If your tree is not
6092 up to date, this will result in the ``try'' tree being created with
6093 the latest revision, then @emph{backwards} patches applied to bring it
6094 ``back'' to the version you actually checked out (plus your actual
6095 code changes), but this will still result in the correct tree being
6096 used for the build.
6098 @item baz
6099 @command{try} does a @code{baz tree-id} to determine the
6100 fully-qualified version and patch identifier for the tree
6101 (ARCHIVE/VERSION--patch-NN), and uses the VERSION--patch-NN component
6102 as the base revision. It then does a @code{baz diff} to obtain the
6103 patch.
6105 @item tla
6106 @command{try} does a @code{tla tree-version} to get the
6107 fully-qualified version identifier (ARCHIVE/VERSION), then takes the
6108 first line of @code{tla logs --reverse} to figure out the base
6109 revision. Then it does @code{tla changes --diffs} to obtain the patch.
6111 @item Darcs
6112 @code{darcs changes --context} emits a text file that contains a list
6113 of all patches back to and including the last tag was made. This text
6114 file (plus the location of a repository that contains all these
6115 patches) is sufficient to re-create the tree. Therefore the contents
6116 of this ``context'' file @emph{are} the revision stamp for a
6117 Darcs-controlled source tree.
6119 So @command{try} does a @code{darcs changes --context} to determine
6120 what your tree's base revision is, and then does a @code{darcs diff
6121 -u} to compute the patch relative to that revision.
6123 @item Mercurial
6124 @code{hg identify} emits a short revision ID (basically a truncated
6125 SHA1 hash of the current revision's contents), which is used as the
6126 base revision. @code{hg diff} then provides the patch relative to that
6127 revision. For @command{try} to work, your working directory must only
6128 have patches that are available from the same remotely-available
6129 repository that the build process' @code{step.Mercurial} will use.
6131 @c TODO: monotone, git
6132 @end table
6134 @heading waiting for results
6136 If you provide the @option{--wait} option (or @code{try_wait = True}
6137 in @file{.buildbot/options}), the @command{buildbot try} command will
6138 wait until your changes have either been proven good or bad before
6139 exiting. Unless you use the @option{--quiet} option (or
6140 @code{try_quiet=True}), it will emit a progress message every 60
6141 seconds until the builds have completed.
6144 @node Other Tools, .buildbot config directory, Developer Tools, Command-line tool
6145 @section Other Tools
6147 These tools are generally used by buildmaster administrators.
6149 @menu
6150 * sendchange::                  
6151 * debugclient::                 
6152 @end menu
6154 @node sendchange, debugclient, Other Tools, Other Tools
6155 @subsection sendchange
6157 This command is used to tell the buildmaster about source changes. It
6158 is intended to be used from within a commit script, installed on the
6159 VC server. It requires that you have a PBChangeSource
6160 (@pxref{PBChangeSource}) running in the buildmaster (by being included
6161 in the @code{c['sources']} list).
6164 @example
6165 buildbot sendchange --master @var{MASTERHOST}:@var{PORT} --username @var{USER} @var{FILENAMES..}
6166 @end example
6168 There are other (optional) arguments which can influence the
6169 @code{Change} that gets submitted:
6171 @table @code
6172 @item --branch
6173 This provides the (string) branch specifier. If omitted, it defaults
6174 to None, indicating the ``default branch''. All files included in this
6175 Change must be on the same branch.
6177 @item --revision_number
6178 This provides a (numeric) revision number for the change, used for VC systems
6179 that use numeric transaction numbers (like Subversion).
6181 @item --revision
6182 This provides a (string) revision specifier, for VC systems that use
6183 strings (Arch would use something like patch-42 etc).
6185 @item --revision_file
6186 This provides a filename which will be opened and the contents used as
6187 the revision specifier. This is specifically for Darcs, which uses the
6188 output of @command{darcs changes --context} as a revision specifier.
6189 This context file can be a couple of kilobytes long, spanning a couple
6190 lines per patch, and would be a hassle to pass as a command-line
6191 argument.
6193 @item --comments
6194 This provides the change comments as a single argument. You may want
6195 to use @option{--logfile} instead.
6197 @item --logfile
6198 This instructs the tool to read the change comments from the given
6199 file. If you use @code{-} as the filename, the tool will read the
6200 change comments from stdin.
6201 @end table
6204 @node debugclient,  , sendchange, Other Tools
6205 @subsection debugclient
6207 @example
6208 buildbot debugclient --master @var{MASTERHOST}:@var{PORT} --passwd @var{DEBUGPW}
6209 @end example
6211 This launches a small Gtk+/Glade-based debug tool, connecting to the
6212 buildmaster's ``debug port''. This debug port shares the same port
6213 number as the slaveport (@pxref{Setting the slaveport}), but the
6214 @code{debugPort} is only enabled if you set a debug password in the
6215 buildmaster's config file (@pxref{Debug options}). The
6216 @option{--passwd} option must match the @code{c['debugPassword']}
6217 value.
6219 @option{--master} can also be provided in @file{.debug/options} by the
6220 @code{master} key. @option{--passwd} can be provided by the
6221 @code{debugPassword} key.
6223 The @code{Connect} button must be pressed before any of the other
6224 buttons will be active. This establishes the connection to the
6225 buildmaster. The other sections of the tool are as follows:
6227 @table @code
6228 @item Reload .cfg
6229 Forces the buildmaster to reload its @file{master.cfg} file. This is
6230 equivalent to sending a SIGHUP to the buildmaster, but can be done
6231 remotely through the debug port. Note that it is a good idea to be
6232 watching the buildmaster's @file{twistd.log} as you reload the config
6233 file, as any errors which are detected in the config file will be
6234 announced there.
6236 @item Rebuild .py
6237 (not yet implemented). The idea here is to use Twisted's ``rebuild''
6238 facilities to replace the buildmaster's running code with a new
6239 version. Even if this worked, it would only be used by buildbot
6240 developers.
6242 @item poke IRC
6243 This locates a @code{words.IRC} status target and causes it to emit a
6244 message on all the channels to which it is currently connected. This
6245 was used to debug a problem in which the buildmaster lost the
6246 connection to the IRC server and did not attempt to reconnect.
6248 @item Commit
6249 This allows you to inject a Change, just as if a real one had been
6250 delivered by whatever VC hook you are using. You can set the name of
6251 the committed file and the name of the user who is doing the commit.
6252 Optionally, you can also set a revision for the change. If the
6253 revision you provide looks like a number, it will be sent as an
6254 integer, otherwise it will be sent as a string.
6256 @item Force Build
6257 This lets you force a Builder (selected by name) to start a build of
6258 the current source tree.
6260 @item Currently
6261 (obsolete). This was used to manually set the status of the given
6262 Builder, but the status-assignment code was changed in an incompatible
6263 way and these buttons are no longer meaningful.
6265 @end table
6268 @node .buildbot config directory,  , Other Tools, Command-line tool
6269 @section .buildbot config directory
6271 Many of the @command{buildbot} tools must be told how to contact the
6272 buildmaster that they interact with. This specification can be
6273 provided as a command-line argument, but most of the time it will be
6274 easier to set them in an ``options'' file. The @command{buildbot}
6275 command will look for a special directory named @file{.buildbot},
6276 starting from the current directory (where the command was run) and
6277 crawling upwards, eventually looking in the user's home directory. It
6278 will look for a file named @file{options} in this directory, and will
6279 evaluate it as a python script, looking for certain names to be set.
6280 You can just put simple @code{name = 'value'} pairs in this file to
6281 set the options.
6283 For a description of the names used in this file, please see the
6284 documentation for the individual @command{buildbot} sub-commands. The
6285 following is a brief sample of what this file's contents could be.
6287 @example
6288 # for status-reading tools
6289 masterstatus = 'buildbot.example.org:12345'
6290 # for 'sendchange' or the debug port
6291 master = 'buildbot.example.org:18990'
6292 debugPassword = 'eiv7Po'
6293 @end example
6295 @table @code
6296 @item masterstatus
6297 Location of the @code{client.PBListener} status port, used by
6298 @command{statuslog} and @command{statusgui}.
6300 @item master
6301 Location of the @code{debugPort} (for @command{debugclient}). Also the
6302 location of the @code{pb.PBChangeSource} (for @command{sendchange}).
6303 Usually shares the slaveport, but a future version may make it
6304 possible to have these listen on a separate port number.
6306 @item debugPassword
6307 Must match the value of @code{c['debugPassword']}, used to protect the
6308 debug port, for the @command{debugclient} command.
6310 @item username
6311 Provides a default username for the @command{sendchange} command.
6313 @end table
6316 The following options are used by the @code{buildbot try} command
6317 (@pxref{try}):
6319 @table @code
6320 @item try_connect
6321 This specifies how the ``try'' command should deliver its request to
6322 the buildmaster. The currently accepted values are ``ssh'' and ``pb''.
6323 @item try_builders
6324 Which builders should be used for the ``try'' build.
6325 @item try_vc
6326 This specifies the version control system being used.
6327 @item try_branch
6328 This indicates that the current tree is on a non-trunk branch.
6329 @item try_topdir
6330 @item try_topfile
6331 Use @code{try_topdir} to explicitly indicate the top of your working
6332 tree, or @code{try_topfile} to name a file that will only be found in
6333 that top-most directory.
6335 @item try_host
6336 @item try_username
6337 @item try_dir
6338 When try_connect is ``ssh'', the command will pay attention to
6339 @code{try_host}, @code{try_username}, and @code{try_dir}.
6341 @item try_username
6342 @item try_password
6343 @item try_master
6344 Instead, when @code{try_connect} is ``pb'', the command will pay
6345 attention to @code{try_username}, @code{try_password}, and
6346 @code{try_master}.
6348 @item try_wait
6349 @item masterstatus
6350 @code{try_wait} and @code{masterstatus} are used to ask the ``try''
6351 command to wait for the requested build to complete.
6353 @end table
6357 @node Resources, Developer's Appendix, Command-line tool, Top
6358 @chapter Resources
6360 The Buildbot's home page is at @uref{http://buildbot.sourceforge.net/}
6362 For configuration questions and general discussion, please use the
6363 @code{buildbot-devel} mailing list. The subscription instructions and
6364 archives are available at
6365 @uref{http://lists.sourceforge.net/lists/listinfo/buildbot-devel}
6367 @node Developer's Appendix, Index of Useful Classes, Resources, Top
6368 @unnumbered Developer's Appendix
6370 This appendix contains random notes about the implementation of the
6371 Buildbot, and is likely to only be of use to people intending to
6372 extend the Buildbot's internals.
6374 The buildmaster consists of a tree of Service objects, which is shaped
6375 as follows:
6377 @example
6378 BuildMaster
6379  ChangeMaster  (in .change_svc)
6380   [IChangeSource instances]
6381  [IScheduler instances]  (in .schedulers)
6382  BotMaster  (in .botmaster)
6383  [IStatusTarget instances]  (in .statusTargets)
6384 @end example
6386 The BotMaster has a collection of Builder objects as values of its
6387 @code{.builders} dictionary.
6390 @node Index of Useful Classes, Index of master.cfg keys, Developer's Appendix, Top
6391 @unnumbered Index of Useful Classes
6393 This is a list of all user-visible classes. There are the ones that
6394 are useful in @file{master.cfg}, the buildmaster's configuration file.
6395 Classes that are not listed here are generally internal things that
6396 admins are unlikely to have much use for.
6399 @heading Change Sources
6400 @printindex cs
6402 @heading Schedulers and Locks
6403 @printindex sl
6405 @heading Build Factories
6406 @printindex bf
6408 @heading Build Steps
6409 @printindex bs
6411 @c undocumented steps
6412 @bsindex buildbot.steps.source.Git
6413 @bsindex buildbot.steps.maxq.MaxQ
6416 @heading Status Targets
6417 @printindex st
6419 @c TODO: undocumented targets
6420 @stindex buildbot.status.mail.MailNotifier
6422 @node Index of master.cfg keys, Index, Index of Useful Classes, Top
6423 @unnumbered Index of master.cfg keys
6425 This is a list of all of the significant keys in master.cfg . Recall
6426 that master.cfg is effectively a small python program one
6427 responsibility: create a dictionary named @code{BuildmasterConfig}.
6428 The keys of this dictionary are listed here. The beginning of the
6429 master.cfg file typically starts with something like:
6431 @example
6432 BuildmasterConfig = c = @{@}
6433 @end example
6435 Therefore a config key of @code{sources} will usually appear in
6436 master.cfg as @code{c['sources']}.
6438 @printindex bc
6441 @node Index,  , Index of master.cfg keys, Top
6442 @unnumbered Index
6444 @printindex cp
6447 @bye