try: update docs, remove some dead code
[buildbot.git] / docs / buildbot.texinfo
blob6cf205d5e93837c3d7a79746e4ef94fcd3fbd914
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename buildbot.info
4 @settitle BuildBot Manual 0.7.4+
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::                
157 Build Process
159 * Build Steps::                 
160 * Interlocks::                  
161 * Build Factories::             
163 Build Steps
165 * Common Parameters::           
166 * Source Checkout::             
167 * ShellCommand::                
168 * Simple ShellCommand Subclasses::  
169 * Python BuildSteps::           
170 * Transferring Files::          
171 * Writing New BuildSteps::      
173 Source Checkout
175 * CVS::                         
176 * SVN::                         
177 * Darcs::                       
178 * Mercurial::                   
179 * Arch::                        
180 * Bazaar::                      
181 * P4::                          
183 Simple ShellCommand Subclasses
185 * Configure::                   
186 * Compile::                     
187 * Test::                        
188 * Build Properties::            
190 Python BuildSteps
192 * BuildEPYDoc::                 
193 * PyFlakes::                    
195 Writing New BuildSteps
197 * BuildStep LogFiles::          
198 * Adding LogObservers::         
199 * BuildStep URLs::              
201 Build Factories
203 * BuildStep Objects::           
204 * BuildFactory::                
205 * Process-Specific build factories::  
207 BuildStep Objects
209 * BuildFactory Attributes::     
210 * Quick builds::                
212 BuildFactory
214 * BuildFactory Attributes::     
215 * Quick builds::                
217 Process-Specific build factories
219 * GNUAutoconf::                 
220 * CPAN::                        
221 * Python distutils::            
222 * Python/Twisted/trial projects::  
224 Status Delivery
226 * HTML Waterfall::              
227 * IRC Bot::                     
228 * PBListener::                  
229 * Writing New Status Plugins::  
231 Command-line tool
233 * Administrator Tools::         
234 * Developer Tools::             
235 * Other Tools::                 
236 * .buildbot config directory::  
238 Developer Tools
240 * statuslog::                   
241 * statusgui::                   
242 * try::                         
244 Other Tools
246 * sendchange::                  
247 * debugclient::                 
249 @end detailmenu
250 @end menu
252 @node Introduction, Installation, Top, Top
253 @chapter Introduction
255 @cindex introduction
257 The BuildBot is a system to automate the compile/test cycle required by most
258 software projects to validate code changes. By automatically rebuilding and
259 testing the tree each time something has changed, build problems are
260 pinpointed quickly, before other developers are inconvenienced by the
261 failure. The guilty developer can be identified and harassed without human
262 intervention. By running the builds on a variety of platforms, developers
263 who do not have the facilities to test their changes everywhere before
264 checkin will at least know shortly afterwards whether they have broken the
265 build or not. Warning counts, lint checks, image size, compile time, and
266 other build parameters can be tracked over time, are more visible, and
267 are therefore easier to improve.
269 The overall goal is to reduce tree breakage and provide a platform to
270 run tests or code-quality checks that are too annoying or pedantic for
271 any human to waste their time with. Developers get immediate (and
272 potentially public) feedback about their changes, encouraging them to
273 be more careful about testing before checkin.
275 Features:
277 @itemize @bullet
278 @item
279 run builds on a variety of slave platforms
280 @item
281 arbitrary build process: handles projects using C, Python, whatever
282 @item
283 minimal host requirements: python and Twisted
284 @item
285 slaves can be behind a firewall if they can still do checkout
286 @item
287 status delivery through web page, email, IRC, other protocols
288 @item
289 track builds in progress, provide estimated completion time
290 @item
291 flexible configuration by subclassing generic build process classes
292 @item
293 debug tools to force a new build, submit fake Changes, query slave status
294 @item
295 released under the GPL
296 @end itemize
298 @menu
299 * History and Philosophy::      
300 * System Architecture::         
301 * Control Flow::                
302 @end menu
305 @node History and Philosophy, System Architecture, Introduction, Introduction
306 @section History and Philosophy
308 @cindex Philosophy of operation
310 The Buildbot was inspired by a similar project built for a development
311 team writing a cross-platform embedded system. The various components
312 of the project were supposed to compile and run on several flavors of
313 unix (linux, solaris, BSD), but individual developers had their own
314 preferences and tended to stick to a single platform. From time to
315 time, incompatibilities would sneak in (some unix platforms want to
316 use @code{string.h}, some prefer @code{strings.h}), and then the tree
317 would compile for some developers but not others. The buildbot was
318 written to automate the human process of walking into the office,
319 updating a tree, compiling (and discovering the breakage), finding the
320 developer at fault, and complaining to them about the problem they had
321 introduced. With multiple platforms it was difficult for developers to
322 do the right thing (compile their potential change on all platforms);
323 the buildbot offered a way to help.
325 Another problem was when programmers would change the behavior of a
326 library without warning its users, or change internal aspects that
327 other code was (unfortunately) depending upon. Adding unit tests to
328 the codebase helps here: if an application's unit tests pass despite
329 changes in the libraries it uses, you can have more confidence that
330 the library changes haven't broken anything. Many developers
331 complained that the unit tests were inconvenient or took too long to
332 run: having the buildbot run them reduces the developer's workload to
333 a minimum.
335 In general, having more visibility into the project is always good,
336 and automation makes it easier for developers to do the right thing.
337 When everyone can see the status of the project, developers are
338 encouraged to keep the tree in good working order. Unit tests that
339 aren't run on a regular basis tend to suffer from bitrot just like
340 code does: exercising them on a regular basis helps to keep them
341 functioning and useful.
343 The current version of the Buildbot is additionally targeted at
344 distributed free-software projects, where resources and platforms are
345 only available when provided by interested volunteers. The buildslaves
346 are designed to require an absolute minimum of configuration, reducing
347 the effort a potential volunteer needs to expend to be able to
348 contribute a new test environment to the project. The goal is for
349 anyone who wishes that a given project would run on their favorite
350 platform should be able to offer that project a buildslave, running on
351 that platform, where they can verify that their portability code
352 works, and keeps working.
354 @node System Architecture, Control Flow, History and Philosophy, Introduction
355 @comment  node-name,  next,  previous,  up
356 @section System Architecture
358 The Buildbot consists of a single @code{buildmaster} and one or more
359 @code{buildslaves}, connected in a star topology. The buildmaster
360 makes all decisions about what, when, and how to build. It sends
361 commands to be run on the build slaves, which simply execute the
362 commands and return the results. (certain steps involve more local
363 decision making, where the overhead of sending a lot of commands back
364 and forth would be inappropriate, but in general the buildmaster is
365 responsible for everything).
367 The buildmaster is usually fed @code{Changes} by some sort of version
368 control system (@pxref{Change Sources}), which may cause builds to be
369 run. As the builds are performed, various status messages are
370 produced, which are then sent to any registered Status Targets
371 (@pxref{Status Delivery}).
373 @c @image{FILENAME, WIDTH, HEIGHT, ALTTEXT, EXTENSION}
374 @image{images/overview,,,Overview Diagram,}
376 The buildmaster is configured and maintained by the ``buildmaster
377 admin'', who is generally the project team member responsible for
378 build process issues. Each buildslave is maintained by a ``buildslave
379 admin'', who do not need to be quite as involved. Generally slaves are
380 run by anyone who has an interest in seeing the project work well on
381 their favorite platform.
383 @menu
384 * BuildSlave Connections::      
385 * Buildmaster Architecture::    
386 * Status Delivery Architecture::  
387 @end menu
389 @node BuildSlave Connections, Buildmaster Architecture, System Architecture, System Architecture
390 @subsection BuildSlave Connections
392 The buildslaves are typically run on a variety of separate machines,
393 at least one per platform of interest. These machines connect to the
394 buildmaster over a TCP connection to a publically-visible port. As a
395 result, the buildslaves can live behind a NAT box or similar
396 firewalls, as long as they can get to buildmaster. The TCP connections
397 are initiated by the buildslave and accepted by the buildmaster, but
398 commands and results travel both ways within this connection. The
399 buildmaster is always in charge, so all commands travel exclusively
400 from the buildmaster to the buildslave.
402 To perform builds, the buildslaves must typically obtain source code
403 from a CVS/SVN/etc repository. Therefore they must also be able to
404 reach the repository. The buildmaster provides instructions for
405 performing builds, but does not provide the source code itself.
407 @image{images/slaves,,,BuildSlave Connections,}
409 @node Buildmaster Architecture, Status Delivery Architecture, BuildSlave Connections, System Architecture
410 @subsection Buildmaster Architecture
412 The Buildmaster consists of several pieces:
414 @image{images/master,,,BuildMaster Architecture,}
416 @itemize @bullet
418 @item
419 Change Sources, which create a Change object each time something is
420 modified in the VC repository. Most ChangeSources listen for messages
421 from a hook script of some sort. Some sources actively poll the
422 repository on a regular basis. All Changes are fed to the Schedulers.
424 @item
425 Schedulers, which decide when builds should be performed. They collect
426 Changes into BuildRequests, which are then queued for delivery to
427 Builders until a buildslave is available.
429 @item
430 Builders, which control exactly @emph{how} each build is performed
431 (with a series of BuildSteps, configured in a BuildFactory). Each
432 Build is run on a single buildslave.
434 @item
435 Status plugins, which deliver information about the build results
436 through protocols like HTTP, mail, and IRC.
438 @end itemize
440 @image{images/slavebuilder,,,SlaveBuilders,}
442 Each Builder is configured with a list of BuildSlaves that it will use
443 for its builds. These buildslaves are expected to behave identically:
444 the only reason to use multiple BuildSlaves for a single Builder is to
445 provide a measure of load-balancing.
447 Within a single BuildSlave, each Builder creates its own SlaveBuilder
448 instance. These SlaveBuilders operate independently from each other.
449 Each gets its own base directory to work in. It is quite common to
450 have many Builders sharing the same buildslave. For example, there
451 might be two buildslaves: one for i386, and a second for PowerPC.
452 There may then be a pair of Builders that do a full compile/test run,
453 one for each architecture, and a lone Builder that creates snapshot
454 source tarballs if the full builders complete successfully. The full
455 builders would each run on a single buildslave, whereas the tarball
456 creation step might run on either buildslave (since the platform
457 doesn't matter when creating source tarballs). In this case, the
458 mapping would look like:
460 @example
461 Builder(full-i386)  ->  BuildSlaves(slave-i386)
462 Builder(full-ppc)   ->  BuildSlaves(slave-ppc)
463 Builder(source-tarball) -> BuildSlaves(slave-i386, slave-ppc)
464 @end example
466 and each BuildSlave would have two SlaveBuilders inside it, one for a
467 full builder, and a second for the source-tarball builder.
469 Once a SlaveBuilder is available, the Builder pulls one or more
470 BuildRequests off its incoming queue. (It may pull more than one if it
471 determines that it can merge the requests together; for example, there
472 may be multiple requests to build the current HEAD revision). These
473 requests are merged into a single Build instance, which includes the
474 SourceStamp that describes what exact version of the source code
475 should be used for the build. The Build is then assigned to a
476 SlaveBuilder and the build begins.
479 @node Status Delivery Architecture,  , Buildmaster Architecture, System Architecture
480 @subsection Status Delivery Architecture
482 The buildmaster maintains a central Status object, to which various
483 status plugins are connected. Through this Status object, a full
484 hierarchy of build status objects can be obtained.
486 @image{images/status,,,Status Delivery,}
488 The configuration file controls which status plugins are active. Each
489 status plugin gets a reference to the top-level Status object. From
490 there they can request information on each Builder, Build, Step, and
491 LogFile. This query-on-demand interface is used by the html.Waterfall
492 plugin to create the main status page each time a web browser hits the
493 main URL.
495 The status plugins can also subscribe to hear about new Builds as they
496 occur: this is used by the MailNotifier to create new email messages
497 for each recently-completed Build.
499 The Status object records the status of old builds on disk in the
500 buildmaster's base directory. This allows it to return information
501 about historical builds.
503 There are also status objects that correspond to Schedulers and
504 BuildSlaves. These allow status plugins to report information about
505 upcoming builds, and the online/offline status of each buildslave.
508 @node Control Flow,  , System Architecture, Introduction
509 @comment  node-name,  next,  previous,  up
510 @section Control Flow
512 A day in the life of the buildbot:
514 @itemize @bullet
516 @item
517 A developer commits some source code changes to the repository. A hook
518 script or commit trigger of some sort sends information about this
519 change to the buildmaster through one of its configured Change
520 Sources. This notification might arrive via email, or over a network
521 connection (either initiated by the buildmaster as it ``subscribes''
522 to changes, or by the commit trigger as it pushes Changes towards the
523 buildmaster). The Change contains information about who made the
524 change, what files were modified, which revision contains the change,
525 and any checkin comments.
527 @item
528 The buildmaster distributes this change to all of its configured
529 Schedulers. Any ``important'' changes cause the ``tree-stable-timer''
530 to be started, and the Change is added to a list of those that will go
531 into a new Build. When the timer expires, a Build is started on each
532 of a set of configured Builders, all compiling/testing the same source
533 code. Unless configured otherwise, all Builds run in parallel on the
534 various buildslaves.
536 @item
537 The Build consists of a series of Steps. Each Step causes some number
538 of commands to be invoked on the remote buildslave associated with
539 that Builder. The first step is almost always to perform a checkout of
540 the appropriate revision from the same VC system that produced the
541 Change. The rest generally perform a compile and run unit tests. As
542 each Step runs, the buildslave reports back command output and return
543 status to the buildmaster.
545 @item
546 As the Build runs, status messages like ``Build Started'', ``Step
547 Started'', ``Build Finished'', etc, are published to a collection of
548 Status Targets. One of these targets is usually the HTML ``Waterfall''
549 display, which shows a chronological list of events, and summarizes
550 the results of the most recent build at the top of each column.
551 Developers can periodically check this page to see how their changes
552 have fared. If they see red, they know that they've made a mistake and
553 need to fix it. If they see green, they know that they've done their
554 duty and don't need to worry about their change breaking anything.
556 @item
557 If a MailNotifier status target is active, the completion of a build
558 will cause email to be sent to any developers whose Changes were
559 incorporated into this Build. The MailNotifier can be configured to
560 only send mail upon failing builds, or for builds which have just
561 transitioned from passing to failing. Other status targets can provide
562 similar real-time notification via different communication channels,
563 like IRC.
565 @end itemize
568 @node Installation, Concepts, Introduction, Top
569 @chapter Installation
571 @menu
572 * Requirements::                
573 * Installing the code::         
574 * Creating a buildmaster::      
575 * Creating a buildslave::       
576 * Launching the daemons::       
577 * Logfiles::                    
578 * Shutdown::                    
579 * Maintenance::                 
580 * Troubleshooting::             
581 @end menu
583 @node Requirements, Installing the code, Installation, Installation
584 @section Requirements
586 At a bare minimum, you'll need the following (for both the buildmaster
587 and a buildslave):
589 @itemize @bullet
590 @item
591 Python: http://www.python.org
593 Buildbot requires python-2.2 or later, and is primarily developed
594 against python-2.3. The buildmaster uses generators, a feature which
595 is not available in python-2.1, and both master and slave require a
596 version of Twisted which only works with python-2.2 or later. Certain
597 features (like the inclusion of build logs in status emails) require
598 python-2.2.2 or later. The IRC ``force build'' command requires
599 python-2.3 (for the shlex.split function).
601 @item
602 Twisted: http://twistedmatrix.com
604 Both the buildmaster and the buildslaves require Twisted-1.3.0 or
605 later. It has been mainly developed against Twisted-2.0.1, but has
606 been tested against Twisted-2.1.0 (the most recent as of this
607 writing), and might even work on versions as old as Twisted-1.1.0, but
608 as always the most recent version is recommended.
610 Twisted-1.3.0 and earlier were released as a single monolithic
611 package. When you run Buildbot against Twisted-2.0.0 or later (which
612 are split into a number of smaller subpackages), you'll need at least
613 "Twisted" (the core package), and you'll also want TwistedMail,
614 TwistedWeb, and TwistedWords (for sending email, serving a web status
615 page, and delivering build status via IRC, respectively).
616 @end itemize
618 Certain other packages may be useful on the system running the
619 buildmaster:
621 @itemize @bullet
622 @item
623 CVSToys: http://purl.net/net/CVSToys
625 If your buildmaster uses FreshCVSSource to receive change notification
626 from a cvstoys daemon, it will require CVSToys be installed (tested
627 with CVSToys-1.0.10). If the it doesn't use that source (i.e. if you
628 only use a mail-parsing change source, or the SVN notification
629 script), you will not need CVSToys.
631 @end itemize
633 And of course, your project's build process will impose additional
634 requirements on the buildslaves. These hosts must have all the tools
635 necessary to compile and test your project's source code.
638 @node Installing the code, Creating a buildmaster, Requirements, Installation
639 @section Installing the code
641 @cindex installation
643 The Buildbot is installed using the standard python @code{distutils}
644 module. After unpacking the tarball, the process is:
646 @example
647 python setup.py build
648 python setup.py install
649 @end example
651 where the install step may need to be done as root. This will put the
652 bulk of the code in somewhere like
653 /usr/lib/python2.3/site-packages/buildbot . It will also install the
654 @code{buildbot} command-line tool in /usr/bin/buildbot.
656 To test this, shift to a different directory (like /tmp), and run:
658 @example
659 buildbot --version
660 @end example
662 If it shows you the versions of Buildbot and Twisted, the install went
663 ok. If it says @code{no such command} or it gets an @code{ImportError}
664 when it tries to load the libaries, then something went wrong.
665 @code{pydoc buildbot} is another useful diagnostic tool.
667 Windows users will find these files in other places. You will need to
668 make sure that python can find the libraries, and will probably find
669 it convenient to have @code{buildbot} on your PATH.
671 If you wish, you can run the buildbot unit test suite like this:
673 @example
674 PYTHONPATH=. trial buildbot.test
675 @end example
677 This should run up to 192 tests, depending upon what VC tools you have
678 installed. On my desktop machine it takes about five minutes to
679 complete. Nothing should fail, a few might be skipped. If any of the
680 tests fail, you should stop and investigate the cause before
681 continuing the installation process, as it will probably be easier to
682 track down the bug early.
684 If you cannot or do not wish to install the buildbot into a site-wide
685 location like @file{/usr} or @file{/usr/local}, you can also install
686 it into the account's home directory. Do the install command like
687 this:
689 @example
690 python setup.py install --home=~
691 @end example
693 That will populate @file{~/lib/python} and create
694 @file{~/bin/buildbot}. Make sure this lib directory is on your
695 @code{PYTHONPATH}.
698 @node Creating a buildmaster, Creating a buildslave, Installing the code, Installation
699 @section Creating a buildmaster
701 As you learned earlier (@pxref{System Architecture}), the buildmaster
702 runs on a central host (usually one that is publically visible, so
703 everybody can check on the status of the project), and controls all
704 aspects of the buildbot system. Let us call this host
705 @code{buildbot.example.org}.
707 You may wish to create a separate user account for the buildmaster,
708 perhaps named @code{buildmaster}. This can help keep your personal
709 configuration distinct from that of the buildmaster and is useful if
710 you have to use a mail-based notification system (@pxref{Change
711 Sources}). However, the Buildbot will work just fine with your regular
712 user account.
714 You need to choose a directory for the buildmaster, called the
715 @code{basedir}. This directory will be owned by the buildmaster, which
716 will use configuration files therein, and create status files as it
717 runs. @file{~/Buildbot} is a likely value. If you run multiple
718 buildmasters in the same account, or if you run both masters and
719 slaves, you may want a more distinctive name like
720 @file{~/Buildbot/master/gnomovision} or
721 @file{~/Buildmasters/fooproject}. If you are using a separate user
722 account, this might just be @file{~buildmaster/masters/fooproject}.
724 Once you've picked a directory, use the @command{buildbot
725 create-master} command to create the directory and populate it with
726 startup files:
728 @example
729 buildbot create-master @var{basedir}
730 @end example
732 You will need to create a configuration file (@pxref{Configuration})
733 before starting the buildmaster. Most of the rest of this manual is
734 dedicated to explaining how to do this. A sample configuration file is
735 placed in the working directory, named @file{master.cfg.sample}, which
736 can be copied to @file{master.cfg} and edited to suit your purposes.
738 (Internal details: This command creates a file named
739 @file{buildbot.tac} that contains all the state necessary to create
740 the buildmaster. Twisted has a tool called @code{twistd} which can use
741 this .tac file to create and launch a buildmaster instance. twistd
742 takes care of logging and daemonization (running the program in the
743 background). @file{/usr/bin/buildbot} is a front end which runs twistd
744 for you.)
746 In addition to @file{buildbot.tac}, a small @file{Makefile.sample} is
747 installed. This can be used as the basis for customized daemon startup,
748 @xref{Launching the daemons}.
751 @node Creating a buildslave, Launching the daemons, Creating a buildmaster, Installation
752 @section Creating a buildslave
754 Typically, you will be adding a buildslave to an existing buildmaster,
755 to provide additional architecture coverage. The buildbot
756 administrator will give you several pieces of information necessary to
757 connect to the buildmaster. You should also be somewhat familiar with
758 the project being tested, so you can troubleshoot build problems
759 locally.
761 The buildbot exists to make sure that the project's stated ``how to
762 build it'' process actually works. To this end, the buildslave should
763 run in an environment just like that of your regular developers.
764 Typically the project build process is documented somewhere
765 (@file{README}, @file{INSTALL}, etc), in a document that should
766 mention all library dependencies and contain a basic set of build
767 instructions. This document will be useful as you configure the host
768 and account in which the buildslave runs.
770 Here's a good checklist for setting up a buildslave:
772 @enumerate
773 @item
774 Set up the account
776 It is recommended (although not mandatory) to set up a separate user
777 account for the buildslave. This account is frequently named
778 @code{buildbot} or @code{buildslave}. This serves to isolate your
779 personal working environment from that of the slave's, and helps to
780 minimize the security threat posed by letting possibly-unknown
781 contributors run arbitrary code on your system. The account should
782 have a minimum of fancy init scripts.
784 @item
785 Install the buildbot code
787 Follow the instructions given earlier (@pxref{Installing the code}).
788 If you use a separate buildslave account, and you didn't install the
789 buildbot code to a shared location, then you will need to install it
790 with @code{--home=~} for each account that needs it.
792 @item
793 Set up the host
795 Make sure the host can actually reach the buildmaster. Usually the
796 buildmaster is running a status webserver on the same machine, so
797 simply point your web browser at it and see if you can get there.
798 Install whatever additional packages or libraries the project's
799 INSTALL document advises. (or not: if your buildslave is supposed to
800 make sure that building without optional libraries still works, then
801 don't install those libraries).
803 Again, these libraries don't necessarily have to be installed to a
804 site-wide shared location, but they must be available to your build
805 process. Accomplishing this is usually very specific to the build
806 process, so installing them to @file{/usr} or @file{/usr/local} is
807 usually the best approach.
809 @item
810 Test the build process
812 Follow the instructions in the INSTALL document, in the buildslave's
813 account. Perform a full CVS (or whatever) checkout, configure, make,
814 run tests, etc. Confirm that the build works without manual fussing.
815 If it doesn't work when you do it by hand, it will be unlikely to work
816 when the buildbot attempts to do it in an automated fashion.
818 @item
819 Choose a base directory
821 This should be somewhere in the buildslave's account, typically named
822 after the project which is being tested. The buildslave will not touch
823 any file outside of this directory. Something like @file{~/Buildbot}
824 or @file{~/Buildslaves/fooproject} is appropriate.
826 @item
827 Get the buildmaster host/port, botname, and password
829 When the buildbot admin configures the buildmaster to accept and use
830 your buildslave, they will provide you with the following pieces of
831 information:
833 @itemize @bullet
834 @item
835 your buildslave's name
836 @item
837 the password assigned to your buildslave
838 @item
839 the hostname and port number of the buildmaster, i.e. buildbot.example.org:8007
840 @end itemize
842 @item
843 Create the buildslave
845 Now run the 'buildbot' command as follows:
847 @example
848 buildbot create-slave @var{BASEDIR} @var{MASTERHOST}:@var{PORT} @var{SLAVENAME} @var{PASSWORD}
849 @end example
851 This will create the base directory and a collection of files inside,
852 including the @file{buildbot.tac} file that contains all the
853 information you passed to the @code{buildbot} command.
855 @item
856 Fill in the hostinfo files
858 When it first connects, the buildslave will send a few files up to the
859 buildmaster which describe the host that it is running on. These files
860 are presented on the web status display so that developers have more
861 information to reproduce any test failures that are witnessed by the
862 buildbot. There are sample files in the @file{info} subdirectory of
863 the buildbot's base directory. You should edit these to correctly
864 describe you and your host.
866 @file{BASEDIR/info/admin} should contain your name and email address.
867 This is the ``buildslave admin address'', and will be visible from the
868 build status page (so you may wish to munge it a bit if
869 address-harvesting spambots are a concern).
871 @file{BASEDIR/info/host} should be filled with a brief description of
872 the host: OS, version, memory size, CPU speed, versions of relevant
873 libraries installed, and finally the version of the buildbot code
874 which is running the buildslave.
876 If you run many buildslaves, you may want to create a single
877 @file{~buildslave/info} file and share it among all the buildslaves
878 with symlinks.
880 @end enumerate
882 @menu
883 * Buildslave Options::          
884 @end menu
886 @node Buildslave Options,  , Creating a buildslave, Creating a buildslave
887 @subsection Buildslave Options
889 There are a handful of options you might want to use when creating the
890 buildslave with the @command{buildbot create-slave <options> DIR <params>}
891 command. You can type @command{buildbot create-slave --help} for a summary.
892 To use these, just include them on the @command{buildbot create-slave}
893 command line, like this:
895 @example
896 buildbot create-slave --umask=022 ~/buildslave buildmaster.example.org:42012 myslavename mypasswd
897 @end example
899 @table @code
900 @item --usepty
901 This is a boolean flag that tells the buildslave whether to launch
902 child processes in a PTY (the default) or with regular pipes. The
903 advantage of using a PTY is that ``grandchild'' processes are more
904 likely to be cleaned up if the build is interrupted or times out
905 (since it enables the use of a ``process group'' in which all child
906 processes will be placed). The disadvantages: some forms of Unix have
907 problems with PTYs, some of your unit tests may behave differently
908 when run under a PTY (generally those which check to see if they are
909 being run interactively), and PTYs will merge the stdout and stderr
910 streams into a single output stream (which means the red-vs-black
911 coloring in the logfiles will be lost). If you encounter problems, you
912 can add @code{--usepty=0} to disable the use of PTYs. Note that
913 windows buildslaves never use PTYs.
915 @item --umask
916 This is a string (generally an octal representation of an integer)
917 which will cause the buildslave process' ``umask'' value to be set
918 shortly after initialization. The ``twistd'' daemonization utility
919 forces the umask to 077 at startup (which means that all files created
920 by the buildslave or its child processes will be unreadable by any
921 user other than the buildslave account). If you want build products to
922 be readable by other accounts, you can add @code{--umask=022} to tell
923 the buildslave to fix the umask after twistd clobbers it. If you want
924 build products to be @emph{writable} by other accounts too, use
925 @code{--umask=000}, but this is likely to be a security problem.
927 @item --keepalive
928 This is a number that indicates how frequently ``keepalive'' messages
929 should be sent from the buildslave to the buildmaster, expressed in
930 seconds. The default (600) causes a message to be sent to the
931 buildmaster at least once every 10 minutes. To set this to a lower
932 value, use e.g. @code{--keepalive=120}.
934 If the buildslave is behind a NAT box or stateful firewall, these
935 messages may help to keep the connection alive: some NAT boxes tend to
936 forget about a connection if it has not been used in a while. When
937 this happens, the buildmaster will think that the buildslave has
938 disappeared, and builds will time out. Meanwhile the buildslave will
939 not realize than anything is wrong.
941 @end table
944 @node Launching the daemons, Logfiles, Creating a buildslave, Installation
945 @section Launching the daemons
947 Both the buildmaster and the buildslave run as daemon programs. To
948 launch them, pass the working directory to the @code{buildbot}
949 command:
951 @example
952 buildbot start @var{BASEDIR}
953 @end example
955 This command will start the daemon and then return, so normally it
956 will not produce any output. To verify that the programs are indeed
957 running, look for a pair of files named @file{twistd.log} and
958 @file{twistd.pid} that should be created in the working directory.
959 @file{twistd.pid} contains the process ID of the newly-spawned daemon.
961 When the buildslave connects to the buildmaster, new directories will
962 start appearing in its base directory. The buildmaster tells the slave
963 to create a directory for each Builder which will be using that slave.
964 All build operations are performed within these directories: CVS
965 checkouts, compiles, and tests.
967 Once you get everything running, you will want to arrange for the
968 buildbot daemons to be started at boot time. One way is to use
969 @code{cron}, by putting them in a @@reboot crontab entry@footnote{this
970 @@reboot syntax is understood by Vixie cron, which is the flavor
971 usually provided with linux systems. Other unices may have a cron that
972 doesn't understand @@reboot}:
974 @example
975 @@reboot buildbot start @var{BASEDIR}
976 @end example
978 When you run @command{crontab} to set this up, remember to do it as
979 the buildmaster or buildslave account! If you add this to your crontab
980 when running as your regular account (or worse yet, root), then the
981 daemon will run as the wrong user, quite possibly as one with more
982 authority than you intended to provide.
984 It is important to remember that the environment provided to cron jobs
985 and init scripts can be quite different that your normal runtime.
986 There may be fewer environment variables specified, and the PATH may
987 be shorter than usual. It is a good idea to test out this method of
988 launching the buildslave by using a cron job with a time in the near
989 future, with the same command, and then check @file{twistd.log} to
990 make sure the slave actually started correctly. Common problems here
991 are for @file{/usr/local} or @file{~/bin} to not be on your
992 @code{PATH}, or for @code{PYTHONPATH} to not be set correctly.
993 Sometimes @code{HOME} is messed up too.
995 To modify the way the daemons are started (perhaps you want to set
996 some environment variables first, or perform some cleanup each time),
997 you can create a file named @file{Makefile.buildbot} in the base
998 directory. When the @file{buildbot} front-end tool is told to
999 @command{start} the daemon, and it sees this file (and
1000 @file{/usr/bin/make} exists), it will do @command{make -f
1001 Makefile.buildbot start} instead of its usual action (which involves
1002 running @command{twistd}). When the buildmaster or buildslave is
1003 installed, a @file{Makefile.sample} is created which implements the
1004 same behavior as the the @file{buildbot} tool uses, so if you want to
1005 customize the process, just copy @file{Makefile.sample} to
1006 @file{Makefile.buildbot} and edit it as necessary.
1008 @node Logfiles, Shutdown, Launching the daemons, Installation
1009 @section Logfiles
1011 @cindex logfiles
1013 While a buildbot daemon runs, it emits text to a logfile, named
1014 @file{twistd.log}. A command like @code{tail -f twistd.log} is useful
1015 to watch the command output as it runs.
1017 The buildmaster will announce any errors with its configuration file
1018 in the logfile, so it is a good idea to look at the log at startup
1019 time to check for any problems. Most buildmaster activities will cause
1020 lines to be added to the log.
1022 @node Shutdown, Maintenance, Logfiles, Installation
1023 @section Shutdown
1025 To stop a buildmaster or buildslave manually, use:
1027 @example
1028 buildbot stop @var{BASEDIR}
1029 @end example
1031 This simply looks for the @file{twistd.pid} file and kills whatever
1032 process is identified within.
1034 At system shutdown, all processes are sent a @code{SIGKILL}. The
1035 buildmaster and buildslave will respond to this by shutting down
1036 normally.
1038 The buildmaster will respond to a @code{SIGHUP} by re-reading its
1039 config file. The following shortcut is available:
1041 @example
1042 buildbot sighup @var{BASEDIR}
1043 @end example
1045 When you update the Buildbot code to a new release, you will need to
1046 restart the buildmaster and/or buildslave before it can take advantage
1047 of the new code. You can do a @code{buildbot stop @var{BASEDIR}} and
1048 @code{buildbot start @var{BASEDIR}} in quick succession, or you can
1049 use the @code{restart} shortcut, which does both steps for you:
1051 @example
1052 buildbot restart @var{BASEDIR}
1053 @end example
1056 @node Maintenance, Troubleshooting, Shutdown, Installation
1057 @section Maintenance
1059 It is a good idea to check the buildmaster's status page every once in
1060 a while, to see if your buildslave is still online. Eventually the
1061 buildbot will probably be enhanced to send you email (via the
1062 @file{info/admin} email address) when the slave has been offline for
1063 more than a few hours.
1065 If you find you can no longer provide a buildslave to the project, please
1066 let the project admins know, so they can put out a call for a
1067 replacement.
1069 The Buildbot records status and logs output continually, each time a
1070 build is performed. The status tends to be small, but the build logs
1071 can become quite large. Each build and log are recorded in a separate
1072 file, arranged hierarchically under the buildmaster's base directory.
1073 To prevent these files from growing without bound, you should
1074 periodically delete old build logs. A simple cron job to delete
1075 anything older than, say, two weeks should do the job. The only trick
1076 is to leave the @file{buildbot.tac} and other support files alone, for
1077 which find's @code{-mindepth} argument helps skip everything in the
1078 top directory. You can use something like the following:
1080 @example
1081 @@weekly cd BASEDIR && find . -mindepth 2 -type f -mtime +14 -exec rm @{@} \;
1082 @@weekly cd BASEDIR && find twistd.log* -mtime +14 -exec rm @{@} \;
1083 @end example
1085 @node Troubleshooting,  , Maintenance, Installation
1086 @section Troubleshooting
1088 Here are a few hints on diagnosing common problems.
1090 @menu
1091 * Starting the buildslave::     
1092 * Connecting to the buildmaster::  
1093 * Forcing Builds::              
1094 @end menu
1096 @node Starting the buildslave, Connecting to the buildmaster, Troubleshooting, Troubleshooting
1097 @subsection Starting the buildslave
1099 Cron jobs are typically run with a minimal shell (@file{/bin/sh}, not
1100 @file{/bin/bash}), and tilde expansion is not always performed in such
1101 commands. You may want to use explicit paths, because the @code{PATH}
1102 is usually quite short and doesn't include anything set by your
1103 shell's startup scripts (@file{.profile}, @file{.bashrc}, etc). If
1104 you've installed buildbot (or other python libraries) to an unusual
1105 location, you may need to add a @code{PYTHONPATH} specification (note
1106 that python will do tilde-expansion on @code{PYTHONPATH} elements by
1107 itself). Sometimes it is safer to fully-specify everything:
1109 @example
1110 @@reboot PYTHONPATH=~/lib/python /usr/local/bin/buildbot start /usr/home/buildbot/basedir
1111 @end example
1113 Take the time to get the @@reboot job set up. Otherwise, things will work
1114 fine for a while, but the first power outage or system reboot you have will
1115 stop the buildslave with nothing but the cries of sorrowful developers to
1116 remind you that it has gone away.
1118 @node Connecting to the buildmaster, Forcing Builds, Starting the buildslave, Troubleshooting
1119 @subsection Connecting to the buildmaster
1121 If the buildslave cannot connect to the buildmaster, the reason should
1122 be described in the @file{twistd.log} logfile. Some common problems
1123 are an incorrect master hostname or port number, or a mistyped bot
1124 name or password. If the buildslave loses the connection to the
1125 master, it is supposed to attempt to reconnect with an
1126 exponentially-increasing backoff. Each attempt (and the time of the
1127 next attempt) will be logged. If you get impatient, just manually stop
1128 and re-start the buildslave.
1130 When the buildmaster is restarted, all slaves will be disconnected,
1131 and will attempt to reconnect as usual. The reconnect time will depend
1132 upon how long the buildmaster is offline (i.e. how far up the
1133 exponential backoff curve the slaves have travelled). Again,
1134 @code{buildbot stop @var{BASEDIR}; buildbot start @var{BASEDIR}} will
1135 speed up the process.
1137 @node Forcing Builds,  , Connecting to the buildmaster, Troubleshooting
1138 @subsection Forcing Builds
1140 From the buildmaster's main status web page, you can force a build to
1141 be run on your build slave. Figure out which column is for a builder
1142 that runs on your slave, click on that builder's name, and the page
1143 that comes up will have a ``Force Build'' button. Fill in the form,
1144 hit the button, and a moment later you should see your slave's
1145 @file{twistd.log} filling with commands being run. Using @code{pstree}
1146 or @code{top} should also reveal the cvs/make/gcc/etc processes being
1147 run by the buildslave. Note that the same web page should also show
1148 the @file{admin} and @file{host} information files that you configured
1149 earlier.
1151 @node Concepts, Configuration, Installation, Top
1152 @chapter Concepts
1154 This chapter defines some of the basic concepts that the Buildbot
1155 uses. You'll need to understand how the Buildbot sees the world to
1156 configure it properly.
1158 @menu
1159 * Version Control Systems::     
1160 * Schedulers::                  
1161 * BuildSet::                    
1162 * BuildRequest::                
1163 * Builder::                     
1164 * Users::                       
1165 @end menu
1167 @node Version Control Systems, Schedulers, Concepts, Concepts
1168 @section Version Control Systems
1170 @cindex Version Control
1172 These source trees come from a Version Control System of some kind.
1173 CVS and Subversion are two popular ones, but the Buildbot supports
1174 others. All VC systems have some notion of an upstream
1175 @code{repository} which acts as a server@footnote{except Darcs, but
1176 since the Buildbot never modifies its local source tree we can ignore
1177 the fact that Darcs uses a less centralized model}, from which clients
1178 can obtain source trees according to various parameters. The VC
1179 repository provides source trees of various projects, for different
1180 branches, and from various points in time. The first thing we have to
1181 do is to specify which source tree we want to get.
1183 @menu
1184 * Generalizing VC Systems::     
1185 * Source Tree Specifications::  
1186 * How Different VC Systems Specify Sources::  
1187 * Attributes of Changes::       
1188 @end menu
1190 @node Generalizing VC Systems, Source Tree Specifications, Version Control Systems, Version Control Systems
1191 @subsection Generalizing VC Systems
1193 For the purposes of the Buildbot, we will try to generalize all VC
1194 systems as having repositories that each provide sources for a variety
1195 of projects. Each project is defined as a directory tree with source
1196 files. The individual files may each have revisions, but we ignore
1197 that and treat the project as a whole as having a set of revisions.
1198 Each time someone commits a change to the project, a new revision
1199 becomes available. These revisions can be described by a tuple with
1200 two items: the first is a branch tag, and the second is some kind of
1201 timestamp or revision stamp. Complex projects may have multiple branch
1202 tags, but there is always a default branch. The timestamp may be an
1203 actual timestamp (such as the -D option to CVS), or it may be a
1204 monotonically-increasing transaction number (such as the change number
1205 used by SVN and P4, or the revision number used by Arch, or a labeled
1206 tag used in CVS)@footnote{many VC systems provide more complexity than
1207 this: in particular the local views that P4 and ClearCase can assemble
1208 out of various source directories are more complex than we're prepared
1209 to take advantage of here}. The SHA1 revision ID used by Monotone and
1210 Mercurial is also a kind of revision stamp, in that it specifies a
1211 unique copy of the source tree, as does a Darcs ``context'' file.
1213 When we aren't intending to make any changes to the sources we check out
1214 (at least not any that need to be committed back upstream), there are two
1215 basic ways to use a VC system:
1217 @itemize @bullet
1218 @item
1219 Retrieve a specific set of source revisions: some tag or key is used
1220 to index this set, which is fixed and cannot be changed by subsequent
1221 developers committing new changes to the tree. Releases are built from
1222 tagged revisions like this, so that they can be rebuilt again later
1223 (probably with controlled modifications).
1224 @item
1225 Retrieve the latest sources along a specific branch: some tag is used
1226 to indicate which branch is to be used, but within that constraint we want
1227 to get the latest revisions.
1228 @end itemize
1230 Build personnel or CM staff typically use the first approach: the
1231 build that results is (ideally) completely specified by the two
1232 parameters given to the VC system: repository and revision tag. This
1233 gives QA and end-users something concrete to point at when reporting
1234 bugs. Release engineers are also reportedly fond of shipping code that
1235 can be traced back to a concise revision tag of some sort.
1237 Developers are more likely to use the second approach: each morning
1238 the developer does an update to pull in the changes committed by the
1239 team over the last day. These builds are not easy to fully specify: it
1240 depends upon exactly when you did a checkout, and upon what local
1241 changes the developer has in their tree. Developers do not normally
1242 tag each build they produce, because there is usually significant
1243 overhead involved in creating these tags. Recreating the trees used by
1244 one of these builds can be a challenge. Some VC systems may provide
1245 implicit tags (like a revision number), while others may allow the use
1246 of timestamps to mean ``the state of the tree at time X'' as opposed
1247 to a tree-state that has been explicitly marked.
1249 The Buildbot is designed to help developers, so it usually works in
1250 terms of @emph{the latest} sources as opposed to specific tagged
1251 revisions. However, it would really prefer to build from reproducible
1252 source trees, so implicit revisions are used whenever possible.
1254 @node Source Tree Specifications, How Different VC Systems Specify Sources, Generalizing VC Systems, Version Control Systems
1255 @subsection Source Tree Specifications
1257 So for the Buildbot's purposes we treat each VC system as a server
1258 which can take a list of specifications as input and produce a source
1259 tree as output. Some of these specifications are static: they are
1260 attributes of the builder and do not change over time. Others are more
1261 variable: each build will have a different value. The repository is
1262 changed over time by a sequence of Changes, each of which represents a
1263 single developer making changes to some set of files. These Changes
1264 are cumulative@footnote{Monotone's @emph{multiple heads} feature
1265 violates this assumption of cumulative Changes, but in most situations
1266 the changes don't occur frequently enough for this to be a significant
1267 problem}.
1269 For normal builds, the Buildbot wants to get well-defined source trees
1270 that contain specific Changes, and exclude other Changes that may have
1271 occurred after the desired ones. We assume that the Changes arrive at
1272 the buildbot (through one of the mechanisms described in @pxref{Change
1273 Sources}) in the same order in which they are committed to the
1274 repository. The Buildbot waits for the tree to become ``stable''
1275 before initiating a build, for two reasons. The first is that
1276 developers frequently make multiple related commits in quick
1277 succession, even when the VC system provides ways to make atomic
1278 transactions involving multiple files at the same time. Running a
1279 build in the middle of these sets of changes would use an inconsistent
1280 set of source files, and is likely to fail (and is certain to be less
1281 useful than a build which uses the full set of changes). The
1282 tree-stable-timer is intended to avoid these useless builds that
1283 include some of the developer's changes but not all. The second reason
1284 is that some VC systems (i.e. CVS) do not provide repository-wide
1285 transaction numbers, so that timestamps are the only way to refer to
1286 a specific repository state. These timestamps may be somewhat
1287 ambiguous, due to processing and notification delays. By waiting until
1288 the tree has been stable for, say, 10 minutes, we can choose a
1289 timestamp from the middle of that period to use for our source
1290 checkout, and then be reasonably sure that any clock-skew errors will
1291 not cause the build to be performed on an inconsistent set of source
1292 files.
1294 The Schedulers always use the tree-stable-timer, with a timeout that
1295 is configured to reflect a reasonable tradeoff between build latency
1296 and change frequency. When the VC system provides coherent
1297 repository-wide revision markers (such as Subversion's revision
1298 numbers, or in fact anything other than CVS's timestamps), the
1299 resulting Build is simply performed against a source tree defined by
1300 that revision marker. When the VC system does not provide this, a
1301 timestamp from the middle of the tree-stable period is used to
1302 generate the source tree@footnote{this @code{checkoutDelay} defaults
1303 to half the tree-stable timer, but it can be overridden with an
1304 argument to the Source Step}.
1306 @node How Different VC Systems Specify Sources, Attributes of Changes, Source Tree Specifications, Version Control Systems
1307 @subsection How Different VC Systems Specify Sources
1309 For CVS, the static specifications are @code{repository} and
1310 @code{module}. In addition to those, each build uses a timestamp (or
1311 omits the timestamp to mean @code{the latest}) and @code{branch tag}
1312 (which defaults to HEAD). These parameters collectively specify a set
1313 of sources from which a build may be performed.
1315 @uref{http://subversion.tigris.org, Subversion} combines the
1316 repository, module, and branch into a single @code{Subversion URL}
1317 parameter. Within that scope, source checkouts can be specified by a
1318 numeric @code{revision number} (a repository-wide
1319 monotonically-increasing marker, such that each transaction that
1320 changes the repository is indexed by a different revision number), or
1321 a revision timestamp. When branches are used, the repository and
1322 module form a static @code{baseURL}, while each build has a
1323 @code{revision number} and a @code{branch} (which defaults to a
1324 statically-specified @code{defaultBranch}). The @code{baseURL} and
1325 @code{branch} are simply concatenated together to derive the
1326 @code{svnurl} to use for the checkout.
1328 @uref{http://www.perforce.com/, Perforce} is similar. The server
1329 is specified through a @code{P4PORT} parameter. Module and branch
1330 are specified in a single depot path, and revisions are
1331 depot-wide. When branches are used, the @code{p4base} and
1332 @code{defaultBranch} are concatenated together to produce the depot
1333 path.
1335 @uref{http://wiki.gnuarch.org/, Arch} and
1336 @uref{http://bazaar.canonical.com/, Bazaar} specify a repository by
1337 URL, as well as a @code{version} which is kind of like a branch name.
1338 Arch uses the word @code{archive} to represent the repository. Arch
1339 lets you push changes from one archive to another, removing the strict
1340 centralization required by CVS and SVN. It retains the distinction
1341 between repository and working directory that most other VC systems
1342 use. For complex multi-module directory structures, Arch has a
1343 built-in @code{build config} layer with which the checkout process has
1344 two steps. First, an initial bootstrap checkout is performed to
1345 retrieve a set of build-config files. Second, one of these files is
1346 used to figure out which archives/modules should be used to populate
1347 subdirectories of the initial checkout.
1349 Builders which use Arch and Bazaar therefore have a static archive
1350 @code{url}, and a default ``branch'' (which is a string that specifies
1351 a complete category--branch--version triple). Each build can have its
1352 own branch (the category--branch--version string) to override the
1353 default, as well as a revision number (which is turned into a
1354 --patch-NN suffix when performing the checkout).
1356 @uref{http://abridgegame.org/darcs/, Darcs} doesn't really have the
1357 notion of a single master repository. Nor does it really have
1358 branches. In Darcs, each working directory is also a repository, and
1359 there are operations to push and pull patches from one of these
1360 @code{repositories} to another. For the Buildbot's purposes, all you
1361 need to do is specify the URL of a repository that you want to build
1362 from. The build slave will then pull the latest patches from that
1363 repository and build them. Multiple branches are implemented by using
1364 multiple repositories (possibly living on the same server).
1366 Builders which use Darcs therefore have a static @code{repourl} which
1367 specifies the location of the repository. If branches are being used,
1368 the source Step is instead configured with a @code{baseURL} and a
1369 @code{defaultBranch}, and the two strings are simply concatenated
1370 together to obtain the repository's URL. Each build then has a
1371 specific branch which replaces @code{defaultBranch}, or just uses the
1372 default one. Instead of a revision number, each build can have a
1373 ``context'', which is a string that records all the patches that are
1374 present in a given tree (this is the output of @command{darcs changes
1375 --context}, and is considerably less concise than, e.g. Subversion's
1376 revision number, but the patch-reordering flexibility of Darcs makes
1377 it impossible to provide a shorter useful specification).
1379 @uref{http://selenic.com/mercurial, Mercurial} is like Darcs, in that
1380 each branch is stored in a separate repository. The @code{repourl},
1381 @code{baseURL}, and @code{defaultBranch} arguments are all handled the
1382 same way as with Darcs. The ``revision'', however, is the hash
1383 identifier returned by @command{hg identify}.
1386 @node Attributes of Changes,  , How Different VC Systems Specify Sources, Version Control Systems
1387 @subsection Attributes of Changes
1389 @heading Who
1391 Each Change has a @code{who} attribute, which specifies which
1392 developer is responsible for the change. This is a string which comes
1393 from a namespace controlled by the VC repository. Frequently this
1394 means it is a username on the host which runs the repository, but not
1395 all VC systems require this (Arch, for example, uses a fully-qualified
1396 @code{Arch ID}, which looks like an email address, as does Darcs).
1397 Each StatusNotifier will map the @code{who} attribute into something
1398 appropriate for their particular means of communication: an email
1399 address, an IRC handle, etc.
1401 @heading Files
1403 It also has a list of @code{files}, which are just the tree-relative
1404 filenames of any files that were added, deleted, or modified for this
1405 Change. These filenames are used by the @code{isFileImportant}
1406 function (in the Scheduler) to decide whether it is worth triggering a
1407 new build or not, e.g. the function could use
1408 @code{filename.endswith(".c")} to only run a build if a C file were
1409 checked in. Certain BuildSteps can also use the list of changed files
1410 to run a more targeted series of tests, e.g. the
1411 @code{python_twisted.Trial} step can run just the unit tests that
1412 provide coverage for the modified .py files instead of running the
1413 full test suite.
1415 @heading Comments
1417 The Change also has a @code{comments} attribute, which is a string
1418 containing any checkin comments.
1420 @heading Revision
1422 Each Change can have a @code{revision} attribute, which describes how
1423 to get a tree with a specific state: a tree which includes this Change
1424 (and all that came before it) but none that come after it. If this
1425 information is unavailable, the @code{.revision} attribute will be
1426 @code{None}. These revisions are provided by the ChangeSource, and
1427 consumed by the @code{computeSourceRevision} method in the appropriate
1428 @code{step.Source} class.
1430 @table @samp
1431 @item CVS
1432 @code{revision} is an int, seconds since the epoch
1433 @item SVN
1434 @code{revision} is an int, a transation number (r%d)
1435 @item Darcs
1436 @code{revision} is a large string, the output of @code{darcs changes --context}
1437 @item Mercurial
1438 @code{revision} is a short string (a hash ID), the output of @code{hg identify}
1439 @item Arch/Bazaar
1440 @code{revision} is the full revision ID (ending in --patch-%d)
1441 @item P4
1442 @code{revision} is an int, the transaction number
1443 @end table
1445 @heading Branches
1447 The Change might also have a @code{branch} attribute. This indicates
1448 that all of the Change's files are in the same named branch. The
1449 Schedulers get to decide whether the branch should be built or not.
1451 For VC systems like CVS, Arch, and Monotone, the @code{branch} name is
1452 unrelated to the filename. (that is, the branch name and the filename
1453 inhabit unrelated namespaces). For SVN, branches are expressed as
1454 subdirectories of the repository, so the file's ``svnurl'' is a
1455 combination of some base URL, the branch name, and the filename within
1456 the branch. (In a sense, the branch name and the filename inhabit the
1457 same namespace). Darcs branches are subdirectories of a base URL just
1458 like SVN. Mercurial branches are the same as Darcs.
1460 @table @samp
1461 @item CVS
1462 branch='warner-newfeature', files=['src/foo.c']
1463 @item SVN
1464 branch='branches/warner-newfeature', files=['src/foo.c']
1465 @item Darcs
1466 branch='warner-newfeature', files=['src/foo.c']
1467 @item Mercurial
1468 branch='warner-newfeature', files=['src/foo.c']
1469 @item Arch/Bazaar
1470 branch='buildbot--usebranches--0', files=['buildbot/master.py']
1471 @end table
1473 @heading Links
1475 @c TODO: who is using 'links'? how is it being used?
1477 Finally, the Change might have a @code{links} list, which is intended
1478 to provide a list of URLs to a @emph{viewcvs}-style web page that
1479 provides more detail for this Change, perhaps including the full file
1480 diffs.
1483 @node Schedulers, BuildSet, Version Control Systems, Concepts
1484 @section Schedulers
1486 @cindex Scheduler
1488 Each Buildmaster has a set of @code{Scheduler} objects, each of which
1489 gets a copy of every incoming Change. The Schedulers are responsible
1490 for deciding when Builds should be run. Some Buildbot installations
1491 might have a single Scheduler, while others may have several, each for
1492 a different purpose.
1494 For example, a ``quick'' scheduler might exist to give immediate
1495 feedback to developers, hoping to catch obvious problems in the code
1496 that can be detected quickly. These typically do not run the full test
1497 suite, nor do they run on a wide variety of platforms. They also
1498 usually do a VC update rather than performing a brand-new checkout
1499 each time. You could have a ``quick'' scheduler which used a 30 second
1500 timeout, and feeds a single ``quick'' Builder that uses a VC
1501 @code{mode='update'} setting.
1503 A separate ``full'' scheduler would run more comprehensive tests a
1504 little while later, to catch more subtle problems. This scheduler
1505 would have a longer tree-stable-timer, maybe 30 minutes, and would
1506 feed multiple Builders (with a @code{mode=} of @code{'copy'},
1507 @code{'clobber'}, or @code{'export'}).
1509 The @code{tree-stable-timer} and @code{isFileImportant} decisions are
1510 made by the Scheduler. Dependencies are also implemented here.
1511 Periodic builds (those which are run every N seconds rather than after
1512 new Changes arrive) are triggered by a special @code{Periodic}
1513 Scheduler subclass. The default Scheduler class can also be told to
1514 watch for specific branches, ignoring Changes on other branches. This
1515 may be useful if you have a trunk and a few release branches which
1516 should be tracked, but when you don't want to have the Buildbot pay
1517 attention to several dozen private user branches.
1519 Some Schedulers may trigger builds for other reasons, other than
1520 recent Changes. For example, a Scheduler subclass could connect to a
1521 remote buildmaster and watch for builds of a library to succeed before
1522 triggering a local build that uses that library.
1524 Each Scheduler creates and submits @code{BuildSet} objects to the
1525 @code{BuildMaster}, which is then responsible for making sure the
1526 individual @code{BuildRequests} are delivered to the target
1527 @code{Builders}.
1529 @code{Scheduler} instances are activated by placing them in the
1530 @code{c['schedulers']} list in the buildmaster config file. Each
1531 Scheduler has a unique name.
1534 @node BuildSet, BuildRequest, Schedulers, Concepts
1535 @section BuildSet
1537 @cindex BuildSet
1539 A @code{BuildSet} is the name given to a set of Builds that all
1540 compile/test the same version of the tree on multiple Builders. In
1541 general, all these component Builds will perform the same sequence of
1542 Steps, using the same source code, but on different platforms or
1543 against a different set of libraries.
1545 The @code{BuildSet} is tracked as a single unit, which fails if any of
1546 the component Builds have failed, and therefore can succeed only if
1547 @emph{all} of the component Builds have succeeded. There are two kinds
1548 of status notification messages that can be emitted for a BuildSet:
1549 the @code{firstFailure} type (which fires as soon as we know the
1550 BuildSet will fail), and the @code{Finished} type (which fires once
1551 the BuildSet has completely finished, regardless of whether the
1552 overall set passed or failed).
1554 A @code{BuildSet} is created with a @emph{source stamp} tuple of
1555 (branch, revision, changes, patch), some of which may be None, and a
1556 list of Builders on which it is to be run. They are then given to the
1557 BuildMaster, which is responsible for creating a separate
1558 @code{BuildRequest} for each Builder.
1560 There are a couple of different likely values for the
1561 @code{SourceStamp}:
1563 @table @code
1564 @item (revision=None, changes=[CHANGES], patch=None)
1565 This is a @code{SourceStamp} used when a series of Changes have
1566 triggered a build. The VC step will attempt to check out a tree that
1567 contains CHANGES (and any changes that occurred before CHANGES, but
1568 not any that occurred after them).
1570 @item (revision=None, changes=None, patch=None)
1571 This builds the most recent code on the default branch. This is the
1572 sort of @code{SourceStamp} that would be used on a Build that was
1573 triggered by a user request, or a Periodic scheduler. It is also
1574 possible to configure the VC Source Step to always check out the
1575 latest sources rather than paying attention to the Changes in the
1576 SourceStamp, which will result in same behavior as this.
1578 @item (branch=BRANCH, revision=None, changes=None, patch=None)
1579 This builds the most recent code on the given BRANCH. Again, this is
1580 generally triggered by a user request or Periodic build.
1582 @item (revision=REV, changes=None, patch=(LEVEL, DIFF))
1583 This checks out the tree at the given revision REV, then applies a
1584 patch (using @code{diff -pLEVEL <DIFF}). The @ref{try} feature uses
1585 this kind of @code{SourceStamp}. If @code{patch} is None, the patching
1586 step is bypassed.
1588 @end table
1590 The buildmaster is responsible for turning the @code{BuildSet} into a
1591 set of @code{BuildRequest} objects and queueing them on the
1592 appropriate Builders.
1595 @node BuildRequest, Builder, BuildSet, Concepts
1596 @section BuildRequest
1598 @cindex BuildRequest
1600 A @code{BuildRequest} is a request to build a specific set of sources
1601 on a single specific Builder. Each Builder runs the
1602 @code{BuildRequest} as soon as it can (i.e. when an associated
1603 buildslave becomes free).
1605 The @code{BuildRequest} contains the @code{SourceStamp} specification.
1606 The actual process of running the build (the series of Steps that will
1607 be executed) is implemented by the @code{Build} object. In this future
1608 this might be changed, to have the @code{Build} define @emph{what}
1609 gets built, and a separate @code{BuildProcess} (provided by the
1610 Builder) to define @emph{how} it gets built.
1612 The @code{BuildRequest} may be mergeable with other compatible
1613 @code{BuildRequest}s. Builds that are triggered by incoming Changes
1614 will generally be mergeable. Builds that are triggered by user
1615 requests are generally not, unless they are multiple requests to build
1616 the @emph{latest sources} of the same branch.
1618 @node Builder, Users, BuildRequest, Concepts
1619 @section Builder
1621 @cindex Builder
1623 The @code{Builder} is a long-lived object which controls all Builds of
1624 a given type. Each one is created when the config file is first
1625 parsed, and lives forever (or rather until it is removed from the
1626 config file). It mediates the connections to the buildslaves that do
1627 all the work, and is responsible for creating the @code{Build} objects
1628 that decide @emph{how} a build is performed (i.e., which steps are
1629 executed in what order).
1631 Each @code{Builder} gets a unique name, and the path name of a
1632 directory where it gets to do all its work (there is a
1633 buildmaster-side directory for keeping status information, as well as
1634 a buildslave-side directory where the actual checkout/compile/test
1635 commands are executed). It also gets a @code{BuildFactory}, which is
1636 responsible for creating new @code{Build} instances: because the
1637 @code{Build} instance is what actually performs each build, choosing
1638 the @code{BuildFactory} is the way to specify what happens each time a
1639 build is done.
1641 Each @code{Builder} is associated with one of more @code{BuildSlaves}.
1642 A @code{Builder} which is used to perform OS-X builds (as opposed to
1643 Linux or Solaris builds) should naturally be associated with an
1644 OS-X-based buildslave.
1647 @node Users,  , Builder, Concepts
1648 @section Users
1650 @cindex Users
1652 Buildbot has a somewhat limited awareness of @emph{users}. It assumes
1653 the world consists of a set of developers, each of whom can be
1654 described by a couple of simple attributes. These developers make
1655 changes to the source code, causing builds which may succeed or fail.
1657 Each developer is primarily known through the source control system. Each
1658 Change object that arrives is tagged with a @code{who} field that
1659 typically gives the account name (on the repository machine) of the user
1660 responsible for that change. This string is the primary key by which the
1661 User is known, and is displayed on the HTML status pages and in each Build's
1662 ``blamelist''.
1664 To do more with the User than just refer to them, this username needs to
1665 be mapped into an address of some sort. The responsibility for this mapping
1666 is left up to the status module which needs the address. The core code knows
1667 nothing about email addresses or IRC nicknames, just user names.
1669 @menu
1670 * Doing Things With Users::     
1671 * Email Addresses::             
1672 * IRC Nicknames::               
1673 * Live Status Clients::         
1674 @end menu
1676 @node Doing Things With Users, Email Addresses, Users, Users
1677 @subsection Doing Things With Users
1679 Each Change has a single User who is responsible for that Change. Most
1680 Builds have a set of Changes: the Build represents the first time these
1681 Changes have been built and tested by the Buildbot. The build has a
1682 ``blamelist'' that consists of a simple union of the Users responsible
1683 for all the Build's Changes.
1685 The Build provides (through the IBuildStatus interface) a list of Users
1686 who are ``involved'' in the build. For now this is equal to the
1687 blamelist, but in the future it will be expanded to include a ``build
1688 sheriff'' (a person who is ``on duty'' at that time and responsible for
1689 watching over all builds that occur during their shift), as well as
1690 per-module owners who simply want to keep watch over their domain (chosen by
1691 subdirectory or a regexp matched against the filenames pulled out of the
1692 Changes). The Involved Users are those who probably have an interest in the
1693 results of any given build.
1695 In the future, Buildbot will acquire the concept of ``Problems'',
1696 which last longer than builds and have beginnings and ends. For example, a
1697 test case which passed in one build and then failed in the next is a
1698 Problem. The Problem lasts until the test case starts passing again, at
1699 which point the Problem is said to be ``resolved''.
1701 If there appears to be a code change that went into the tree at the
1702 same time as the test started failing, that Change is marked as being
1703 resposible for the Problem, and the user who made the change is added
1704 to the Problem's ``Guilty'' list. In addition to this user, there may
1705 be others who share responsibility for the Problem (module owners,
1706 sponsoring developers). In addition to the Responsible Users, there
1707 may be a set of Interested Users, who take an interest in the fate of
1708 the Problem.
1710 Problems therefore have sets of Users who may want to be kept aware of
1711 the condition of the problem as it changes over time. If configured, the
1712 Buildbot can pester everyone on the Responsible list with increasing
1713 harshness until the problem is resolved, with the most harshness reserved
1714 for the Guilty parties themselves. The Interested Users may merely be told
1715 when the problem starts and stops, as they are not actually responsible for
1716 fixing anything.
1718 @node Email Addresses, IRC Nicknames, Doing Things With Users, Users
1719 @subsection Email Addresses
1721 The @code{buildbot.status.mail.MailNotifier} class provides a
1722 status target which can send email about the results of each build. It
1723 accepts a static list of email addresses to which each message should be
1724 delivered, but it can also be configured to send mail to the Build's
1725 Interested Users. To do this, it needs a way to convert User names into
1726 email addresses.
1728 For many VC systems, the User Name is actually an account name on the
1729 system which hosts the repository. As such, turning the name into an
1730 email address is a simple matter of appending
1731 ``@@repositoryhost.com''. Some projects use other kinds of mappings
1732 (for example the preferred email address may be at ``project.org''
1733 despite the repository host being named ``cvs.project.org''), and some
1734 VC systems have full separation between the concept of a user and that
1735 of an account on the repository host (like Perforce). Some systems
1736 (like Arch) put a full contact email address in every change.
1738 To convert these names to addresses, the MailNotifier uses an EmailLookup
1739 object. This provides a .getAddress method which accepts a name and
1740 (eventually) returns an address. The default @code{MailNotifier}
1741 module provides an EmailLookup which simply appends a static string,
1742 configurable when the notifier is created. To create more complex behaviors
1743 (perhaps using an LDAP lookup, or using ``finger'' on a central host to
1744 determine a preferred address for the developer), provide a different object
1745 as the @code{lookup} argument.
1747 In the future, when the Problem mechanism has been set up, the Buildbot
1748 will need to send mail to arbitrary Users. It will do this by locating a
1749 MailNotifier-like object among all the buildmaster's status targets, and
1750 asking it to send messages to various Users. This means the User-to-address
1751 mapping only has to be set up once, in your MailNotifier, and every email
1752 message the buildbot emits will take advantage of it.
1754 @node IRC Nicknames, Live Status Clients, Email Addresses, Users
1755 @subsection IRC Nicknames
1757 Like MailNotifier, the @code{buildbot.status.words.IRC} class
1758 provides a status target which can announce the results of each build. It
1759 also provides an interactive interface by responding to online queries
1760 posted in the channel or sent as private messages.
1762 In the future, the buildbot can be configured map User names to IRC
1763 nicknames, to watch for the recent presence of these nicknames, and to
1764 deliver build status messages to the interested parties. Like
1765 @code{MailNotifier} does for email addresses, the @code{IRC} object
1766 will have an @code{IRCLookup} which is responsible for nicknames. The
1767 mapping can be set up statically, or it can be updated by online users
1768 themselves (by claiming a username with some kind of ``buildbot: i am
1769 user warner'' commands).
1771 Once the mapping is established, the rest of the buildbot can ask the
1772 @code{IRC} object to send messages to various users. It can report on
1773 the likelihood that the user saw the given message (based upon how long the
1774 user has been inactive on the channel), which might prompt the Problem
1775 Hassler logic to send them an email message instead.
1777 @node Live Status Clients,  , IRC Nicknames, Users
1778 @subsection Live Status Clients
1780 The Buildbot also offers a PB-based status client interface which can
1781 display real-time build status in a GUI panel on the developer's desktop.
1782 This interface is normally anonymous, but it could be configured to let the
1783 buildmaster know @emph{which} developer is using the status client. The
1784 status client could then be used as a message-delivery service, providing an
1785 alternative way to deliver low-latency high-interruption messages to the
1786 developer (like ``hey, you broke the build'').
1789 @node Configuration, Getting Source Code Changes, Concepts, Top
1790 @chapter Configuration
1792 @cindex Configuration
1794 The buildbot's behavior is defined by the ``config file'', which
1795 normally lives in the @file{master.cfg} file in the buildmaster's base
1796 directory (but this can be changed with an option to the
1797 @code{buildbot create-master} command). This file completely specifies
1798 which Builders are to be run, which slaves they should use, how
1799 Changes should be tracked, and where the status information is to be
1800 sent. The buildmaster's @file{buildbot.tac} file names the base
1801 directory; everything else comes from the config file.
1803 A sample config file was installed for you when you created the
1804 buildmaster, but you will need to edit it before your buildbot will do
1805 anything useful.
1807 This chapter gives an overview of the format of this file and the
1808 various sections in it. You will need to read the later chapters to
1809 understand how to fill in each section properly.
1811 @menu
1812 * Config File Format::          
1813 * Loading the Config File::     
1814 * Defining the Project::        
1815 * Listing Change Sources and Schedulers::  
1816 * Setting the slaveport::       
1817 * Buildslave Specifiers::       
1818 * Defining Builders::           
1819 * Defining Status Targets::     
1820 * Debug options::               
1821 @end menu
1823 @node Config File Format, Loading the Config File, Configuration, Configuration
1824 @section Config File Format
1826 The config file is, fundamentally, just a piece of Python code which
1827 defines a dictionary named @code{BuildmasterConfig}, with a number of
1828 keys that are treated specially. You don't need to know Python to do
1829 basic configuration, though, you can just copy the syntax of the
1830 sample file. If you @emph{are} comfortable writing Python code,
1831 however, you can use all the power of a full programming language to
1832 achieve more complicated configurations.
1834 The @code{BuildmasterConfig} name is the only one which matters: all
1835 other names defined during the execution of the file are discarded.
1836 When parsing the config file, the Buildmaster generally compares the
1837 old configuration with the new one and performs the minimum set of
1838 actions necessary to bring the buildbot up to date: Builders which are
1839 not changed are left untouched, and Builders which are modified get to
1840 keep their old event history.
1842 Basic Python syntax: comments start with a hash character (``#''),
1843 tuples are defined with @code{(parenthesis, pairs)}, arrays are
1844 defined with @code{[square, brackets]}, tuples and arrays are mostly
1845 interchangeable. Dictionaries (data structures which map ``keys'' to
1846 ``values'') are defined with curly braces: @code{@{'key1': 'value1',
1847 'key2': 'value2'@} }. Function calls (and object instantiation) can use
1848 named parameters, like @code{w = html.Waterfall(http_port=8010)}.
1850 The config file starts with a series of @code{import} statements,
1851 which make various kinds of Steps and Status targets available for
1852 later use. The main @code{BuildmasterConfig} dictionary is created,
1853 then it is populated with a variety of keys. These keys are broken
1854 roughly into the following sections, each of which is documented in
1855 the rest of this chapter:
1857 @itemize @bullet
1858 @item
1859 Project Definitions
1860 @item
1861 Change Sources / Schedulers
1862 @item
1863 Slaveport
1864 @item
1865 Buildslave Configuration
1866 @item
1867 Builders / Interlocks
1868 @item
1869 Status Targets
1870 @item
1871 Debug options
1872 @end itemize
1874 The config file can use a few names which are placed into its namespace:
1876 @table @code
1877 @item basedir
1878 the base directory for the buildmaster. This string has not been
1879 expanded, so it may start with a tilde. It needs to be expanded before
1880 use. The config file is located in
1881 @code{os.path.expanduser(os.path.join(basedir, 'master.cfg'))}
1883 @end table
1886 @node Loading the Config File, Defining the Project, Config File Format, Configuration
1887 @section Loading the Config File
1889 The config file is only read at specific points in time. It is first
1890 read when the buildmaster is launched. Once it is running, there are
1891 various ways to ask it to reload the config file. If you are on the
1892 system hosting the buildmaster, you can send a @code{SIGHUP} signal to
1893 it: the @command{buildbot} tool has a shortcut for this:
1895 @example
1896 buildbot sighup @var{BASEDIR}
1897 @end example
1899 The debug tool (@code{buildbot debugclient --master HOST:PORT}) has a
1900 ``Reload .cfg'' button which will also trigger a reload. In the
1901 future, there will be other ways to accomplish this step (probably a
1902 password-protected button on the web page, as well as a privileged IRC
1903 command).
1906 @node Defining the Project, Listing Change Sources and Schedulers, Loading the Config File, Configuration
1907 @section Defining the Project
1909 There are a couple of basic settings that you use to tell the buildbot
1910 what project it is working on. This information is used by status
1911 reporters to let users find out more about the codebase being
1912 exercised by this particular Buildbot installation.
1914 @example
1915 c['projectName'] = "Buildbot"
1916 c['projectURL'] = "http://buildbot.sourceforge.net/"
1917 c['buildbotURL'] = "http://localhost:8010/"
1918 @end example
1920 @bcindex c['projectName']
1921 @code{projectName} is a short string will be used to describe the
1922 project that this buildbot is working on. For example, it is used as
1923 the title of the waterfall HTML page. 
1925 @bcindex c['projectURL']
1926 @code{projectURL} is a string that gives a URL for the project as a
1927 whole. HTML status displays will show @code{projectName} as a link to
1928 @code{projectURL}, to provide a link from buildbot HTML pages to your
1929 project's home page.
1931 @bcindex c['buildbotURL']
1932 The @code{buildbotURL} string should point to the location where the
1933 buildbot's internal web server (usually the @code{html.Waterfall}
1934 page) is visible. This typically uses the port number set when you
1935 create the @code{Waterfall} object: the buildbot needs your help to
1936 figure out a suitable externally-visible host name.
1938 When status notices are sent to users (either by email or over IRC),
1939 @code{buildbotURL} will be used to create a URL to the specific build
1940 or problem that they are being notified about. It will also be made
1941 available to queriers (over IRC) who want to find out where to get
1942 more information about this buildbot.
1945 @node Listing Change Sources and Schedulers, Setting the slaveport, Defining the Project, Configuration
1946 @section Listing Change Sources and Schedulers
1948 @bcindex c['sources']
1949 The @code{c['sources']} key is a list of ChangeSource
1950 instances@footnote{To be precise, it is a list of objects which all
1951 implement the @code{buildbot.interfaces.IChangeSource} Interface}.
1952 This defines how the buildmaster learns about source code changes.
1953 More information about what goes here is available in @xref{Getting
1954 Source Code Changes}.
1956 @example
1957 import buildbot.changes.pb
1958 c['sources'] = [buildbot.changes.pb.PBChangeSource()]
1959 @end example
1961 @bcindex c['schedulers']
1962 @code{c['schedulers']} is a list of Scheduler instances, each of which
1963 causes builds to be started on a particular set of Builders. The two
1964 basic Scheduler classes you are likely to start with are
1965 @code{Scheduler} and @code{Periodic}, but you can write a customized
1966 subclass to implement more complicated build scheduling.
1968 The docstring for @code{buildbot.scheduler.Scheduler} is the best
1969 place to see all the options that can be used. Type @code{pydoc
1970 buildbot.scheduler.Scheduler} to see it, or look in
1971 @file{buildbot/scheduler.py} directly.
1973 The basic Scheduler takes four arguments:
1975 @table @code
1976 @item name
1977 Each Scheduler must have a unique name. This is only used in status
1978 displays.
1980 @item branch
1981 This Scheduler will pay attention to a single branch, ignoring Changes
1982 that occur on other branches. Setting @code{branch} equal to the
1983 special value of @code{None} means it should only pay attention to the
1984 default branch. Note that @code{None} is a keyword, not a string, so
1985 you want to use @code{None} and not @code{"None"}.
1987 @item treeStableTimer
1988 The Scheduler will wait for this many seconds before starting the
1989 build. If new changes are made during this interval, the timer will be
1990 restarted, so really the build will be started after a change and then
1991 after this many seconds of inactivity.
1993 @item builderNames
1994 When the tree-stable-timer finally expires, builds will be started on
1995 these Builders. Each Builder gets a unique name: these strings must
1996 match.
1998 @end table
2000 @example
2001 from buildbot import scheduler
2002 quick = scheduler.Scheduler("quick", None, 60,
2003                             ["quick-linux", "quick-netbsd"])
2004 full = scheduler.Scheduler("full", None, 5*60,
2005                            ["full-linux", "full-netbsd", "full-OSX"])
2006 nightly = scheduler.Periodic("nightly", ["full-solaris"], 24*60*60)
2007 c['schedulers'] = [quick, full, nightly]
2008 @end example
2010 In this example, the two ``quick'' builds are triggered 60 seconds
2011 after the tree has been changed. The ``full'' builds do not run quite
2012 so quickly (they wait 5 minutes), so hopefully if the quick builds
2013 fail due to a missing file or really simple typo, the developer can
2014 discover and fix the problem before the full builds are started. Both
2015 Schedulers only pay attention to the default branch: any changes on
2016 other branches are ignored by these Schedulers. Each Scheduler
2017 triggers a different set of Builders, referenced by name.
2019 The third Scheduler in this example just runs the full solaris build
2020 once per day. (note that this Scheduler only lets you control the time
2021 between builds, not the absolute time-of-day of each Build, so this
2022 could easily wind up a ``daily'' or ``every afternoon'' scheduler
2023 depending upon when it was first activated).
2025 @menu
2026 * Scheduler Types::             
2027 * Build Dependencies::          
2028 @end menu
2030 @node Scheduler Types, Build Dependencies, Listing Change Sources and Schedulers, Listing Change Sources and Schedulers
2031 @subsection Scheduler Types
2033 @slindex buildbot.scheduler.Scheduler
2034 @slindex buildbot.scheduler.AnyBranchScheduler
2035 @slindex buildbot.scheduler.Periodic
2036 @slindex buildbot.scheduler.Nightly
2038 Here is a brief catalog of the available Scheduler types. All these
2039 Schedulers are classes in @code{buildbot.scheduler}, and the
2040 docstrings there are the best source of documentation on the arguments
2041 taken by each one.
2043 @table @code
2044 @item Scheduler
2045 This is the default Scheduler class. It follows exactly one branch,
2046 and starts a configurable tree-stable-timer after each change on that
2047 branch. When the timer expires, it starts a build on some set of
2048 Builders. The Scheduler accepts a @code{fileIsImportant} function
2049 which can be used to ignore some Changes if they do not affect any
2050 ``important'' files.
2052 @item AnyBranchScheduler
2053 This scheduler uses a tree-stable-timer like the default one, but
2054 follows multiple branches at once. Each branch gets a separate timer.
2056 @item Dependent
2057 This scheduler watches an ``upstream'' Builder. When that Builder
2058 successfully builds a particular set of Changes, it triggers builds of
2059 the same code on a configured set of ``downstream'' builders. The next
2060 section (@pxref{Build Dependencies}) describes this scheduler in more
2061 detail.
2063 @item Periodic
2064 This simple scheduler just triggers a build every N seconds.
2066 @item Nightly
2067 This is highly configurable periodic build scheduler, which triggers a
2068 build at particular times of day, week, month, or year. The
2069 configuration syntax is very similar to the well-known @code{crontab}
2070 format, in which you provide values for minute, hour, day, and month
2071 (some of which can be wildcards), and a build is triggered whenever
2072 the current time matches the given constraints. This can run a build
2073 every night, every morning, every weekend, alternate Thursdays, on
2074 your boss's birthday, etc.
2076 @item Try_Jobdir / Try_Userpass
2077 This scheduler allows developers to use the @code{buildbot try}
2078 command to trigger builds of code they have not yet committed. See
2079 @ref{try} for complete details.
2081 @end table
2083 @node Build Dependencies,  , Scheduler Types, Listing Change Sources and Schedulers
2084 @subsection Build Dependencies
2086 @cindex Dependent
2087 @cindex Dependencies
2088 @slindex buildbot.scheduler.Dependent
2090 It is common to wind up with one kind of build which should only be
2091 performed if the same source code was successfully handled by some
2092 other kind of build first. An example might be a packaging step: you
2093 might only want to produce .deb or RPM packages from a tree that was
2094 known to compile successfully and pass all unit tests. You could put
2095 the packaging step in the same Build as the compile and testing steps,
2096 but there might be other reasons to not do this (in particular you
2097 might have several Builders worth of compiles/tests, but only wish to
2098 do the packaging once). Another example is if you want to skip the
2099 ``full'' builds after a failing ``quick'' build of the same source
2100 code. Or, if one Build creates a product (like a compiled library)
2101 that is used by some other Builder, you'd want to make sure the
2102 consuming Build is run @emph{after} the producing one.
2104 You can use @code{Dependencies} to express this relationship to the
2105 Buildbot. There is a special kind of Scheduler named
2106 @code{scheduler.Dependent} that will watch an ``upstream'' Scheduler
2107 for builds to complete successfully (on all of its Builders). Each
2108 time that happens, the same source code (i.e. the same
2109 @code{SourceStamp}) will be used to start a new set of builds, on a
2110 different set of Builders. This ``downstream'' scheduler doesn't pay
2111 attention to Changes at all, it only pays attention to the upstream
2112 scheduler.
2114 If the SourceStamp fails on any of the Builders in the upstream set,
2115 the downstream builds will not fire.
2117 @example
2118 from buildbot import scheduler
2119 tests = scheduler.Scheduler("tests", None, 5*60,
2120                             ["full-linux", "full-netbsd", "full-OSX"])
2121 package = scheduler.Dependent("package",
2122                               tests, # upstream scheduler
2123                               ["make-tarball", "make-deb", "make-rpm"])
2124 c['schedulers'] = [tests, package]
2125 @end example
2127 Note that @code{Dependent}'s upstream scheduler argument is given as a
2128 @code{Scheduler} @emph{instance}, not a name. This makes it impossible
2129 to create circular dependencies in the config file.
2132 @node Setting the slaveport, Buildslave Specifiers, Listing Change Sources and Schedulers, Configuration
2133 @section Setting the slaveport
2135 @bcindex c['slavePortnum']
2137 The buildmaster will listen on a TCP port of your choosing for
2138 connections from buildslaves. It can also use this port for
2139 connections from remote Change Sources, status clients, and debug
2140 tools. This port should be visible to the outside world, and you'll
2141 need to tell your buildslave admins about your choice.
2143 It does not matter which port you pick, as long it is externally
2144 visible, however you should probably use something larger than 1024,
2145 since most operating systems don't allow non-root processes to bind to
2146 low-numbered ports. If your buildmaster is behind a firewall or a NAT
2147 box of some sort, you may have to configure your firewall to permit
2148 inbound connections to this port.
2150 @example
2151 c['slavePortnum'] = 10000
2152 @end example
2154 @code{c['slavePortnum']} is a @emph{strports} specification string,
2155 defined in the @code{twisted.application.strports} module (try
2156 @command{pydoc twisted.application.strports} to get documentation on
2157 the format). This means that you can have the buildmaster listen on a
2158 localhost-only port by doing:
2160 @example
2161 c['slavePortnum'] = "tcp:10000:interface=127.0.0.1"
2162 @end example
2164 This might be useful if you only run buildslaves on the same machine,
2165 and they are all configured to contact the buildmaster at
2166 @code{localhost:10000}.
2169 @node Buildslave Specifiers, Defining Builders, Setting the slaveport, Configuration
2170 @section Buildslave Specifiers
2172 @bcindex c['bots']
2174 The @code{c['bots']} key is a list of known buildslaves. Each
2175 buildslave is defined by a tuple of (slavename, slavepassword). These
2176 are the same two values that need to be provided to the buildslave
2177 administrator when they create the buildslave.
2179 @example
2180 c['bots'] = [('bot-solaris', 'solarispasswd'),
2181              ('bot-bsd', 'bsdpasswd'),
2182             ]
2183 @end example
2185 The slavenames must be unique, of course. The password exists to
2186 prevent evildoers from interfering with the buildbot by inserting
2187 their own (broken) buildslaves into the system and thus displacing the
2188 real ones.
2190 Buildslaves with an unrecognized slavename or a non-matching password
2191 will be rejected when they attempt to connect, and a message
2192 describing the problem will be put in the log file (see @ref{Logfiles}).
2195 @node Defining Builders, Defining Status Targets, Buildslave Specifiers, Configuration
2196 @section Defining Builders
2198 @bcindex c['builders']
2200 The @code{c['builders']} key is a list of dictionaries which specify
2201 the Builders. The Buildmaster runs a collection of Builders, each of
2202 which handles a single type of build (e.g. full versus quick), on a
2203 single build slave. A Buildbot which makes sure that the latest code
2204 (``HEAD'') compiles correctly across four separate architecture will
2205 have four Builders, each performing the same build but on different
2206 slaves (one per platform).
2208 Each Builder gets a separate column in the waterfall display. In
2209 general, each Builder runs independently (although various kinds of
2210 interlocks can cause one Builder to have an effect on another).
2212 Each Builder specification dictionary has several required keys:
2214 @table @code
2215 @item name
2216 This specifies the Builder's name, which is used in status
2217 reports.
2219 @item slavename
2220 This specifies which buildslave will be used by this Builder.
2221 @code{slavename} must appear in the @code{c['bots']} list. Each
2222 buildslave can accomodate multiple Builders.
2224 @item slavenames
2225 If you provide @code{slavenames} instead of @code{slavename}, you can
2226 give a list of buildslaves which are capable of running this Builder.
2227 If multiple buildslaves are available for any given Builder, you will
2228 have some measure of redundancy: in case one slave goes offline, the
2229 others can still keep the Builder working. In addition, multiple
2230 buildslaves will allow multiple simultaneous builds for the same
2231 Builder, which might be useful if you have a lot of forced or ``try''
2232 builds taking place.
2234 If you use this feature, it is important to make sure that the
2235 buildslaves are all, in fact, capable of running the given build. The
2236 slave hosts should be configured similarly, otherwise you will spend a
2237 lot of time trying (unsuccessfully) to reproduce a failure that only
2238 occurs on some of the buildslaves and not the others. Different
2239 platforms, operating systems, versions of major programs or libraries,
2240 all these things mean you should use separate Builders.
2242 @item builddir
2243 This specifies the name of a subdirectory (under the base directory)
2244 in which everything related to this builder will be placed. On the
2245 buildmaster, this holds build status information. On the buildslave,
2246 this is where checkouts, compiles, and tests are run.
2248 @item factory
2249 This is a @code{buildbot.process.factory.BuildFactory} instance which
2250 controls how the build is performed. Full details appear in their own
2251 chapter, @xref{Build Process}. Parameters like the location of the CVS
2252 repository and the compile-time options used for the build are
2253 generally provided as arguments to the factory's constructor.
2255 @end table
2257 Other optional keys may be set on each Builder:
2259 @table @code
2261 @item category
2262 If provided, this is a string that identifies a category for the
2263 builder to be a part of. Status clients can limit themselves to a
2264 subset of the available categories. A common use for this is to add
2265 new builders to your setup (for a new module, or for a new buildslave)
2266 that do not work correctly yet and allow you to integrate them with
2267 the active builders. You can put these new builders in a test
2268 category, make your main status clients ignore them, and have only
2269 private status clients pick them up. As soon as they work, you can
2270 move them over to the active category.
2272 @end table
2275 @node Defining Status Targets, Debug options, Defining Builders, Configuration
2276 @section Defining Status Targets
2278 The Buildmaster has a variety of ways to present build status to
2279 various users. Each such delivery method is a ``Status Target'' object
2280 in the configuration's @code{status} list. To add status targets, you
2281 just append more objects to this list:
2283 @bcindex c['status']
2285 @example
2286 c['status'] = []
2288 from buildbot.status import html
2289 c['status'].append(html.Waterfall(http_port=8010))
2291 from buildbot.status import mail
2292 m = mail.MailNotifier(fromaddr="buildbot@@localhost",
2293                       extraRecipients=["builds@@lists.example.com"],
2294                       sendToInterestedUsers=False)
2295 c['status'].append(m)
2297 from buildbot.status import words
2298 c['status'].append(words.IRC(host="irc.example.com", nick="bb",
2299                              channels=["#example"]))
2300 @end example
2302 Status delivery has its own chapter, @xref{Status Delivery}, in which
2303 all the built-in status targets are documented.
2306 @node Debug options,  , Defining Status Targets, Configuration
2307 @section Debug options
2310 @bcindex c['debugPassword']
2311 If you set @code{c['debugPassword']}, then you can connect to the
2312 buildmaster with the diagnostic tool launched by @code{buildbot
2313 debugclient MASTER:PORT}. From this tool, you can reload the config
2314 file, manually force builds, and inject changes, which may be useful
2315 for testing your buildmaster without actually commiting changes to
2316 your repository (or before you have the Change Sources set up). The
2317 debug tool uses the same port number as the slaves do:
2318 @code{c['slavePortnum']}, and is authenticated with this password.
2320 @example
2321 c['debugPassword'] = "debugpassword"
2322 @end example
2324 @bcindex c['manhole']
2325 If you set @code{c['manhole']} to an instance of one of the classes in
2326 @code{buildbot.manhole}, you can telnet or ssh into the buildmaster
2327 and get an interactive Python shell, which may be useful for debugging
2328 buildbot internals. It is probably only useful for buildbot
2329 developers. It exposes full access to the buildmaster's account
2330 (including the ability to modify and delete files), so it should not
2331 be enabled with a weak or easily guessable password.
2333 There are three separate @code{Manhole} classes. Two of them use SSH,
2334 one uses unencrypted telnet. Two of them use a username+password
2335 combination to grant access, one of them uses an SSH-style
2336 @file{authorized_keys} file which contains a list of ssh public keys.
2338 @table @code
2339 @item manhole.AuthorizedKeysManhole
2340 You construct this with the name of a file that contains one SSH
2341 public key per line, just like @file{~/.ssh/authorized_keys}. If you
2342 provide a non-absolute filename, it will be interpreted relative to
2343 the buildmaster's base directory.
2345 @item manhole.PasswordManhole
2346 This one accepts SSH connections but asks for a username and password
2347 when authenticating. It accepts only one such pair.
2350 @item manhole.TelnetManhole
2351 This accepts regular unencrypted telnet connections, and asks for a
2352 username/password pair before providing access. Because this
2353 username/password is transmitted in the clear, and because Manhole
2354 access to the buildmaster is equivalent to granting full shell
2355 privileges to both the buildmaster and all the buildslaves (and to all
2356 accounts which then run code produced by the buildslaves), it is
2357 highly recommended that you use one of the SSH manholes instead.
2359 @end table
2361 @example
2362 # some examples:
2363 from buildbot import manhole
2364 c['manhole'] = manhole.AuthorizedKeysManhole(1234, "authorized_keys")
2365 c['manhole'] = manhole.PasswordManhole(1234, "alice", "mysecretpassword")
2366 c['manhole'] = manhole.TelnetManhole(1234, "bob", "snoop_my_password_please")
2367 @end example
2369 The @code{Manhole} instance can be configured to listen on a specific
2370 port. You may wish to have this listening port bind to the loopback
2371 interface (sometimes known as ``lo0'', ``localhost'', or 127.0.0.1) to
2372 restrict access to clients which are running on the same host.
2374 @example
2375 from buildbot.manhole import PasswordManhole
2376 c['manhole'] = PasswordManhole("tcp:9999:interface=127.0.0.1","admin","passwd")
2377 @end example
2379 To have the @code{Manhole} listen on all interfaces, use
2380 @code{"tcp:9999"} or simply 9999. This port specification uses
2381 @code{twisted.application.strports}, so you can make it listen on SSL
2382 or even UNIX-domain sockets if you want.
2384 Note that using any Manhole requires that the TwistedConch package be
2385 installed, and that you be using Twisted version 2.0 or later.
2387 The buildmaster's SSH server will use a different host key than the
2388 normal sshd running on a typical unix host. This will cause the ssh
2389 client to complain about a ``host key mismatch'', because it does not
2390 realize there are two separate servers running on the same host. To
2391 avoid this, use a clause like the following in your @file{.ssh/config}
2392 file:
2394 @example
2395 Host remotehost-buildbot
2396  HostName remotehost
2397  HostKeyAlias remotehost-buildbot
2398  Port 9999
2399  # use 'user' if you use PasswordManhole and your name is not 'admin'.
2400  # if you use AuthorizedKeysManhole, this probably doesn't matter.
2401  User admin
2402 @end example
2405 @node Getting Source Code Changes, Build Process, Configuration, Top
2406 @chapter Getting Source Code Changes
2408 The most common way to use the Buildbot is centered around the idea of
2409 @code{Source Trees}: a directory tree filled with source code of some form
2410 which can be compiled and/or tested. Some projects use languages that don't
2411 involve any compilation step: nevertheless there may be a @code{build} phase
2412 where files are copied or rearranged into a form that is suitable for
2413 installation. Some projects do not have unit tests, and the Buildbot is
2414 merely helping to make sure that the sources can compile correctly. But in
2415 all of these cases, the thing-being-tested is a single source tree.
2417 A Version Control System mantains a source tree, and tells the
2418 buildmaster when it changes. The first step of each Build is typically
2419 to acquire a copy of some version of this tree.
2421 This chapter describes how the Buildbot learns about what Changes have
2422 occurred. For more information on VC systems and Changes, see
2423 @ref{Version Control Systems}.
2426 @menu
2427 * Change Sources::              
2428 @end menu
2432 @node Change Sources,  , Getting Source Code Changes, Getting Source Code Changes
2433 @section Change Sources
2435 @c TODO: rework this, the one-buildmaster-one-tree thing isn't quite
2436 @c so narrow-minded anymore
2438 Each Buildmaster watches a single source tree. Changes can be provided
2439 by a variety of ChangeSource types, however any given project will
2440 typically have only a single ChangeSource active. This section
2441 provides a description of all available ChangeSource types and
2442 explains how to set up each of them.
2444 There are a variety of ChangeSources available, some of which are
2445 meant to be used in conjunction with other tools to deliver Change
2446 events from the VC repository to the buildmaster.
2448 @itemize @bullet
2450 @item CVSToys
2451 This ChangeSource opens a TCP connection from the buildmaster to a
2452 waiting FreshCVS daemon that lives on the repository machine, and
2453 subscribes to hear about Changes.
2455 @item MaildirSource
2456 This one watches a local maildir-format inbox for email sent out by
2457 the repository when a change is made. When a message arrives, it is
2458 parsed to create the Change object. A variety of parsing functions are
2459 available to accomodate different email-sending tools.
2461 @item PBChangeSource
2462 This ChangeSource listens on a local TCP socket for inbound
2463 connections from a separate tool. Usually, this tool would be run on
2464 the VC repository machine in a commit hook. It is expected to connect
2465 to the TCP socket and send a Change message over the network
2466 connection. The @command{buildbot sendchange} command is one example
2467 of a tool that knows how to send these messages, so you can write a
2468 commit script for your VC system that calls it to deliver the Change.
2469 There are other tools in the contrib/ directory that use the same
2470 protocol.
2472 @end itemize
2474 As a quick guide, here is a list of VC systems and the ChangeSources
2475 that might be useful with them. All of these ChangeSources are in the
2476 @code{buildbot.changes} module.
2478 @table @code
2479 @item CVS
2481 @itemize @bullet
2482 @item freshcvs.FreshCVSSource (connected via TCP to the freshcvs daemon)
2483 @item mail.FCMaildirSource (watching for email sent by a freshcvs daemon)
2484 @item mail.BonsaiMaildirSource (watching for email sent by Bonsai)
2485 @item mail.SyncmailMaildirSource (watching for email sent by syncmail)
2486 @item pb.PBChangeSource (listening for connections from @code{buildbot
2487 sendchange} run in a loginfo script)
2488 @item pb.PBChangeSource (listening for connections from a long-running
2489 @code{contrib/viewcvspoll.py} polling process which examines the ViewCVS
2490 database directly
2491 @end itemize
2493 @item SVN
2494 @itemize @bullet
2495 @item pb.PBChangeSource (listening for connections from
2496 @code{contrib/svn_buildbot.py} run in a postcommit script)
2497 @item pb.PBChangeSource (listening for connections from a long-running
2498 @code{contrib/svn_watcher.py} or @code{contrib/svnpoller.py} polling
2499 process
2500 @end itemize
2502 @item Darcs
2503 @itemize @bullet
2504 @item pb.PBChangeSource (listening for connections from
2505 @code{contrib/darcs_buildbot.py} in a commit script
2506 @end itemize
2508 @item Mercurial
2509 @itemize @bullet
2510 @item pb.PBChangeSource (listening for connections from
2511 @code{contrib/hg_buildbot.py} run in an 'incoming' hook)
2512 @end itemize
2514 @item Arch/Bazaar
2515 @itemize @bullet
2516 @item pb.PBChangeSource (listening for connections from
2517 @code{contrib/arch_buildbot.py} run in a commit hook)
2518 @end itemize
2520 @end table
2522 All VC systems can be driven by a PBChangeSource and the
2523 @code{buildbot sendchange} tool run from some form of commit script.
2524 If you write an email parsing function, they can also all be driven by
2525 a suitable @code{MaildirSource}.
2528 @menu
2529 * Choosing ChangeSources::      
2530 * CVSToys - PBService::         
2531 * CVSToys - mail notification::  
2532 * Other mail notification ChangeSources::  
2533 * PBChangeSource::              
2534 * P4Source::                    
2535 * BonsaiPoller::                
2536 @end menu
2538 @node Choosing ChangeSources, CVSToys - PBService, Change Sources, Change Sources
2539 @subsection Choosing ChangeSources
2541 The @code{master.cfg} configuration file has a dictionary key named
2542 @code{BuildmasterConfig['sources']}, which holds a list of
2543 @code{IChangeSource} objects. The config file will typically create an
2544 object from one of the classes described below and stuff it into the
2545 list.
2547 @example
2548 s = FreshCVSSourceNewcred(host="host", port=4519,
2549                           user="alice", passwd="secret",
2550                           prefix="Twisted")
2551 BuildmasterConfig['sources'] = [s]
2552 @end example
2554 Each source tree has a nominal @code{top}. Each Change has a list of
2555 filenames, which are all relative to this top location. The
2556 ChangeSource is responsible for doing whatever is necessary to
2557 accomplish this. Most sources have a @code{prefix} argument: a partial
2558 pathname which is stripped from the front of all filenames provided to
2559 that @code{ChangeSource}. Files which are outside this sub-tree are
2560 ignored by the changesource: it does not generate Changes for those
2561 files.
2564 @node CVSToys - PBService, CVSToys - mail notification, Choosing ChangeSources, Change Sources
2565 @subsection CVSToys - PBService
2567 @csindex buildbot.changes.freshcvs.FreshCVSSource
2569 The @uref{http://purl.net/net/CVSToys, CVSToys} package provides a
2570 server which runs on the machine that hosts the CVS repository it
2571 watches. It has a variety of ways to distribute commit notifications,
2572 and offers a flexible regexp-based way to filter out uninteresting
2573 changes. One of the notification options is named @code{PBService} and
2574 works by listening on a TCP port for clients. These clients subscribe
2575 to hear about commit notifications.
2577 The buildmaster has a CVSToys-compatible @code{PBService} client built
2578 in. There are two versions of it, one for old versions of CVSToys
2579 (1.0.9 and earlier) which used the @code{oldcred} authentication
2580 framework, and one for newer versions (1.0.10 and later) which use
2581 @code{newcred}. Both are classes in the
2582 @code{buildbot.changes.freshcvs} package.
2584 @code{FreshCVSSourceNewcred} objects are created with the following
2585 parameters:
2587 @table @samp
2589 @item @code{host} and @code{port}
2590 these specify where the CVSToys server can be reached
2592 @item @code{user} and @code{passwd}
2593 these specify the login information for the CVSToys server
2594 (@code{freshcvs}). These must match the server's values, which are
2595 defined in the @code{freshCfg} configuration file (which lives in the
2596 CVSROOT directory of the repository).
2598 @item @code{prefix}
2599 this is the prefix to be found and stripped from filenames delivered
2600 by the CVSToys server. Most projects live in sub-directories of the
2601 main repository, as siblings of the CVSROOT sub-directory, so
2602 typically this prefix is set to that top sub-directory name.
2604 @end table
2606 @heading Example
2608 To set up the freshCVS server, add a statement like the following to
2609 your @file{freshCfg} file:
2611 @example
2612 pb = ConfigurationSet([
2613     (None, None, None, PBService(userpass=('foo', 'bar'), port=4519)),
2614     ])
2615 @end example
2617 This will announce all changes to a client which connects to port 4519
2618 using a username of 'foo' and a password of 'bar'.
2620 Then add a clause like this to your buildmaster's @file{master.cfg}:
2622 @example
2623 BuildmasterConfig['sources'] = [FreshCVSSource("cvs.example.com", 4519,
2624                                 "foo", "bar",
2625                                 prefix="glib/")]
2626 @end example
2628 where "cvs.example.com" is the host that is running the FreshCVS daemon, and
2629 "glib" is the top-level directory (relative to the repository's root) where
2630 all your source code lives. Most projects keep one or more projects in the
2631 same repository (along with CVSROOT/ to hold admin files like loginfo and
2632 freshCfg); the prefix= argument tells the buildmaster to ignore everything
2633 outside that directory, and to strip that common prefix from all pathnames
2634 it handles.
2638 @node CVSToys - mail notification, Other mail notification ChangeSources, CVSToys - PBService, Change Sources
2639 @subsection CVSToys - mail notification
2641 @csindex buildbot.changes.mail.FCMaildirSource
2643 CVSToys also provides a @code{MailNotification} action which will send
2644 email to a list of recipients for each commit. This tends to work
2645 better than using @code{/bin/mail} from within the CVSROOT/loginfo
2646 file directly, as CVSToys will batch together all files changed during
2647 the same CVS invocation, and can provide more information (like
2648 creating a ViewCVS URL for each file changed).
2650 The Buildbot's @code{FCMaildirSource} is a ChangeSource which knows
2651 how to parse these CVSToys messages and turn them into Change objects.
2652 It watches a Maildir for new messages. The usually installation
2653 process looks like:
2655 @enumerate
2656 @item
2657 Create a mailing list, @code{projectname-commits}.
2658 @item
2659 In CVSToys' freshCfg file, use a @code{MailNotification} action to
2660 send commit mail to this mailing list.
2661 @item
2662 Subscribe the buildbot user to the mailing list.
2663 @item
2664 Configure your .qmail or .forward file to deliver these messages into
2665 a maildir.
2666 @item
2667 In the Buildbot's master.cfg file, use a @code{FCMaildirSource} to
2668 watch the maildir for commit messages.
2669 @end enumerate
2671 The @code{FCMaildirSource} is created with two parameters: the
2672 directory name of the maildir root, and the prefix to strip.
2674 @node Other mail notification ChangeSources, PBChangeSource, CVSToys - mail notification, Change Sources
2675 @subsection Other mail notification ChangeSources
2677 @csindex buildbot.changes.mail.SyncmailMaildirSource
2678 @csindex buildbot.changes.mail.BonsaiMaildirSource
2680 There are other types of maildir-watching ChangeSources, which only
2681 differ in the function used to parse the message body.
2683 @code{SyncmailMaildirSource} knows how to parse the message format
2684 used in mail sent by Syncmail.
2686 @code{BonsaiMaildirSource} parses messages sent out by Bonsai.
2688 @node PBChangeSource, P4Source, Other mail notification ChangeSources, Change Sources
2689 @subsection PBChangeSource
2691 @csindex buildbot.changes.pb.PBChangeSource
2693 The last kind of ChangeSource actually listens on a TCP port for
2694 clients to connect and push change notices @emph{into} the
2695 Buildmaster. This is used by the built-in @code{buildbot sendchange}
2696 notification tool, as well as the VC-specific
2697 @file{contrib/svn_buildbot.py} and @file{contrib/arch_buildbot.py}
2698 tools. These tools are run by the repository (in a commit hook
2699 script), and connect to the buildmaster directly each time a file is
2700 comitted. This is also useful for creating new kinds of change sources
2701 that work on a @code{push} model instead of some kind of subscription
2702 scheme, for example a script which is run out of an email .forward
2703 file.
2705 This ChangeSource can be configured to listen on its own TCP port, or
2706 it can share the port that the buildmaster is already using for the
2707 buildslaves to connect. (This is possible because the
2708 @code{PBChangeSource} uses the same protocol as the buildslaves, and
2709 they can be distinguished by the @code{username} attribute used when
2710 the initial connection is established). It might be useful to have it
2711 listen on a different port if, for example, you wanted to establish
2712 different firewall rules for that port. You could allow only the SVN
2713 repository machine access to the @code{PBChangeSource} port, while
2714 allowing only the buildslave machines access to the slave port. Or you
2715 could just expose one port and run everything over it. @emph{Note:
2716 this feature is not yet implemented, the PBChangeSource will always
2717 share the slave port and will always have a @code{user} name of
2718 @code{change}, and a passwd of @code{changepw}. These limitations will
2719 be removed in the future.}.
2722 The @code{PBChangeSource} is created with the following arguments. All
2723 are optional.
2725 @table @samp
2726 @item @code{port}
2727 which port to listen on. If @code{None} (which is the default), it
2728 shares the port used for buildslave connections. @emph{Not
2729 Implemented, always set to @code{None}}.
2731 @item @code{user} and @code{passwd}
2732 The user/passwd account information that the client program must use
2733 to connect. Defaults to @code{change} and @code{changepw}. @emph{Not
2734 Implemented, @code{user} is currently always set to @code{change},
2735 @code{passwd} is always set to @code{changepw}}.
2737 @item @code{prefix}
2738 The prefix to be found and stripped from filenames delivered over the
2739 connection. Any filenames which do not start with this prefix will be
2740 removed. If all the filenames in a given Change are removed, the that
2741 whole Change will be dropped. This string should probably end with a
2742 directory separator.
2744 This is useful for changes coming from version control systems that
2745 represent branches as parent directories within the repository (like
2746 SVN and Perforce). Use a prefix of 'trunk/' or
2747 'project/branches/foobranch/' to only follow one branch and to get
2748 correct tree-relative filenames. Without a prefix, the PBChangeSource
2749 will probably deliver Changes with filenames like @file{trunk/foo.c}
2750 instead of just @file{foo.c}. Of course this also depends upon the
2751 tool sending the Changes in (like @command{buildbot sendchange}) and
2752 what filenames it is delivering: that tool may be filtering and
2753 stripping prefixes at the sending end.
2755 @end table
2758 @node P4Source, BonsaiPoller, PBChangeSource, Change Sources
2759 @subsection P4Source
2761 @csindex buildbot.changes.p4poller.P4Source
2763 The @code{P4Source} periodically polls a @uref{http://www.perforce.com/,
2764 Perforce} depot for changes. It accepts the following arguments:
2766 @table @samp
2767 @item @code{p4base}
2768 The base depot path to watch, without the trailing '/...'.
2770 @item @code{p4port}
2771 The Perforce server to connect to (as host:port).
2773 @item @code{p4user}
2774 The Perforce user.
2776 @item @code{p4passwd}
2777 The Perforce password.
2779 @item @code{split_file}
2780 A function that maps a pathname, without the leading @code{p4base}, to a
2781 (branch, filename) tuple. The default just returns (None, branchfile),
2782 which effectively disables branch support. You should supply a function
2783 which understands your repository structure.
2785 @item @code{pollinterval}
2786 How often to poll, in seconds. Defaults to 600 (10 minutes).
2788 @item @code{histmax}
2789 The maximum number of changes to inspect at a time. If more than this
2790 number occur since the last poll, older changes will be silently
2791 ignored.
2792 @end table
2794 @heading Example
2796 This configuration uses the @code{P4PORT}, @code{P4USER}, and @code{P4PASSWD}
2797 specified in the buildmaster's environment. It watches a project in which the
2798 branch name is simply the next path component, and the file is all path
2799 components after.
2801 @example
2802 import buildbot.changes.p4poller
2803 c['sources'].append(p4poller.P4Source(
2804         p4base='//depot/project/',
2805         split_file=lambda branchfile: branchfile.split('/',1)
2807 @end example
2809 @node BonsaiPoller,  , P4Source, Change Sources
2810 @subsection BonsaiPoller
2812 @csindex buildbot.changes.bonsaipoller.BonsaiPoller
2814 The @code{BonsaiPoller} periodically polls a Bonsai server. This is a
2815 CGI script accessed through a web server that provides information
2816 about a CVS tree, for example the Mozilla bonsai server at
2817 @uref{http://bonsai.mozilla.org}. Bonsai servers are usable by both
2818 humans and machines. In this case, the buildbot's change source forms
2819 a query which asks about any files in the specified branch which have
2820 changed since the last query.
2822 Please take a look at the BonsaiPoller docstring for details about the
2823 arguments it accepts.
2826 @node Build Process, Status Delivery, Getting Source Code Changes, Top
2827 @chapter Build Process
2829 A @code{Build} object is responsible for actually performing a build.
2830 It gets access to a remote @code{SlaveBuilder} where it may run
2831 commands, and a @code{BuildStatus} object where it must emit status
2832 events. The @code{Build} is created by the Builder's
2833 @code{BuildFactory}.
2835 The default @code{Build} class is made up of a fixed sequence of
2836 @code{BuildSteps}, executed one after another until all are complete
2837 (or one of them indicates that the build should be halted early). The
2838 default @code{BuildFactory} creates instances of this @code{Build}
2839 class with a list of @code{BuildSteps}, so the basic way to configure
2840 the build is to provide a list of @code{BuildSteps} to your
2841 @code{BuildFactory}.
2843 More complicated @code{Build} subclasses can make other decisions:
2844 execute some steps only if certain files were changed, or if certain
2845 previous steps passed or failed. The base class has been written to
2846 allow users to express basic control flow without writing code, but
2847 you can always subclass and customize to achieve more specialized
2848 behavior.
2850 @menu
2851 * Build Steps::                 
2852 * Interlocks::                  
2853 * Build Factories::             
2854 @end menu
2856 @node Build Steps, Interlocks, Build Process, Build Process
2857 @section Build Steps
2859 @code{BuildStep}s are usually specified in the buildmaster's
2860 configuration file, in a list of ``step specifications'' that is used
2861 to create the @code{BuildFactory}. These ``step specifications'' are
2862 not actual steps, but rather a tuple of the @code{BuildStep} subclass
2863 to be created and a dictionary of arguments. (the actual
2864 @code{BuildStep} instances are not created until the Build is started,
2865 so that each Build gets an independent copy of each BuildStep). The
2866 preferred way to create these step specifications is with the
2867 @code{BuildFactory}'s @code{addStep} method:
2869 @example
2870 from buildbot.steps import source, shell
2871 from buildbot.process import factory
2873 f = factory.BuildFactory()
2874 f.addStep(source.SVN, svnurl="http://svn.example.org/Trunk/")
2875 f.addStep(shell.ShellCommand, command=["make", "all"])
2876 f.addStep(shell.ShellCommand, command=["make", "test"])
2877 @end example
2879 The rest of this section lists all the standard BuildStep objects
2880 available for use in a Build, and the parameters which can be used to
2881 control each.
2883 @menu
2884 * Common Parameters::           
2885 * Source Checkout::             
2886 * ShellCommand::                
2887 * Simple ShellCommand Subclasses::  
2888 * Python BuildSteps::           
2889 * Transferring Files::          
2890 * Writing New BuildSteps::      
2891 @end menu
2893 @node Common Parameters, Source Checkout, Build Steps, Build Steps
2894 @subsection Common Parameters
2896 The standard @code{Build} runs a series of @code{BuildStep}s in order,
2897 only stopping when it runs out of steps or if one of them requests
2898 that the build be halted. It collects status information from each one
2899 to create an overall build status (of SUCCESS, WARNINGS, or FAILURE).
2901 All BuildSteps accept some common parameters. Some of these control
2902 how their individual status affects the overall build. Others are used
2903 to specify which @code{Locks} (see @pxref{Interlocks}) should be
2904 acquired before allowing the step to run.
2906 Arguments common to all @code{BuildStep} subclasses:
2909 @table @code
2910 @item name
2911 the name used to describe the step on the status display. It is also
2912 used to give a name to any LogFiles created by this step.
2914 @item haltOnFailure
2915 if True, a FAILURE of this build step will cause the build to halt
2916 immediately with an overall result of FAILURE.
2918 @item flunkOnWarnings
2919 when True, a WARNINGS or FAILURE of this build step will mark the
2920 overall build as FAILURE. The remaining steps will still be executed.
2922 @item flunkOnFailure
2923 when True, a FAILURE of this build step will mark the overall build as
2924 a FAILURE. The remaining steps will still be executed.
2926 @item warnOnWarnings
2927 when True, a WARNINGS or FAILURE of this build step will mark the
2928 overall build as having WARNINGS. The remaining steps will still be
2929 executed.
2931 @item warnOnFailure
2932 when True, a FAILURE of this build step will mark the overall build as
2933 having WARNINGS. The remaining steps will still be executed.
2935 @item locks
2936 a list of Locks (instances of @code{buildbot.locks.SlaveLock} or
2937 @code{buildbot.locks.MasterLock}) that should be acquired before
2938 starting this Step. The Locks will be released when the step is
2939 complete. Note that this is a list of actual Lock instances, not
2940 names. Also note that all Locks must have unique names.
2942 @end table
2945 @node Source Checkout, ShellCommand, Common Parameters, Build Steps
2946 @subsection Source Checkout
2948 The first step of any build is typically to acquire the source code
2949 from which the build will be performed. There are several classes to
2950 handle this, one for each of the different source control system that
2951 Buildbot knows about. For a description of how Buildbot treats source
2952 control in general, see @ref{Version Control Systems}.
2954 All source checkout steps accept some common parameters to control how
2955 they get the sources and where they should be placed. The remaining
2956 per-VC-system parameters are mostly to specify where exactly the
2957 sources are coming from.
2959 @table @code
2960 @item mode
2962 a string describing the kind of VC operation that is desired. Defaults
2963 to @code{update}.
2965 @table @code
2966 @item update
2967 specifies that the CVS checkout/update should be performed directly
2968 into the workdir. Each build is performed in the same directory,
2969 allowing for incremental builds. This minimizes disk space, bandwidth,
2970 and CPU time. However, it may encounter problems if the build process
2971 does not handle dependencies properly (sometimes you must do a ``clean
2972 build'' to make sure everything gets compiled), or if source files are
2973 deleted but generated files can influence test behavior (e.g. python's
2974 .pyc files), or when source directories are deleted but generated
2975 files prevent CVS from removing them. Builds ought to be correct
2976 regardless of whether they are done ``from scratch'' or incrementally,
2977 but it is useful to test both kinds: this mode exercises the
2978 incremental-build style.
2980 @item copy
2981 specifies that the CVS workspace should be maintained in a separate
2982 directory (called the 'copydir'), using checkout or update as
2983 necessary. For each build, a new workdir is created with a copy of the
2984 source tree (rm -rf workdir; cp -r copydir workdir). This doubles the
2985 disk space required, but keeps the bandwidth low (update instead of a
2986 full checkout). A full 'clean' build is performed each time. This
2987 avoids any generated-file build problems, but is still occasionally
2988 vulnerable to CVS problems such as a repository being manually
2989 rearranged, causing CVS errors on update which are not an issue with a
2990 full checkout.
2992 @c TODO: something is screwy about this, revisit. Is it the source
2993 @c directory or the working directory that is deleted each time?
2995 @item clobber
2996 specifes that the working directory should be deleted each time,
2997 necessitating a full checkout for each build. This insures a clean
2998 build off a complete checkout, avoiding any of the problems described
2999 above. This mode exercises the ``from-scratch'' build style.
3001 @item export
3002 this is like @code{clobber}, except that the 'cvs export' command is
3003 used to create the working directory. This command removes all CVS
3004 metadata files (the CVS/ directories) from the tree, which is
3005 sometimes useful for creating source tarballs (to avoid including the
3006 metadata in the tar file).
3007 @end table
3009 @item workdir
3010 like all Steps, this indicates the directory where the build will take
3011 place. Source Steps are special in that they perform some operations
3012 outside of the workdir (like creating the workdir itself).
3014 @item alwaysUseLatest
3015 if True, bypass the usual ``update to the last Change'' behavior, and
3016 always update to the latest changes instead.
3018 @item retry
3019 If set, this specifies a tuple of @code{(delay, repeats)} which means
3020 that when a full VC checkout fails, it should be retried up to
3021 @var{repeats} times, waiting @var{delay} seconds between attempts. If
3022 you don't provide this, it defaults to @code{None}, which means VC
3023 operations should not be retried. This is provided to make life easier
3024 for buildslaves which are stuck behind poor network connections.
3026 @end table
3029 My habit as a developer is to do a @code{cvs update} and @code{make} each
3030 morning. Problems can occur, either because of bad code being checked in, or
3031 by incomplete dependencies causing a partial rebuild to fail where a
3032 complete from-scratch build might succeed. A quick Builder which emulates
3033 this incremental-build behavior would use the @code{mode='update'}
3034 setting.
3036 On the other hand, other kinds of dependency problems can cause a clean
3037 build to fail where a partial build might succeed. This frequently results
3038 from a link step that depends upon an object file that was removed from a
3039 later version of the tree: in the partial tree, the object file is still
3040 around (even though the Makefiles no longer know how to create it).
3042 ``official'' builds (traceable builds performed from a known set of
3043 source revisions) are always done as clean builds, to make sure it is
3044 not influenced by any uncontrolled factors (like leftover files from a
3045 previous build). A ``full'' Builder which behaves this way would want
3046 to use the @code{mode='clobber'} setting.
3048 Each VC system has a corresponding source checkout class: their
3049 arguments are described on the following pages.
3052 @menu
3053 * CVS::                         
3054 * SVN::                         
3055 * Darcs::                       
3056 * Mercurial::                   
3057 * Arch::                        
3058 * Bazaar::                      
3059 * P4::                          
3060 @end menu
3062 @node CVS, SVN, Source Checkout, Source Checkout
3063 @subsubsection CVS
3065 @cindex CVS Checkout
3066 @bsindex buildbot.steps.source.CVS
3069 The @code{CVS} build step performs a @uref{http://www.nongnu.org/cvs/,
3070 CVS} checkout or update. It takes the following arguments:
3072 @table @code
3073 @item cvsroot
3074 (required): specify the CVSROOT value, which points to a CVS
3075 repository, probably on a remote machine. For example, the cvsroot
3076 value you would use to get a copy of the Buildbot source code is
3077 @code{:pserver:anonymous@@cvs.sourceforge.net:/cvsroot/buildbot}
3079 @item cvsmodule
3080 (required): specify the cvs @code{module}, which is generally a
3081 subdirectory of the CVSROOT. The cvsmodule for the Buildbot source
3082 code is @code{buildbot}.
3084 @item branch
3085 a string which will be used in a @code{-r} argument. This is most
3086 useful for specifying a branch to work on. Defaults to @code{HEAD}.
3088 @item global_options
3089 a list of flags to be put before the verb in the CVS command.
3091 @item checkoutDelay
3092 if set, the number of seconds to put between the timestamp of the last
3093 known Change and the value used for the @code{-D} option. Defaults to
3094 half of the parent Build's treeStableTimer.
3096 @end table
3099 @node SVN, Darcs, CVS, Source Checkout
3100 @subsubsection SVN
3102 @cindex SVN Checkout
3103 @bsindex buildbot.steps.source.SVN
3106 The @code{SVN} build step performs a
3107 @uref{http://subversion.tigris.org, Subversion} checkout or update.
3108 There are two basic ways of setting up the checkout step, depending
3109 upon whether you are using multiple branches or not.
3111 If all of your builds use the same branch, then you should create the
3112 @code{SVN} step with the @code{svnurl} argument:
3114 @table @code
3115 @item svnurl
3116 (required): this specifies the @code{URL} argument that will be given
3117 to the @code{svn checkout} command. It dictates both where the
3118 repository is located and which sub-tree should be extracted. In this
3119 respect, it is like a combination of the CVS @code{cvsroot} and
3120 @code{cvsmodule} arguments. For example, if you are using a remote
3121 Subversion repository which is accessible through HTTP at a URL of
3122 @code{http://svn.example.com/repos}, and you wanted to check out the
3123 @code{trunk/calc} sub-tree, you would use
3124 @code{svnurl="http://svn.example.com/repos/trunk/calc"} as an argument
3125 to your @code{SVN} step.
3126 @end table
3128 If, on the other hand, you are building from multiple branches, then
3129 you should create the @code{SVN} step with the @code{baseURL} and
3130 @code{defaultBranch} arguments instead:
3132 @table @code
3133 @item baseURL
3134 (required): this specifies the base repository URL, to which a branch
3135 name will be appended. It should probably end in a slash.
3137 @item defaultBranch
3138 this specifies the name of the branch to use when a Build does not
3139 provide one of its own. This will be appended to @code{baseURL} to
3140 create the string that will be passed to the @code{svn checkout}
3141 command.
3142 @end table
3144 If you are using branches, you must also make sure your
3145 @code{ChangeSource} will report the correct branch names.
3147 @heading branch example
3149 Let's suppose that the ``MyProject'' repository uses branches for the
3150 trunk, for various users' individual development efforts, and for
3151 several new features that will require some amount of work (involving
3152 multiple developers) before they are ready to merge onto the trunk.
3153 Such a repository might be organized as follows:
3155 @example
3156 svn://svn.example.org/MyProject/trunk
3157 svn://svn.example.org/MyProject/branches/User1/foo
3158 svn://svn.example.org/MyProject/branches/User1/bar
3159 svn://svn.example.org/MyProject/branches/User2/baz
3160 svn://svn.example.org/MyProject/features/newthing
3161 svn://svn.example.org/MyProject/features/otherthing
3162 @end example
3164 Further assume that we want the Buildbot to run tests against the
3165 trunk and against all the feature branches (i.e., do a
3166 checkout/compile/build of branch X when a file has been changed on
3167 branch X, when X is in the set [trunk, features/newthing,
3168 features/otherthing]). We do not want the Buildbot to automatically
3169 build any of the user branches, but it should be willing to build a
3170 user branch when explicitly requested (most likely by the user who
3171 owns that branch).
3173 There are three things that need to be set up to accomodate this
3174 system. The first is a ChangeSource that is capable of identifying the
3175 branch which owns any given file. This depends upon a user-supplied
3176 function, in an external program that runs in the SVN commit hook and
3177 connects to the buildmaster's @code{PBChangeSource} over a TCP
3178 connection. (you can use the ``@code{buildbot sendchange}'' utility
3179 for this purpose, but you will still need an external program to
3180 decide what value should be passed to the @code{--branch=} argument).
3181 For example, a change to a file with the SVN url of
3182 ``svn://svn.example.org/MyProject/features/newthing/src/foo.c'' should
3183 be broken down into a Change instance with
3184 @code{branch='features/newthing'} and @code{file='src/foo.c'}.
3186 The second piece is an @code{AnyBranchScheduler} which will pay
3187 attention to the desired branches. It will not pay attention to the
3188 user branches, so it will not automatically start builds in response
3189 to changes there. The AnyBranchScheduler class requires you to
3190 explicitly list all the branches you want it to use, but it would not
3191 be difficult to write a subclass which used
3192 @code{branch.startswith('features/'} to remove the need for this
3193 explicit list. Or, if you want to build user branches too, you can use
3194 AnyBranchScheduler with @code{branches=None} to indicate that you want
3195 it to pay attention to all branches.
3197 The third piece is an @code{SVN} checkout step that is configured to
3198 handle the branches correctly, with a @code{baseURL} value that
3199 matches the way the ChangeSource splits each file's URL into base,
3200 branch, and file.
3202 @example
3203 from buildbot.changes.pb import PBChangeSource
3204 from buildbot.scheduler import AnyBranchScheduler
3205 from buildbot.process import source, factory
3206 from buildbot.steps import source, shell
3208 c['sources'] = [PBChangeSource()]
3209 s1 = AnyBranchScheduler('main',
3210                         ['trunk', 'features/newthing', 'features/otherthing'],
3211                         10*60, ['test-i386', 'test-ppc'])
3212 c['schedulers'] = [s1]
3214 f = factory.BuildFactory()
3215 f.addStep(source.SVN, mode='update',
3216           baseURL='svn://svn.example.org/MyProject/',
3217           defaultBranch='trunk')
3218 f.addStep(shell.Compile, command="make all")
3219 f.addStep(shell.Test, command="make test")
3221 c['builders'] = [
3222   @{'name':'test-i386', 'slavename':'bot-i386', 'builddir':'test-i386',
3223                        'factory':f @},
3224   @{'name':'test-ppc', 'slavename':'bot-ppc', 'builddir':'test-ppc',
3225                       'factory':f @},
3227 @end example
3229 In this example, when a change arrives with a @code{branch} attribute
3230 of ``trunk'', the resulting build will have an SVN step that
3231 concatenates ``svn://svn.example.org/MyProject/'' (the baseURL) with
3232 ``trunk'' (the branch name) to get the correct svn command. If the
3233 ``newthing'' branch has a change to ``src/foo.c'', then the SVN step
3234 will concatenate ``svn://svn.example.org/MyProject/'' with
3235 ``features/newthing'' to get the svnurl for checkout.
3237 @node Darcs, Mercurial, SVN, Source Checkout
3238 @subsubsection Darcs
3240 @cindex Darcs Checkout
3241 @bsindex buildbot.steps.source.Darcs
3244 The @code{Darcs} build step performs a
3245 @uref{http://abridgegame.org/darcs/, Darcs} checkout or update.
3247 Like @xref{SVN}, this step can either be configured to always check
3248 out a specific tree, or set up to pull from a particular branch that
3249 gets specified separately for each build. Also like SVN, the
3250 repository URL given to Darcs is created by concatenating a
3251 @code{baseURL} with the branch name, and if no particular branch is
3252 requested, it uses a @code{defaultBranch}. The only difference in
3253 usage is that each potential Darcs repository URL must point to a
3254 fully-fledged repository, whereas SVN URLs usually point to sub-trees
3255 of the main Subversion repository. In other words, doing an SVN
3256 checkout of @code{baseURL} is legal, but silly, since you'd probably
3257 wind up with a copy of every single branch in the whole repository.
3258 Doing a Darcs checkout of @code{baseURL} is just plain wrong, since
3259 the parent directory of a collection of Darcs repositories is not
3260 itself a valid repository.
3262 The Darcs step takes the following arguments:
3264 @table @code
3265 @item repourl
3266 (required unless @code{baseURL} is provided): the URL at which the
3267 Darcs source repository is available.
3269 @item baseURL
3270 (required unless @code{repourl} is provided): the base repository URL,
3271 to which a branch name will be appended. It should probably end in a
3272 slash.
3274 @item defaultBranch
3275 (allowed if and only if @code{baseURL} is provided): this specifies
3276 the name of the branch to use when a Build does not provide one of its
3277 own. This will be appended to @code{baseURL} to create the string that
3278 will be passed to the @code{darcs get} command.
3279 @end table
3281 @node Mercurial, Arch, Darcs, Source Checkout
3282 @subsubsection Mercurial
3284 @cindex Mercurial Checkout
3285 @bsindex buildbot.steps.source.Mercurial
3288 The @code{Mercurial} build step performs a
3289 @uref{http://selenic.com/mercurial, Mercurial} (aka ``hg'') checkout
3290 or update.
3292 Branches are handled just like @xref{Darcs}.
3294 The Mercurial step takes the following arguments:
3296 @table @code
3297 @item repourl
3298 (required unless @code{baseURL} is provided): the URL at which the
3299 Mercurial source repository is available.
3301 @item baseURL
3302 (required unless @code{repourl} is provided): the base repository URL,
3303 to which a branch name will be appended. It should probably end in a
3304 slash.
3306 @item defaultBranch
3307 (allowed if and only if @code{baseURL} is provided): this specifies
3308 the name of the branch to use when a Build does not provide one of its
3309 own. This will be appended to @code{baseURL} to create the string that
3310 will be passed to the @code{hg clone} command.
3311 @end table
3314 @node Arch, Bazaar, Mercurial, Source Checkout
3315 @subsubsection Arch
3317 @cindex Arch Checkout
3318 @bsindex buildbot.steps.source.Arch
3321 The @code{Arch} build step performs an @uref{http://gnuarch.org/,
3322 Arch} checkout or update using the @code{tla} client. It takes the
3323 following arguments:
3325 @table @code
3326 @item url
3327 (required): this specifies the URL at which the Arch source archive is
3328 available.
3330 @item version
3331 (required): this specifies which ``development line'' (like a branch)
3332 should be used. This provides the default branch name, but individual
3333 builds may specify a different one.
3335 @item archive
3336 (optional): Each repository knows its own archive name. If this
3337 parameter is provided, it must match the repository's archive name.
3338 The parameter is accepted for compatibility with the @code{Bazaar}
3339 step, below.
3341 @end table
3343 @node Bazaar, P4, Arch, Source Checkout
3344 @subsubsection Bazaar
3346 @cindex Bazaar Checkout
3347 @bsindex buildbot.steps.source.Bazaar
3350 @code{Bazaar} is an alternate implementation of the Arch VC system,
3351 which uses a client named @code{baz}. The checkout semantics are just
3352 different enough from @code{tla} that there is a separate BuildStep for
3355 It takes exactly the same arguments as @code{Arch}, except that the
3356 @code{archive=} parameter is required. (baz does not emit the archive
3357 name when you do @code{baz register-archive}, so we must provide it
3358 ourselves).
3361 @node P4,  , Bazaar, Source Checkout
3362 @subsubsection P4
3364 @cindex Perforce Update
3365 @bsindex buildbot.steps.source.P4
3366 @c TODO @bsindex buildbot.steps.source.P4Sync
3369 The @code{P4} build step creates a @uref{http://www.perforce.com/,
3370 Perforce} client specification and performs an update.
3372 @table @code
3373 @item p4base
3374 A view into the Perforce depot without branch name or trailing "...".
3375 Typically "//depot/proj/".
3376 @item defaultBranch
3377 A branch name to append on build requests if none is specified.
3378 Typically "trunk".
3379 @item p4port
3380 (optional): the host:port string describing how to get to the P4 Depot
3381 (repository), used as the -p argument for all p4 commands.
3382 @item p4user
3383 (optional): the Perforce user, used as the -u argument to all p4
3384 commands.
3385 @item p4passwd
3386 (optional): the Perforce password, used as the -p argument to all p4
3387 commands.
3388 @item p4extra_views
3389 (optional): a list of (depotpath, clientpath) tuples containing extra
3390 views to be mapped into the client specification. Both will have
3391 "/..." appended automatically. The client name and source directory
3392 will be prepended to the client path.
3393 @item p4client
3394 (optional): The name of the client to use. In mode='copy' and
3395 mode='update', it's particularly important that a unique name is used
3396 for each checkout directory to avoid incorrect synchronization. For
3397 this reason, Python percent substitution will be performed on this value
3398 to replace %(slave)s with the slave name and %(builder)s with the
3399 builder name. The default is "buildbot_%(slave)s_%(build)s".
3400 @end table
3402 @node ShellCommand, Simple ShellCommand Subclasses, Source Checkout, Build Steps
3403 @subsection ShellCommand
3405 @bsindex buildbot.steps.shell.ShellCommand
3406 @c TODO @bsindex buildbot.steps.shell.TreeSize
3408 This is a useful base class for just about everything you might want
3409 to do during a build (except for the initial source checkout). It runs
3410 a single command in a child shell on the buildslave. All stdout/stderr
3411 is recorded into a LogFile. The step finishes with a status of FAILURE
3412 if the command's exit code is non-zero, otherwise it has a status of
3413 SUCCESS.
3415 The preferred way to specify the command is with a list of argv strings,
3416 since this allows for spaces in filenames and avoids doing any fragile
3417 shell-escaping. You can also specify the command with a single string, in
3418 which case the string is given to '/bin/sh -c COMMAND' for parsing.
3420 All ShellCommands are run by default in the ``workdir'', which
3421 defaults to the ``@file{build}'' subdirectory of the slave builder's
3422 base directory. The absolute path of the workdir will thus be the
3423 slave's basedir (set as an option to @code{buildbot create-slave},
3424 @pxref{Creating a buildslave}) plus the builder's basedir (set in the
3425 builder's @code{c['builddir']} key in master.cfg) plus the workdir
3426 itself (a class-level attribute of the BuildFactory, defaults to
3427 ``@file{build}'').
3429 @code{ShellCommand} arguments:
3431 @table @code
3432 @item command
3433 a list of strings (preferred) or single string (discouraged) which
3434 specifies the command to be run. A list of strings is preferred
3435 because it can be used directly as an argv array. Using a single
3436 string (with embedded spaces) requires the buildslave to pass the
3437 string to /bin/sh for interpretation, which raises all sorts of
3438 difficult questions about how to escape or interpret shell
3439 metacharacters.
3441 @item env
3442 a dictionary of environment strings which will be added to the child
3443 command's environment. For example, to run tests with a different i18n
3444 language setting, you might use
3446 @example
3447 f.addStep(ShellCommand, command=["make", "test"],
3448           env=@{'LANG': 'fr_FR'@})
3449 @end example
3451 These variable settings will override any existing ones in the
3452 buildslave's environment. The exception is PYTHONPATH, which is merged
3453 with (actually prepended to) any existing $PYTHONPATH setting. The
3454 value is treated as a list of directories to prepend, and a single
3455 string is treated like a one-item list. For example, to prepend both
3456 @file{/usr/local/lib/python2.3} and @file{/home/buildbot/lib/python}
3457 to any existing $PYTHONPATH setting, you would do something like the
3458 following:
3460 @example
3461 f.addStep(ShellCommand, command=["make", "test"],
3462           env=@{'PYTHONPATH': ["/usr/local/lib/python2.3",
3463                               "/home/buildbot/lib/python"] @})
3464 @end example
3466 @item want_stdout
3467 if False, stdout from the child process is discarded rather than being
3468 sent to the buildmaster for inclusion in the step's LogFile.
3470 @item want_stderr
3471 like @code{want_stdout} but for stderr. Note that commands run through
3472 a PTY do not have separate stdout/stderr streams: both are merged into
3473 stdout.
3475 @item logfiles
3476 Sometimes commands will log interesting data to a local file, rather
3477 than emitting everything to stdout or stderr. For example, Twisted's
3478 ``trial'' command (which runs unit tests) only presents summary
3479 information to stdout, and puts the rest into a file named
3480 @file{_trial_temp/test.log}. It is often useful to watch these files
3481 as the command runs, rather than using @command{/bin/cat} to dump
3482 their contents afterwards.
3484 The @code{logfiles=} argument allows you to collect data from these
3485 secondary logfiles in near-real-time, as the step is running. It
3486 accepts a dictionary which maps from a local Log name (which is how
3487 the log data is presented in the build results) to a remote filename
3488 (interpreted relative to the build's working directory). Each named
3489 file will be polled on a regular basis (every couple of seconds) as
3490 the build runs, and any new text will be sent over to the buildmaster.
3492 @example
3493 f.addStep(ShellCommand, command=["make", "test"],
3494           logfiles=@{"triallog": "_trial_temp/test.log"@})
3495 @end example
3498 @item timeout
3499 if the command fails to produce any output for this many seconds, it
3500 is assumed to be locked up and will be killed.
3502 @item description
3503 This will be used to describe the command (on the Waterfall display)
3504 while the command is still running. It should be a single
3505 imperfect-tense verb, like ``compiling'' or ``testing''. The preferred
3506 form is a list of short strings, which allows the HTML Waterfall
3507 display to create narrower columns by emitting a <br> tag between each
3508 word. You may also provide a single string.
3510 @item descriptionDone
3511 This will be used to describe the command once it has finished. A
3512 simple noun like ``compile'' or ``tests'' should be used. Like
3513 @code{description}, this may either be a list of short strings or a
3514 single string.
3516 If neither @code{description} nor @code{descriptionDone} are set, the
3517 actual command arguments will be used to construct the description.
3518 This may be a bit too wide to fit comfortably on the Waterfall
3519 display.
3521 @example
3522 f.addStep(ShellCommand, command=["make", "test"],
3523           description=["testing"],
3524           descriptionDone=["tests"])
3525 @end example
3527 @end table
3529 @node Simple ShellCommand Subclasses, Python BuildSteps, ShellCommand, Build Steps
3530 @subsection Simple ShellCommand Subclasses
3532 Several subclasses of ShellCommand are provided as starting points for
3533 common build steps. These are all very simple: they just override a few
3534 parameters so you don't have to specify them yourself, making the master.cfg
3535 file less verbose.
3537 @menu
3538 * Configure::                   
3539 * Compile::                     
3540 * Test::                        
3541 * Build Properties::            
3542 @end menu
3544 @node Configure, Compile, Simple ShellCommand Subclasses, Simple ShellCommand Subclasses
3545 @subsubsection Configure
3547 @bsindex buildbot.steps.shell.Configure
3549 This is intended to handle the @code{./configure} step from
3550 autoconf-style projects, or the @code{perl Makefile.PL} step from perl
3551 MakeMaker.pm-style modules. The default command is @code{./configure}
3552 but you can change this by providing a @code{command=} parameter.
3554 @node Compile, Test, Configure, Simple ShellCommand Subclasses
3555 @subsubsection Compile
3557 @bsindex buildbot.steps.shell.Compile
3559 This is meant to handle compiling or building a project written in C. The
3560 default command is @code{make all}. When the compile is finished, the
3561 log file is scanned for GCC error/warning messages and a summary log is
3562 created with any problems that were seen (TODO: the summary is not yet
3563 created).
3565 @node Test, Build Properties, Compile, Simple ShellCommand Subclasses
3566 @subsubsection Test
3568 @bsindex buildbot.steps.shell.Test
3570 This is meant to handle unit tests. The default command is @code{make
3571 test}, and the @code{warnOnFailure} flag is set.
3575 @node Build Properties,  , Test, Simple ShellCommand Subclasses
3576 @subsubsection Build Properties
3578 @cindex build properties
3580 Each build has a set of ``Build Properties'', which can be used by its
3581 BuildStep to modify their actions. For example, the SVN revision
3582 number of the source code being built is available as a build
3583 property, and a ShellCommand step could incorporate this number into a
3584 command which create a numbered release tarball.
3586 Some build properties are set when the build starts, such as the
3587 SourceStamp information. Other properties can be set by BuildSteps as
3588 they run, for example the various Source steps will set the
3589 @code{got_revision} property to the source revision that was actually
3590 checked out (which can be useful when the SourceStamp in use merely
3591 requested the ``latest revision'': @code{got_revision} will tell you
3592 what was actually built).
3594 In custom BuildSteps, you can get and set the build properties with
3595 the @code{getProperty}/@code{setProperty} methods. Each takes a string
3596 for the name of the property, and returns or accepts an
3597 arbitrary@footnote{Build properties are serialized along with the
3598 build results, so they must be serializable. For this reason, the
3599 value of any build property should be simple inert data: strings,
3600 numbers, lists, tuples, and dictionaries. They should not contain
3601 class instances.} object. For example:
3603 @example
3604 class MakeTarball(ShellCommand):
3605     def start(self):
3606         self.setCommand(["tar", "czf",
3607                          "build-%s.tar.gz" % self.getProperty("revision"),
3608                          "source"])
3609         ShellCommand.start(self)
3610 @end example
3612 @cindex WithProperties
3614 You can use build properties in ShellCommands by using the
3615 @code{WithProperties} wrapper when setting the arguments of the
3616 ShellCommand. This interpolates the named build properties into the
3617 generated shell command.
3619 @example
3620 from buildbot.steps.shell import ShellCommand, WithProperties
3622 f.addStep(ShellCommand,
3623           command=["tar", "czf",
3624                    WithProperties("build-%s.tar.gz", "revision"),
3625                    "source"])
3626 @end example
3628 If this BuildStep were used in a tree obtained from Subversion, it
3629 would create a tarball with a name like @file{build-1234.tar.gz}.
3631 The @code{WithProperties} function does @code{printf}-style string
3632 interpolation, using strings obtained by calling
3633 @code{build.getProperty(propname)}. Note that for every @code{%s} (or
3634 @code{%d}, etc), you must have exactly one additional argument to
3635 indicate which build property you want to insert.
3638 You can also use python dictionary-style string interpolation by using
3639 the @code{%(propname)s} syntax. In this form, the property name goes
3640 in the parentheses, and WithProperties takes @emph{no} additional
3641 arguments:
3643 @example
3644 f.addStep(ShellCommand,
3645           command=["tar", "czf",
3646                    WithProperties("build-%(revision)s.tar.gz"),
3647                    "source"])
3648 @end example
3650 Don't forget the extra ``s'' after the closing parenthesis! This is
3651 the cause of many confusing errors.
3653 Note that, like python, you can either do positional-argument
3654 interpolation @emph{or} keyword-argument interpolation, not both. Thus
3655 you cannot use a string like
3656 @code{WithProperties("foo-%(revision)s-%s", "branch")}.
3658 At the moment, the only way to set build properties is by writing a
3659 custom BuildStep.
3661 @heading Common Build Properties
3663 The following build properties are set when the build is started, and
3664 are available to all steps.
3666 @table @code
3667 @item branch
3669 This comes from the build's SourceStamp, and describes which branch is
3670 being checked out. This will be @code{None} (which interpolates into
3671 @code{WithProperties} as an empty string) if the build is on the
3672 default branch, which is generally the trunk. Otherwise it will be a
3673 string like ``branches/beta1.4''. The exact syntax depends upon the VC
3674 system being used.
3676 @item revision
3678 This also comes from the SourceStamp, and is the revision of the
3679 source code tree that was requested from the VC system. When a build
3680 is requested of a specific revision (as is generally the case when the
3681 build is triggered by Changes), this will contain the revision
3682 specification. The syntax depends upon the VC system in use: for SVN
3683 it is an integer, for Mercurial it is a short string, for Darcs it is
3684 a rather large string, etc.
3686 If the ``force build'' button was pressed, the revision will be
3687 @code{None}, which means to use the most recent revision available.
3688 This is a ``trunk build''. This will be interpolated as an empty
3689 string.
3691 @item got_revision
3693 This is set when a Source step checks out the source tree, and
3694 provides the revision that was actually obtained from the VC system.
3695 In general this should be the same as @code{revision}, except for
3696 trunk builds, where @code{got_revision} indicates what revision was
3697 current when the checkout was performed. This can be used to rebuild
3698 the same source code later.
3700 Note that for some VC systems (Darcs in particular), the revision is a
3701 large string containing newlines, and is not suitable for
3702 interpolation into a filename.
3704 @item buildername
3706 This is a string that indicates which Builder the build was a part of.
3707 The combination of buildername and buildnumber uniquely identify a
3708 build.
3710 @item buildnumber
3712 Each build gets a number, scoped to the Builder (so the first build
3713 performed on any given Builder will have a build number of 0). This
3714 integer property contains the build's number.
3716 @item slavename
3718 This is a string which identifies which buildslave the build is
3719 running on.
3721 @end table
3723 @node Python BuildSteps, Transferring Files, Simple ShellCommand Subclasses, Build Steps
3724 @subsection Python BuildSteps
3726 Here are some BuildSteps that are specifcally useful for projects
3727 implemented in Python.
3729 @menu
3730 * BuildEPYDoc::                 
3731 * PyFlakes::                    
3732 @end menu
3734 @node BuildEPYDoc, PyFlakes, Python BuildSteps, Python BuildSteps
3735 @subsubsection BuildEPYDoc
3737 @bsindex buildbot.steps.python.BuildEPYDoc
3739 @url{http://epydoc.sourceforge.net/, epydoc} is a tool for generating
3740 API documentation for Python modules from their docstrings. It reads
3741 all the .py files from your source tree, processes the docstrings
3742 therein, and creates a large tree of .html files (or a single .pdf
3743 file).
3745 The @code{buildbot.steps.python.BuildEPYDoc} step will run
3746 @command{epydoc} to produce this API documentation, and will count the
3747 errors and warnings from its output.
3749 You must supply the command line to be used. The default is
3750 @command{make epydocs}, which assumes that your project has a Makefile
3751 with an ``epydocs'' target. You might wish to use something like
3752 @command{epydoc -o apiref source/PKGNAME} instead. You might also want
3753 to add @command{--pdf} to generate a PDF file instead of a large tree
3754 of HTML files.
3756 The API docs are generated in-place in the build tree (under the
3757 workdir, in the subdirectory controlled by the ``-o'' argument). To
3758 make them useful, you will probably have to copy them to somewhere
3759 they can be read. A command like @command{rsync -ad apiref/
3760 dev.example.com:~public_html/current-apiref/} might be useful. You
3761 might instead want to bundle them into a tarball and publish it in the
3762 same place where the generated install tarball is placed.
3764 @example
3765 from buildbot.steps.python import BuildEPYDoc
3768 f.addStep(BuildEPYDoc, command=["epydoc", "-o", "apiref", "source/mypkg"])
3769 @end example
3772 @node PyFlakes,  , BuildEPYDoc, Python BuildSteps
3773 @subsubsection PyFlakes
3775 @bsindex buildbot.steps.python.PyFlakes
3777 @url{http://divmod.org/trac/wiki/DivmodPyflakes, PyFlakes} is a tool
3778 to perform basic static analysis of Python code to look for simple
3779 errors, like missing imports and references of undefined names. It is
3780 like a fast and simple form of the C ``lint'' program. Other tools
3781 (like pychecker) provide more detailed results but take longer to run.
3783 The @code{buildbot.steps.python.PyFlakes} step will run pyflakes and
3784 count the various kinds of errors and warnings it detects.
3786 You must supply the command line to be used. The default is
3787 @command{make pyflakes}, which assumes you have a top-level Makefile
3788 with a ``pyflakes'' target. You might want to use something like
3789 @command{pyflakes .} or @command{pyflakes src}.
3791 @example
3792 from buildbot.steps.python import PyFlakes
3795 f.addStep(PyFlakes, command=["pyflakes", "src"])
3796 @end example
3799 @node Transferring Files, Writing New BuildSteps, Python BuildSteps, Build Steps
3800 @subsection Transferring Files
3802 @cindex File Transfer
3803 @bsindex buildbot.steps.transfer.FileUpload
3804 @bsindex buildbot.steps.transfer.FileDownload
3806 Most of the work involved in a build will take place on the
3807 buildslave. But occasionally it is useful to do some work on the
3808 buildmaster side. The most basic way to involve the buildmaster is
3809 simply to move a file from the slave to the master, or vice versa.
3810 There are a pair of BuildSteps named @code{FileUpload} and
3811 @code{FileDownload} to provide this functionality. @code{FileUpload}
3812 moves a file @emph{up to} the master, while @code{FileDownload} moves
3813 a file @emph{down from} the master.
3815 As an example, let's assume that there is a step which produces an
3816 HTML file within the source tree that contains some sort of generated
3817 project documentation. We want to move this file to the buildmaster,
3818 into a @file{~/public_html} directory, so it can be visible to
3819 developers. This file will wind up in the slave-side working directory
3820 under the name @file{docs/reference.html}. We want to put it into the
3821 master-side @file{~/public_html/ref.html}.
3823 @example
3824 from buildbot.steps.shell import ShellCommand
3825 from buildbot.steps.transfer import FileUpload
3827 f.addStep(ShellCommand, command=["make", "docs"])
3828 f.addStep(FileUpload,
3829           slavesrc="docs/reference.html",
3830           masterdest="~/public_html/ref.html")
3831 @end example
3833 The @code{masterdest=} argument will be passed to os.path.expanduser,
3834 so things like ``~'' will be expanded properly. Non-absolute paths
3835 will be interpreted relative to the buildmaster's base directory.
3836 Likewise, the @code{slavesrc=} argument will be expanded and
3837 interpreted relative to the builder's working directory.
3840 To move a file from the master to the slave, use the
3841 @code{FileDownload} command. For example, let's assume that some step
3842 requires a configuration file that, for whatever reason, could not be
3843 recorded in the source code repository or generated on the buildslave
3844 side:
3846 @example
3847 from buildbot.steps.shell import ShellCommand
3848 from buildbot.steps.transfer import FileUpload
3850 f.addStep(FileDownload
3851           mastersrc="~/todays_build_config.txt",
3852           slavedest="build_config.txt")
3853 f.addStep(ShellCommand, command=["make", "config"])
3854 @end example
3856 @c TODO: document other parameters
3859 @node Writing New BuildSteps,  , Transferring Files, Build Steps
3860 @subsection Writing New BuildSteps
3862 While it is a good idea to keep your build process self-contained in
3863 the source code tree, sometimes it is convenient to put more
3864 intelligence into your Buildbot configuration. One was to do this is
3865 to write a custom BuildStep. Once written, this Step can be used in
3866 the @file{master.cfg} file.
3868 The best reason for writing a custom BuildStep is to better parse the
3869 results of the command being run. For example, a BuildStep that knows
3870 about JUnit could look at the logfiles to determine which tests had
3871 been run, how many passed and how many failed, and then report more
3872 detailed information than a simple @code{rc==0} -based ``good/bad''
3873 decision.
3875 TODO: add more description of BuildSteps.
3877 @menu
3878 * BuildStep LogFiles::          
3879 * Adding LogObservers::         
3880 * BuildStep URLs::              
3881 @end menu
3883 @node BuildStep LogFiles, Adding LogObservers, Writing New BuildSteps, Writing New BuildSteps
3884 @subsubsection BuildStep LogFiles
3886 Each BuildStep has a collection of ``logfiles''. Each one has a short
3887 name, like ``stdio'' or ``warnings''. Each LogFile contains an
3888 arbitrary amount of text, usually the contents of some output file
3889 generated during a build or test step, or a record of everything that
3890 was printed to stdout/stderr during the execution of some command.
3892 These LogFiles are stored to disk, so they can be retrieved later.
3894 Each can contain multiple ``channels'', generally limited to three
3895 basic ones: stdout, stderr, and ``headers''. For example, when a
3896 ShellCommand runs, it writes a few lines to the ``headers'' channel to
3897 indicate the exact argv strings being run, which directory the command
3898 is being executed in, and the contents of the current environment
3899 variables. Then, as the command runs, it adds a lot of ``stdout'' and
3900 ``stderr'' messages. When the command finishes, a final ``header''
3901 line is added with the exit code of the process.
3903 Status display plugins can format these different channels in
3904 different ways. For example, the web page shows LogFiles as text/html,
3905 with header lines in blue text, stdout in black, and stderr in red. A
3906 different URL is available which provides a text/plain format, in
3907 which stdout and stderr are collapsed together, and header lines are
3908 stripped completely. This latter option makes it easy to save the
3909 results to a file and run @command{grep} or whatever against the
3910 output.
3912 Each BuildStep contains a mapping (implemented in a python dictionary)
3913 from LogFile name to the actual LogFile objects. Status plugins can
3914 get a list of LogFiles to display, for example, a list of HREF links
3915 that, when clicked, provide the full contents of the LogFile.
3917 @heading Using LogFiles in custom BuildSteps
3919 The most common way for a custom BuildStep to use a LogFile is to
3920 summarize the results of a ShellCommand (after the command has
3921 finished running). For example, a compile step with thousands of lines
3922 of output might want to create a summary of just the warning messages.
3923 If you were doing this from a shell, you would use something like:
3925 @example
3926 grep "warning:" output.log >warnings.log
3927 @end example
3929 In a custom BuildStep, you could instead create a ``warnings'' LogFile
3930 that contained the same text. To do this, you would add code to your
3931 @code{createSummary} method that pulls lines from the main output log
3932 and creates a new LogFile with the results:
3934 @example
3935     def createSummary(self, log):
3936         warnings = []
3937         for line in log.readlines():
3938             if "warning:" in line:
3939                 warnings.append()
3940         self.addCompleteLog('warnings', "".join(warnings))
3941 @end example
3943 This example uses the @code{addCompleteLog} method, which creates a
3944 new LogFile, puts some text in it, and then ``closes'' it, meaning
3945 that no further contents will be added. This LogFile will appear in
3946 the HTML display under an HREF with the name ``warnings'', since that
3947 is the name of the LogFile.
3949 You can also use @code{addHTMLLog} to create a complete (closed)
3950 LogFile that contains HTML instead of plain text. The normal LogFile
3951 will be HTML-escaped if presented through a web page, but the HTML
3952 LogFile will not. At the moment this is only used to present a pretty
3953 HTML representation of an otherwise ugly exception traceback when
3954 something goes badly wrong during the BuildStep.
3956 In contrast, you might want to create a new LogFile at the beginning
3957 of the step, and add text to it as the command runs. You can create
3958 the LogFile and attach it to the build by calling @code{addLog}, which
3959 returns the LogFile object. You then add text to this LogFile by
3960 calling methods like @code{addStdout} and @code{addHeader}. When you
3961 are done, you must call the @code{finish} method so the LogFile can be
3962 closed. It may be useful to create and populate a LogFile like this
3963 from a LogObserver method @xref{Adding LogObservers}.
3965 The @code{logfiles=} argument to @code{ShellCommand} (see
3966 @pxref{ShellCommand}) creates new LogFiles and fills them in realtime
3967 by asking the buildslave to watch a actual file on disk. The
3968 buildslave will look for additions in the target file and report them
3969 back to the BuildStep. These additions will be added to the LogFile by
3970 calling @code{addStdout}. These secondary LogFiles can be used as the
3971 source of a LogObserver just like the normal ``stdio'' LogFile.
3974 @node Adding LogObservers, BuildStep URLs, BuildStep LogFiles, Writing New BuildSteps
3975 @subsubsection Adding LogObservers
3977 @cindex LogObserver
3978 @cindex LogLineObserver
3980 Most shell commands emit messages to stdout or stderr as they operate,
3981 especially if you ask them nicely with a @code{--verbose} flag of some
3982 sort. They may also write text to a log file while they run. Your
3983 BuildStep can watch this output as it arrives, to keep track of how
3984 much progress the command has made. You can get a better measure of
3985 progress by counting the number of source files compiled or test cases
3986 run than by merely tracking the number of bytes that have been written
3987 to stdout. This improves the accuracy and the smoothness of the ETA
3988 display.
3990 To accomplish this, you will need to attach a @code{LogObserver} to
3991 one of the log channels, most commonly to the ``stdio'' channel but
3992 perhaps to another one which tracks a log file. This observer is given
3993 all text as it is emitted from the command, and has the opportunity to
3994 parse that output incrementally. Once the observer has decided that
3995 some event has occurred (like a source file being compiled), it can
3996 use the @code{setProgress} method to tell the BuildStep about the
3997 progress that this event represents.
3999 There are a number of pre-built @code{LogObserver} classes that you
4000 can choose from, and of course you can subclass them to add further
4001 customization. The @code{LogLineObserver} class handles the grunt work
4002 of buffering and scanning for end-of-line delimiters, allowing your
4003 parser to operate on complete stdout/stderr lines.
4005 For example, let's take a look at the @code{TrialTestCaseCounter},
4006 which is used by the Trial step to count test cases as they are run.
4007 As Trial executes, it emits lines like the following:
4009 @example
4010 buildbot.test.test_config.ConfigTest.testDebugPassword ... [OK]
4011 buildbot.test.test_config.ConfigTest.testEmpty ... [OK]
4012 buildbot.test.test_config.ConfigTest.testIRC ... [FAIL]
4013 buildbot.test.test_config.ConfigTest.testLocks ... [OK]
4014 @end example
4016 When the tests are finished, trial emits a long line of ``======'' and
4017 then some lines which summarize the tests that failed. We want to
4018 avoid parsing these trailing lines, because their format is less
4019 well-defined than the ``[OK]'' lines.
4021 The parser class looks like this:
4023 @example
4024 class TrialTestCaseCounter(step.LogLineObserver):
4025     _line_re = re.compile(r'^([\w\.]+) \.\.\. \[([^\]]+)\]$')
4026     numTests = 0
4027     finished = False
4029     def outLineReceived(self, line):
4030         if self.finished:
4031             return
4032         if line.startswith("=" * 40):
4033             self.finished = True
4034             return
4036         m = self._line_re.search(line.strip())
4037         if m:
4038             testname, result = m.groups()
4039             self.numTests += 1
4040             self.step.setProgress('tests', self.numTests)
4041 @end example
4043 This parser only pays attention to stdout, since that's where trial
4044 writes the progress lines. It has a mode flag named @code{finished} to
4045 ignore everything after the ``===='' marker, and a scary-looking
4046 regular expression to match each line while hopefully ignoring other
4047 messages that might get displayed as the test runs.
4049 Each time it identifies a test has been completed, it increments its
4050 counter and delivers the new progress value to the step with
4051 @code{self.step.setProgress}. This class is specifically measuring
4052 progress along the ``tests'' metric, in units of test cases (as
4053 opposed to other kinds of progress like the ``output'' metric, which
4054 measures in units of bytes). The Progress-tracking code uses each
4055 progress metric separately to come up with an overall completion
4056 percentage and an ETA value.
4058 To connect this parser into the @code{Trial} BuildStep,
4059 @code{Trial.__init__} ends with the following clause:
4061 @example
4062         # this counter will feed Progress along the 'test cases' metric
4063         counter = TrialTestCaseCounter()
4064         self.addLogObserver('stdio', counter)
4065 @end example
4067 This creates a TrialTestCaseCounter and tells the step that the
4068 counter wants to watch the ``stdio'' log. The observer is
4069 automatically given a reference to the step in its @code{.step}
4070 attribute.
4072 @node BuildStep URLs,  , Adding LogObservers, Writing New BuildSteps
4073 @subsubsection BuildStep URLs
4075 @cindex links
4076 @cindex BuildStep URLs
4077 @cindex addURL
4079 Each BuildStep has a collection of ``links''. Like its collection of
4080 LogFiles, each link has a name and a target URL. The web status page
4081 creates HREFs for each link in the same box as it does for LogFiles,
4082 except that the target of the link is the external URL instead of an
4083 internal link to a page that shows the contents of the LogFile.
4085 These external links can be used to point at build information hosted
4086 on other servers. For example, the test process might produce an
4087 intricate description of which tests passed and failed, or some sort
4088 of code coverage data in HTML form, or a PNG or GIF image with a graph
4089 of memory usage over time. The external link can provide an easy way
4090 for users to navigate from the buildbot's status page to these
4091 external web sites or file servers. Note that the step itself is
4092 responsible for insuring that there will be a document available at
4093 the given URL (perhaps by using @command{scp} to copy the HTML output
4094 to a @file{~/public_html/} directory on a remote web server). Calling
4095 @code{addURL} does not magically populate a web server.
4097 To set one of these links, the BuildStep should call the @code{addURL}
4098 method with the name of the link and the target URL. Multiple URLs can
4099 be set.
4101 In this example, we assume that the @command{make test} command causes
4102 a collection of HTML files to be created and put somewhere on the
4103 coverage.example.org web server, in a filename that incorporates the
4104 build number.
4106 @example
4107 class TestWithCodeCoverage(BuildStep):
4108     command = ["make", "test",
4109                WithProperties("buildnum=%s" % "buildnumber")]
4111     def createSummary(self, log):
4112         buildnumber = self.getProperty("buildnumber")
4113         url = "http://coverage.example.org/builds/%s.html" % buildnumber
4114         self.addURL("coverage", url)
4115 @end example
4117 You might also want to extract the URL from some special message
4118 output by the build process itself:
4120 @example
4121 class TestWithCodeCoverage(BuildStep):
4122     command = ["make", "test",
4123                WithProperties("buildnum=%s" % "buildnumber")]
4125     def createSummary(self, log):
4126         output = StringIO(log.getText())
4127         for line in output.readlines():
4128             if line.startswith("coverage-url:"):
4129                 url = line[len("coverage-url:"):].strip()
4130                 self.addURL("coverage", url)
4131                 return
4132 @end example
4134 Note that a build process which emits both stdout and stderr might
4135 cause this line to be split or interleaved between other lines. It
4136 might be necessary to restrict the getText() call to only stdout with
4137 something like this:
4139 @example
4140         output = StringIO("".join([c[1]
4141                                    for c in log.getChunks()
4142                                    if c[0] == LOG_CHANNEL_STDOUT]))
4143 @end example
4145 Of course if the build is run under a PTY, then stdout and stderr will
4146 be merged before the buildbot ever sees them, so such interleaving
4147 will be unavoidable.
4150 @node Interlocks, Build Factories, Build Steps, Build Process
4151 @section Interlocks
4153 @cindex locks
4154 @slindex buildbot.locks.MasterLock
4155 @slindex buildbot.locks.SlaveLock
4157 For various reasons, you may want to prevent certain Steps (or perhaps
4158 entire Builds) from running simultaneously. Limited CPU speed or
4159 network bandwidth to the VC server, problems with simultaneous access
4160 to a database server used by unit tests, or multiple Builds which
4161 access shared state may all require some kind of interlock to prevent
4162 corruption, confusion, or resource overload. These resources might
4163 require completely exclusive access, or it might be sufficient to
4164 establish a limit of two or three simultaneous builds.
4166 @code{Locks} are the mechanism used to express these kinds of
4167 constraints on when Builds or Steps can be run. There are two kinds of
4168 @code{Locks}, each with their own scope: @code{MasterLock} instances
4169 are scoped to the buildbot as a whole, while @code{SlaveLock}s are
4170 scoped to a single buildslave. This means that each buildslave has a
4171 separate copy of each @code{SlaveLock}, which could enforce a
4172 one-Build-at-a-time limit for each machine, but still allow as many
4173 simultaneous builds as there are machines.
4175 Each @code{Lock} is created with a unique name. Each lock gets a count
4176 of how many owners it may have: how many processes can claim it at ths
4177 same time. This limit defaults to one, and is controllable through the
4178 @code{maxCount} argument. On @code{SlaveLock}s you can set the owner
4179 count on a per-slave basis by providing a dictionary (that maps from
4180 slavename to maximum owner count) to its @code{maxCountForSlave}
4181 argument. Any buildslaves that aren't mentioned in
4182 @code{maxCountForSlave} get their owner count from @code{maxCount}.
4184 To use a lock, simply include it in the @code{locks=} argument of the
4185 @code{BuildStep} object that should obtain the lock before it runs.
4186 This argument accepts a list of @code{Lock} objects: the Step will
4187 acquire all of them before it runs.
4189 To claim a lock for the whole Build, add a @code{'locks'} key to the
4190 builder specification dictionary with the same list of @code{Lock}
4191 objects. (This is the dictionary that has the @code{'name'},
4192 @code{'slavename'}, @code{'builddir'}, and @code{'factory'} keys). The
4193 @code{Build} object also accepts a @code{locks=} argument, but unless
4194 you are writing your own @code{BuildFactory} subclass then it will be
4195 easier to set the locks in the builder dictionary.
4197 Note that there are no partial-acquire or partial-release semantics:
4198 this prevents deadlocks caused by two Steps each waiting for a lock
4199 held by the other@footnote{Also note that a clever buildmaster admin
4200 could still create the opportunity for deadlock: Build A obtains Lock
4201 1, inside which Step A.two tries to acquire Lock 2 at the Step level.
4202 Meanwhile Build B obtains Lock 2, and has a Step B.two which wants to
4203 acquire Lock 1 at the Step level. Don't Do That.}. This also means
4204 that waiting to acquire a @code{Lock} can take an arbitrarily long
4205 time: if the buildmaster is very busy, a Step or Build which requires
4206 only one @code{Lock} may starve another that is waiting for that
4207 @code{Lock} plus some others.
4210 In the following example, we run the same build on three different
4211 platforms. The unit-test steps of these builds all use a common
4212 database server, and would interfere with each other if allowed to run
4213 simultaneously. The @code{Lock} prevents more than one of these builds
4214 from happening at the same time.
4216 @example
4217 from buildbot import locks
4218 from buildbot.steps import source, shell
4219 from buildbot.process import factory
4221 db_lock = locks.MasterLock("database")
4222 f = factory.BuildFactory()
4223 f.addStep(source.SVN, svnurl="http://example.org/svn/Trunk")
4224 f.addStep(shell.ShellCommand, command="make all")
4225 f.addStep(shell.ShellCommand, command="make test", locks=[db_lock])
4226 b1 = @{'name': 'full1', 'slavename': 'bot-1', builddir='f1', 'factory': f@}
4227 b2 = @{'name': 'full2', 'slavename': 'bot-2', builddir='f2', 'factory': f@}
4228 b3 = @{'name': 'full3', 'slavename': 'bot-3', builddir='f3', 'factory': f@}
4229 c['builders'] = [b1, b2, b3]
4230 @end example
4232 In the next example, we have one buildslave hosting three separate
4233 Builders (each running tests against a different version of Python).
4234 The machine which hosts this buildslave is not particularly fast, so
4235 we want to prevent all three builds from all happening at the same
4236 time. (Assume we've experimentally determined that one build leaves
4237 unused CPU capacity, three builds causes a lot of disk thrashing, but
4238 two builds at a time is Just Right). We use a @code{SlaveLock} because
4239 the builds happening on this one slow slave should not affect builds
4240 running on other slaves, and we use the lock on the build as a whole
4241 because the slave is so slow that even multiple simultaneous SVN
4242 checkouts would be too taxing. We set @code{maxCount=2} to achieve our
4243 goal of two simultaneous builds per slave.
4245 @example
4246 from buildbot import locks
4247 from buildbot.steps import source
4248 from buildbot.process import s, factory
4250 slow_lock = locks.SlaveLock("cpu", maxCount=2)
4251 source = s(source.SVN, svnurl="http://example.org/svn/Trunk")
4252 f22 = factory.Trial(source, trialpython=["python2.2"])
4253 f23 = factory.Trial(source, trialpython=["python2.3"])
4254 f24 = factory.Trial(source, trialpython=["python2.4"])
4255 b1 = @{'name': 'p22', 'slavename': 'bot-1', builddir='p22', 'factory': f22,
4256       'locks': [slow_lock] @}
4257 b2 = @{'name': 'p23', 'slavename': 'bot-1', builddir='p23', 'factory': f23,
4258       'locks': [slow_lock] @}
4259 b3 = @{'name': 'p24', 'slavename': 'bot-1', builddir='p24', 'factory': f24,
4260       'locks': [slow_lock] @}
4261 c['builders'] = [b1, b2, b3]
4262 @end example
4264 In the last example, we use two Locks at the same time. In this case,
4265 we're concerned about both of the previous constraints, but we'll say
4266 that only the tests are computationally intensive, and that they have
4267 been split into those which use the database and those which do not.
4268 In addition, two of the Builds run on a fast machine which does not
4269 need to worry about the cpu lock, but which still must be prevented
4270 from simultaneous database access. We use @code{maxCountForSlave} to
4271 limit the slow machine to one simultanous build, but allow practically
4272 unlimited concurrent builds on the fast machine.
4274 @example
4275 from buildbot import locks
4276 from buildbot.steps import source, shell
4277 from buildbot.process import factory
4279 db_lock = locks.MasterLock("database")
4280 slavecounts = @{"bot-slow": 1, "bot-fast": 100@}
4281 cpu_lock = locks.SlaveLock("cpu", maxCountForSlave=slavecounts)
4282 f = factory.BuildFactory()
4283 f.addStep(source.SVN, svnurl="http://example.org/svn/Trunk")
4284 f.addStep(shell.ShellCommand, command="make all", locks=[cpu_lock])
4285 f.addStep(shell.ShellCommand, command="make test", locks=[cpu_lock])
4286 f.addStep(shell.ShellCommand, command="make db-test",
4287                               locks=[db_lock, cpu_lock])
4289 b1 = @{'name': 'full1', 'slavename': 'bot-slow', builddir='full1',
4290       'factory': f@}
4291 b2 = @{'name': 'full2', 'slavename': 'bot-slow', builddir='full2',
4292       'factory': f@}
4293 b3 = @{'name': 'full3', 'slavename': 'bot-fast', builddir='full3',
4294       'factory': f@}
4295 b4 = @{'name': 'full4', 'slavename': 'bot-fast', builddir='full4',
4296       'factory': f@}
4297 c['builders'] = [b1, b2, b3, b4]
4298 @end example
4300 As a final note, remember that a unit test system which breaks when
4301 multiple people run it at the same time is fragile and should be
4302 fixed. Asking your human developers to serialize themselves when
4303 running unit tests will just discourage them from running the unit
4304 tests at all. Find a way to fix this: change the database tests to
4305 create a new (uniquely-named) user or table for each test run, don't
4306 use fixed listening TCP ports for network tests (instead listen on
4307 port 0 to let the kernel choose a port for you and then query the
4308 socket to find out what port was allocated). @code{MasterLock}s can be
4309 used to accomodate broken test systems like this, but are really
4310 intended for other purposes: build processes that store or retrieve
4311 products in shared directories, or which do things that human
4312 developers would not (or which might slow down or break in ways that
4313 require human attention to deal with).
4315 @code{SlaveLocks}s can be used to keep automated performance tests
4316 from interfering with each other, when there are multiple Builders all
4317 using the same buildslave. But they can't prevent other users from
4318 running CPU-intensive jobs on that host while the tests are running.
4320 @node Build Factories,  , Interlocks, Build Process
4321 @section Build Factories
4324 Each Builder is equipped with a ``build factory'', which is
4325 responsible for producing the actual @code{Build} objects that perform
4326 each build. This factory is created in the configuration file, and
4327 attached to a Builder through the @code{factory} element of its
4328 dictionary.
4330 The standard @code{BuildFactory} object creates @code{Build} objects
4331 by default. These Builds will each execute a collection of BuildSteps
4332 in a fixed sequence. Each step can affect the results of the build,
4333 but in general there is little intelligence to tie the different steps
4334 together. You can create subclasses of @code{Build} to implement more
4335 sophisticated build processes, and then use a subclass of
4336 @code{BuildFactory} (or simply set the @code{buildClass} attribute) to
4337 create instances of your new Build subclass.
4340 @menu
4341 * BuildStep Objects::           
4342 * BuildFactory::                
4343 * Process-Specific build factories::  
4344 @end menu
4346 @node BuildStep Objects, BuildFactory, Build Factories, Build Factories
4347 @subsection BuildStep Objects
4349 The steps used by these builds are all subclasses of @code{BuildStep}.
4350 The standard ones provided with Buildbot are documented later,
4351 @xref{Build Steps}. You can also write your own subclasses to use in
4352 builds.
4354 The basic behavior for a @code{BuildStep} is to:
4356 @itemize @bullet
4357 @item
4358 run for a while, then stop
4359 @item
4360 possibly invoke some RemoteCommands on the attached build slave
4361 @item
4362 possibly produce a set of log files
4363 @item
4364 finish with a status described by one of four values defined in
4365 buildbot.status.builder: SUCCESS, WARNINGS, FAILURE, SKIPPED
4366 @item
4367 provide a list of short strings to describe the step
4368 @item
4369 define a color (generally green, orange, or red) with which the
4370 step should be displayed
4371 @end itemize
4374 More sophisticated steps may produce additional information and
4375 provide it to later build steps, or store it in the factory to provide
4376 to later builds.
4379 @menu
4380 * BuildFactory Attributes::     
4381 * Quick builds::                
4382 @end menu
4384 @node BuildFactory, Process-Specific build factories, BuildStep Objects, Build Factories
4385 @subsection BuildFactory
4387 @bfindex buildbot.process.factory.BuildFactory
4388 @bfindex buildbot.process.factory.BasicBuildFactory
4389 @c TODO: what is BasicSVN anyway?
4390 @bfindex buildbot.process.factory.BasicSVN
4392 The default @code{BuildFactory}, provided in the
4393 @code{buildbot.process.factory} module, contains a list of ``BuildStep
4394 specifications'': a list of @code{(step_class, kwargs)} tuples for
4395 each. When asked to create a Build, it loads the list of steps into
4396 the new Build object. When the Build is actually started, these step
4397 specifications are used to create the actual set of BuildSteps, which
4398 are then executed one at a time. For example, a build which consists
4399 of a CVS checkout followed by a @code{make build} would be constructed
4400 as follows:
4402 @example
4403 from buildbot.steps import source, shell
4404 from buildbot.process import factory
4406 f = factory.BuildFactory()
4407 f.addStep(source.CVS, cvsroot=CVSROOT, cvsmodule="project", mode="update")
4408 f.addStep(shell.Compile, command=["make", "build"])
4409 @end example
4411 It is also possible to pass a list of step specifications into the
4412 @code{BuildFactory} when it is created. Using @code{addStep} is
4413 usually simpler, but there are cases where is is more convenient to
4414 create the list of steps ahead of time. To make this approach easier,
4415 a convenience function named @code{s} is available:
4417 @example
4418 from buildbot.steps import source, shell
4419 from buildbot.process import factory
4420 from buildbot.factory import s
4421 # s is a convenience function, defined with:
4422 # def s(steptype, **kwargs): return (steptype, kwargs)
4424 all_steps = [s(source.CVS, cvsroot=CVSROOT, cvsmodule="project",
4425                mode="update"),
4426              s(shell.Compile, command=["make", "build"]),
4427             ]
4428 f = factory.BuildFactory(all_steps)
4429 @end example
4432 Each step can affect the build process in the following ways:
4434 @itemize @bullet
4435 @item
4436 If the step's @code{haltOnFailure} attribute is True, then a failure
4437 in the step (i.e. if it completes with a result of FAILURE) will cause
4438 the whole build to be terminated immediately: no further steps will be
4439 executed. This is useful for setup steps upon which the rest of the
4440 build depends: if the CVS checkout or @code{./configure} process
4441 fails, there is no point in trying to compile or test the resulting
4442 tree.
4444 @item
4445 If the @code{flunkOnFailure} or @code{flunkOnWarnings} flag is set,
4446 then a result of FAILURE or WARNINGS will mark the build as a whole as
4447 FAILED. However, the remaining steps will still be executed. This is
4448 appropriate for things like multiple testing steps: a failure in any
4449 one of them will indicate that the build has failed, however it is
4450 still useful to run them all to completion.
4452 @item
4453 Similarly, if the @code{warnOnFailure} or @code{warnOnWarnings} flag
4454 is set, then a result of FAILURE or WARNINGS will mark the build as
4455 having WARNINGS, and the remaining steps will still be executed. This
4456 may be appropriate for certain kinds of optional build or test steps.
4457 For example, a failure experienced while building documentation files
4458 should be made visible with a WARNINGS result but not be serious
4459 enough to warrant marking the whole build with a FAILURE.
4461 @end itemize
4463 In addition, each Step produces its own results, may create logfiles,
4464 etc. However only the flags described above have any effect on the
4465 build as a whole.
4467 The pre-defined BuildSteps like @code{CVS} and @code{Compile} have
4468 reasonably appropriate flags set on them already. For example, without
4469 a source tree there is no point in continuing the build, so the
4470 @code{CVS} class has the @code{haltOnFailure} flag set to True. Look
4471 in @file{buildbot/process/step.py} to see how the other Steps are
4472 marked.
4474 Each Step is created with an additional @code{workdir} argument that
4475 indicates where its actions should take place. This is specified as a
4476 subdirectory of the slave builder's base directory, with a default
4477 value of @code{build}. This is only implemented as a step argument (as
4478 opposed to simply being a part of the base directory) because the
4479 CVS/SVN steps need to perform their checkouts from the parent
4480 directory.
4482 @menu
4483 * BuildFactory Attributes::     
4484 * Quick builds::                
4485 @end menu
4487 @node BuildFactory Attributes, Quick builds, BuildFactory, BuildFactory
4488 @subsubsection BuildFactory Attributes
4490 Some attributes from the BuildFactory are copied into each Build.
4492 @cindex treeStableTimer
4494 @table @code
4495 @item useProgress
4496 (defaults to True): if True, the buildmaster keeps track of how long
4497 each step takes, so it can provide estimates of how long future builds
4498 will take. If builds are not expected to take a consistent amount of
4499 time (such as incremental builds in which a random set of files are
4500 recompiled or tested each time), this should be set to False to
4501 inhibit progress-tracking.
4503 @end table
4506 @node Quick builds,  , BuildFactory Attributes, BuildFactory
4507 @subsubsection Quick builds
4509 @bfindex buildbot.process.factory.QuickBuildFactory
4511 The difference between a ``full build'' and a ``quick build'' is that
4512 quick builds are generally done incrementally, starting with the tree
4513 where the previous build was performed. That simply means that the
4514 source-checkout step should be given a @code{mode='update'} flag, to
4515 do the source update in-place.
4517 In addition to that, the @code{useProgress} flag should be set to
4518 False. Incremental builds will (or at least the ought to) compile as
4519 few files as necessary, so they will take an unpredictable amount of
4520 time to run. Therefore it would be misleading to claim to predict how
4521 long the build will take.
4524 @node Process-Specific build factories,  , BuildFactory, Build Factories
4525 @subsection Process-Specific build factories
4527 Many projects use one of a few popular build frameworks to simplify
4528 the creation and maintenance of Makefiles or other compilation
4529 structures. Buildbot provides several pre-configured BuildFactory
4530 subclasses which let you build these projects with a minimum of fuss.
4532 @menu
4533 * GNUAutoconf::                 
4534 * CPAN::                        
4535 * Python distutils::            
4536 * Python/Twisted/trial projects::  
4537 @end menu
4539 @node GNUAutoconf, CPAN, Process-Specific build factories, Process-Specific build factories
4540 @subsubsection GNUAutoconf
4542 @bfindex buildbot.process.factory.GNUAutoconf
4544 @uref{http://www.gnu.org/software/autoconf/, GNU Autoconf} is a
4545 software portability tool, intended to make it possible to write
4546 programs in C (and other languages) which will run on a variety of
4547 UNIX-like systems. Most GNU software is built using autoconf. It is
4548 frequently used in combination with GNU automake. These tools both
4549 encourage a build process which usually looks like this:
4551 @example
4552 % CONFIG_ENV=foo ./configure --with-flags
4553 % make all
4554 % make check
4555 # make install
4556 @end example
4558 (except of course the Buildbot always skips the @code{make install}
4559 part).
4561 The Buildbot's @code{buildbot.process.factory.GNUAutoconf} factory is
4562 designed to build projects which use GNU autoconf and/or automake. The
4563 configuration environment variables, the configure flags, and command
4564 lines used for the compile and test are all configurable, in general
4565 the default values will be suitable.
4567 Example:
4569 @example
4570 # use the s() convenience function defined earlier
4571 f = factory.GNUAutoconf(source=s(step.SVN, svnurl=URL, mode="copy"),
4572                         flags=["--disable-nls"])
4573 @end example
4575 Required Arguments:
4577 @table @code
4578 @item source
4579 This argument must be a step specification tuple that provides a
4580 BuildStep to generate the source tree.
4581 @end table
4583 Optional Arguments:
4585 @table @code
4586 @item configure
4587 The command used to configure the tree. Defaults to
4588 @code{./configure}. Accepts either a string or a list of shell argv
4589 elements.
4591 @item configureEnv
4592 The environment used for the initial configuration step. This accepts
4593 a dictionary which will be merged into the buildslave's normal
4594 environment. This is commonly used to provide things like
4595 @code{CFLAGS="-O2 -g"} (to turn off debug symbols during the compile).
4596 Defaults to an empty dictionary.
4598 @item configureFlags
4599 A list of flags to be appended to the argument list of the configure
4600 command. This is commonly used to enable or disable specific features
4601 of the autoconf-controlled package, like @code{["--without-x"]} to
4602 disable windowing support. Defaults to an empty list.
4604 @item compile
4605 this is a shell command or list of argv values which is used to
4606 actually compile the tree. It defaults to @code{make all}. If set to
4607 None, the compile step is skipped.
4609 @item test
4610 this is a shell command or list of argv values which is used to run
4611 the tree's self-tests. It defaults to @code{make check}. If set to
4612 None, the test step is skipped.
4614 @end table
4617 @node CPAN, Python distutils, GNUAutoconf, Process-Specific build factories
4618 @subsubsection CPAN
4620 @bfindex buildbot.process.factory.CPAN
4622 Most Perl modules available from the @uref{http://www.cpan.org/, CPAN}
4623 archive use the @code{MakeMaker} module to provide configuration,
4624 build, and test services. The standard build routine for these modules
4625 looks like:
4627 @example
4628 % perl Makefile.PL
4629 % make
4630 % make test
4631 # make install
4632 @end example
4634 (except again Buildbot skips the install step)
4636 Buildbot provides a @code{CPAN} factory to compile and test these
4637 projects.
4640 Arguments:
4641 @table @code
4642 @item source
4643 (required): A step specification tuple, that that used by GNUAutoconf.
4645 @item perl
4646 A string which specifies the @code{perl} executable to use. Defaults
4647 to just @code{perl}.
4649 @end table
4652 @node Python distutils, Python/Twisted/trial projects, CPAN, Process-Specific build factories
4653 @subsubsection Python distutils
4655 @bfindex buildbot.process.factory.Distutils
4657 Most Python modules use the @code{distutils} package to provide
4658 configuration and build services. The standard build process looks
4659 like:
4661 @example
4662 % python ./setup.py build
4663 % python ./setup.py install
4664 @end example
4666 Unfortunately, although Python provides a standard unit-test framework
4667 named @code{unittest}, to the best of my knowledge @code{distutils}
4668 does not provide a standardized target to run such unit tests. (please
4669 let me know if I'm wrong, and I will update this factory).
4671 The @code{Distutils} factory provides support for running the build
4672 part of this process. It accepts the same @code{source=} parameter as
4673 the other build factories.
4676 Arguments:
4677 @table @code
4678 @item source
4679 (required): A step specification tuple, that that used by GNUAutoconf.
4680   
4681 @item python
4682 A string which specifies the @code{python} executable to use. Defaults
4683 to just @code{python}.
4685 @item test
4686 Provides a shell command which runs unit tests. This accepts either a
4687 string or a list. The default value is None, which disables the test
4688 step (since there is no common default command to run unit tests in
4689 distutils modules).
4691 @end table
4694 @node Python/Twisted/trial projects,  , Python distutils, Process-Specific build factories
4695 @subsubsection Python/Twisted/trial projects
4697 @bfindex buildbot.process.factory.Trial
4698 @c TODO: document these steps better
4699 @bsindex buildbot.steps.python_twisted.HLint
4700 @bsindex buildbot.steps.python_twisted.Trial
4701 @bsindex buildbot.steps.python_twisted.ProcessDocs
4702 @bsindex buildbot.steps.python_twisted.BuildDebs
4703 @bsindex buildbot.steps.python_twisted.RemovePYCs
4705 Twisted provides a unit test tool named @code{trial} which provides a
4706 few improvements over Python's built-in @code{unittest} module. Many
4707 python projects which use Twisted for their networking or application
4708 services also use trial for their unit tests. These modules are
4709 usually built and tested with something like the following:
4711 @example
4712 % python ./setup.py build
4713 % PYTHONPATH=build/lib.linux-i686-2.3 trial -v PROJECTNAME.test
4714 % python ./setup.py install
4715 @end example
4717 Unfortunately, the @file{build/lib} directory into which the
4718 built/copied .py files are placed is actually architecture-dependent,
4719 and I do not yet know of a simple way to calculate its value. For many
4720 projects it is sufficient to import their libraries ``in place'' from
4721 the tree's base directory (@code{PYTHONPATH=.}).
4723 In addition, the @var{PROJECTNAME} value where the test files are
4724 located is project-dependent: it is usually just the project's
4725 top-level library directory, as common practice suggests the unit test
4726 files are put in the @code{test} sub-module. This value cannot be
4727 guessed, the @code{Trial} class must be told where to find the test
4728 files.
4730 The @code{Trial} class provides support for building and testing
4731 projects which use distutils and trial. If the test module name is
4732 specified, trial will be invoked. The library path used for testing
4733 can also be set.
4735 One advantage of trial is that the Buildbot happens to know how to
4736 parse trial output, letting it identify which tests passed and which
4737 ones failed. The Buildbot can then provide fine-grained reports about
4738 how many tests have failed, when individual tests fail when they had
4739 been passing previously, etc.
4741 Another feature of trial is that you can give it a series of source
4742 .py files, and it will search them for special @code{test-case-name}
4743 tags that indicate which test cases provide coverage for that file.
4744 Trial can then run just the appropriate tests. This is useful for
4745 quick builds, where you want to only run the test cases that cover the
4746 changed functionality.
4748 Arguments:
4749 @table @code
4750 @item source
4751 (required): A step specification tuple, like that used by GNUAutoconf.
4753 @item buildpython
4754 A list (argv array) of strings which specifies the @code{python}
4755 executable to use when building the package. Defaults to just
4756 @code{['python']}. It may be useful to add flags here, to supress
4757 warnings during compilation of extension modules. This list is
4758 extended with @code{['./setup.py', 'build']} and then executed in a
4759 ShellCommand.
4761 @item testpath
4762 Provides a directory to add to @code{PYTHONPATH} when running the unit
4763 tests, if tests are being run. Defaults to @code{.} to include the
4764 project files in-place. The generated build library is frequently
4765 architecture-dependent, but may simply be @file{build/lib} for
4766 pure-python modules.
4768 @item trialpython
4769 Another list of strings used to build the command that actually runs
4770 trial. This is prepended to the contents of the @code{trial} argument
4771 below. It may be useful to add @code{-W} flags here to supress
4772 warnings that occur while tests are being run. Defaults to an empty
4773 list, meaning @code{trial} will be run without an explicit
4774 interpreter, which is generally what you want if you're using
4775 @file{/usr/bin/trial} instead of, say, the @file{./bin/trial} that
4776 lives in the Twisted source tree.
4778 @item trial
4779 provides the name of the @code{trial} command. It is occasionally
4780 useful to use an alternate executable, such as @code{trial2.2} which
4781 might run the tests under an older version of Python. Defaults to
4782 @code{trial}.
4784 @item tests
4785 Provides a module name or names which contain the unit tests for this
4786 project. Accepts a string, typically @code{PROJECTNAME.test}, or a
4787 list of strings. Defaults to None, indicating that no tests should be
4788 run. You must either set this or @code{useTestCaseNames} to do anyting
4789 useful with the Trial factory.
4791 @item useTestCaseNames
4792 Tells the Step to provide the names of all changed .py files to trial,
4793 so it can look for test-case-name tags and run just the matching test
4794 cases. Suitable for use in quick builds. Defaults to False.
4796 @item randomly
4797 If @code{True}, tells Trial (with the @code{--random=0} argument) to
4798 run the test cases in random order, which sometimes catches subtle
4799 inter-test dependency bugs. Defaults to @code{False}.
4801 @item recurse
4802 If @code{True}, tells Trial (with the @code{--recurse} argument) to
4803 look in all subdirectories for additional test cases. It isn't clear
4804 to me how this works, but it may be useful to deal with the
4805 unknown-PROJECTNAME problem described above, and is currently used in
4806 the Twisted buildbot to accomodate the fact that test cases are now
4807 distributed through multiple twisted.SUBPROJECT.test directories.
4809 @end table  
4811 Unless one of @code{trialModule} or @code{useTestCaseNames}
4812 are set, no tests will be run.
4814 Some quick examples follow. Most of these examples assume that the
4815 target python code (the ``code under test'') can be reached directly
4816 from the root of the target tree, rather than being in a @file{lib/}
4817 subdirectory.
4819 @example
4820 #  Trial(source, tests="toplevel.test") does:
4821 #   python ./setup.py build
4822 #   PYTHONPATH=. trial -to toplevel.test
4824 #  Trial(source, tests=["toplevel.test", "other.test"]) does:
4825 #   python ./setup.py build
4826 #   PYTHONPATH=. trial -to toplevel.test other.test
4828 #  Trial(source, useTestCaseNames=True) does:
4829 #   python ./setup.py build
4830 #   PYTHONPATH=. trial -to --testmodule=foo/bar.py..  (from Changes)
4832 #  Trial(source, buildpython=["python2.3", "-Wall"], tests="foo.tests"):
4833 #   python2.3 -Wall ./setup.py build
4834 #   PYTHONPATH=. trial -to foo.tests
4836 #  Trial(source, trialpython="python2.3", trial="/usr/bin/trial",
4837 #        tests="foo.tests") does:
4838 #   python2.3 -Wall ./setup.py build
4839 #   PYTHONPATH=. python2.3 /usr/bin/trial -to foo.tests
4841 # For running trial out of the tree being tested (only useful when the
4842 # tree being built is Twisted itself):
4843 #  Trial(source, trialpython=["python2.3", "-Wall"], trial="./bin/trial",
4844 #        tests="foo.tests") does:
4845 #   python2.3 -Wall ./setup.py build
4846 #   PYTHONPATH=. python2.3 -Wall ./bin/trial -to foo.tests
4847 @end example
4849 If the output directory of @code{./setup.py build} is known, you can
4850 pull the python code from the built location instead of the source
4851 directories. This should be able to handle variations in where the
4852 source comes from, as well as accomodating binary extension modules:
4854 @example
4855 # Trial(source,tests="toplevel.test",testpath='build/lib.linux-i686-2.3')
4856 # does:
4857 #  python ./setup.py build
4858 #  PYTHONPATH=build/lib.linux-i686-2.3 trial -to toplevel.test
4859 @end example
4862 @node Status Delivery, Command-line tool, Build Process, Top
4863 @chapter Status Delivery
4865 More details are available in the docstrings for each class, use
4866 @code{pydoc buildbot.status.html.Waterfall} to see them. Most status
4867 delivery objects take a @code{categories=} argument, which can contain
4868 a list of ``category'' names: in this case, it will only show status
4869 for Builders that are in one of the named categories.
4871 (implementor's note: each of these objects should be a
4872 service.MultiService which will be attached to the BuildMaster object
4873 when the configuration is processed. They should use
4874 @code{self.parent.getStatus()} to get access to the top-level IStatus
4875 object, either inside @code{startService} or later. They may call
4876 @code{status.subscribe()} in @code{startService} to receive
4877 notifications of builder events, in which case they must define
4878 @code{builderAdded} and related methods. See the docstrings in
4879 @file{buildbot/interfaces.py} for full details.)
4881 @menu
4882 * HTML Waterfall::              
4883 * IRC Bot::                     
4884 * PBListener::                  
4885 * Writing New Status Plugins::  
4886 @end menu
4888 @c @node Email Delivery,  , Status Delivery, Status Delivery
4889 @c @subsection Email Delivery
4891 @c DOCUMENT THIS
4893 @node HTML Waterfall, IRC Bot, Status Delivery, Status Delivery
4894 @section HTML Waterfall
4896 @cindex Waterfall
4897 @stindex buildbot.status.html.Waterfall
4900 @example
4901 from buildbot.status import html
4902 w = html.Waterfall(http_port=8080)
4903 c['status'].append(w)
4904 @end example
4906 The @code{buildbot.status.html.Waterfall} status target creates an
4907 HTML ``waterfall display'', which shows a time-based chart of events.
4908 This display provides detailed information about all steps of all
4909 recent builds, and provides hyperlinks to look at individual build
4910 logs and source changes. If the @code{http_port} argument is provided,
4911 it provides a strports specification for the port that the web server
4912 should listen on. This can be a simple port number, or a string like
4913 @code{tcp:8080:interface=127.0.0.1} (to limit connections to the
4914 loopback interface, and therefore to clients running on the same
4915 host)@footnote{It may even be possible to provide SSL access by using
4916 a specification like
4917 @code{"ssl:12345:privateKey=mykey.pen:certKey=cert.pem"}, but this is
4918 completely untested}.
4920 If instead (or in addition) you provide the @code{distrib_port}
4921 argument, a twisted.web distributed server will be started either on a
4922 TCP port (if @code{distrib_port} is like @code{"tcp:12345"}) or more
4923 likely on a UNIX socket (if @code{distrib_port} is like
4924 @code{"unix:/path/to/socket"}).
4926 The @code{distrib_port} option means that, on a host with a
4927 suitably-configured twisted-web server, you do not need to consume a
4928 separate TCP port for the buildmaster's status web page. When the web
4929 server is constructed with @code{mktap web --user}, URLs that point to
4930 @code{http://host/~username/} are dispatched to a sub-server that is
4931 listening on a UNIX socket at @code{~username/.twisted-web-pb}. On
4932 such a system, it is convenient to create a dedicated @code{buildbot}
4933 user, then set @code{distrib_port} to
4934 @code{"unix:"+os.path.expanduser("~/.twistd-web-pb")}. This
4935 configuration will make the HTML status page available at
4936 @code{http://host/~buildbot/} . Suitable URL remapping can make it
4937 appear at @code{http://host/buildbot/}, and the right virtual host
4938 setup can even place it at @code{http://buildbot.host/} .
4940 Other arguments:
4942 @table @code
4943 @item allowForce
4944 If set to True (the default), then the web page will provide a ``Force
4945 Build'' button that allows visitors to manually trigger builds. This
4946 is useful for developers to re-run builds that have failed because of
4947 intermittent problems in the test suite, or because of libraries that
4948 were not installed at the time of the previous build. You may not wish
4949 to allow strangers to cause a build to run: in that case, set this to
4950 False to remove these buttons.
4952 @item favicon
4953 If set to a string, this will be interpreted as a filename containing
4954 a ``favicon'': a small image that contains an icon for the web site.
4955 This is returned to browsers that request the @code{favicon.ico} file,
4956 and should point to a .png or .ico image file. The default value uses
4957 the buildbot/buildbot.png image (a small hex nut) contained in the
4958 buildbot distribution. You can set this to None to avoid using a
4959 favicon at all.
4961 @item robots_txt
4962 If set to a string, this will be interpreted as a filename containing
4963 the contents of ``robots.txt''. Many search engine spiders request
4964 this file before indexing the site. Setting it to a file which
4965 contains:
4966 @example
4967 User-agent: *
4968 Disallow: /
4969 @end example
4970 will prevent most search engines from trawling the (voluminous)
4971 generated status pages.
4973 @end table
4976 @node IRC Bot, PBListener, HTML Waterfall, Status Delivery
4977 @section IRC Bot
4979 @cindex IRC
4980 @stindex buildbot.status.words.IRC
4983 The @code{buildbot.status.words.IRC} status target creates an IRC bot
4984 which will attach to certain channels and be available for status
4985 queries. It can also be asked to announce builds as they occur, or be
4986 told to shut up.
4988 @example
4989 from twisted.status import words
4990 irc = words.IRC("irc.example.org", "botnickname", 
4991                 channels=["channel1", "channel2"],
4992                 password="mysecretpassword")
4993 c['status'].append(irc)
4994 @end example
4996 Take a look at the docstring for @code{words.IRC} for more details on
4997 configuring this service. The @code{password} argument, if provided,
4998 will be sent to Nickserv to claim the nickname: some IRC servers will
4999 not allow clients to send private messages until they have logged in
5000 with a password.
5002 To use the service, you address messages at the buildbot, either
5003 normally (@code{botnickname: status}) or with private messages
5004 (@code{/msg botnickname status}). The buildbot will respond in kind.
5006 Some of the commands currently available:
5008 @table @code
5010 @item list builders
5011 Emit a list of all configured builders
5012 @item status BUILDER
5013 Announce the status of a specific Builder: what it is doing right now.
5014 @item status all
5015 Announce the status of all Builders
5016 @item watch BUILDER
5017 If the given Builder is currently running, wait until the Build is
5018 finished and then announce the results.
5019 @item last BUILDER
5020 Return the results of the last build to run on the given Builder.
5022 @item help COMMAND
5023 Describe a command. Use @code{help commands} to get a list of known
5024 commands.
5025 @item source
5026 Announce the URL of the Buildbot's home page.
5027 @item version
5028 Announce the version of this Buildbot.
5029 @end table
5031 If the @code{allowForce=True} option was used, some addtional commands
5032 will be available:
5034 @table @code
5035 @item force build BUILDER REASON
5036 Tell the given Builder to start a build of the latest code. The user
5037 requesting the build and REASON are recorded in the Build status. The
5038 buildbot will announce the build's status when it finishes.
5040 @item stop build BUILDER REASON
5041 Terminate any running build in the given Builder. REASON will be added
5042 to the build status to explain why it was stopped. You might use this
5043 if you committed a bug, corrected it right away, and don't want to
5044 wait for the first build (which is destined to fail) to complete
5045 before starting the second (hopefully fixed) build.
5046 @end table
5048 @node PBListener, Writing New Status Plugins, IRC Bot, Status Delivery
5049 @section PBListener
5051 @cindex PBListener
5052 @stindex buildbot.status.client.PBListener
5055 @example
5056 import buildbot.status.client
5057 pbl = buildbot.status.client.PBListener(port=int, user=str,
5058                                         passwd=str)
5059 c['status'].append(pbl)
5060 @end example
5062 This sets up a PB listener on the given TCP port, to which a PB-based
5063 status client can connect and retrieve status information.
5064 @code{buildbot statusgui} (@pxref{statusgui}) is an example of such a
5065 status client. The @code{port} argument can also be a strports
5066 specification string.
5068 @node Writing New Status Plugins,  , PBListener, Status Delivery
5069 @section Writing New Status Plugins
5071 TODO: this needs a lot more examples
5073 Each status plugin is an object which provides the
5074 @code{twisted.application.service.IService} interface, which creates a
5075 tree of Services with the buildmaster at the top [not strictly true].
5076 The status plugins are all children of an object which implements
5077 @code{buildbot.interfaces.IStatus}, the main status object. From this
5078 object, the plugin can retrieve anything it wants about current and
5079 past builds. It can also subscribe to hear about new and upcoming
5080 builds.
5082 Status plugins which only react to human queries (like the Waterfall
5083 display) never need to subscribe to anything: they are idle until
5084 someone asks a question, then wake up and extract the information they
5085 need to answer it, then they go back to sleep. Plugins which need to
5086 act spontaneously when builds complete (like the Mail plugin) need to
5087 subscribe to hear about new builds.
5089 If the status plugin needs to run network services (like the HTTP
5090 server used by the Waterfall plugin), they can be attached as Service
5091 children of the plugin itself, using the @code{IServiceCollection}
5092 interface.
5096 @node Command-line tool, Resources, Status Delivery, Top
5097 @chapter Command-line tool
5099 The @command{buildbot} command-line tool can be used to start or stop a
5100 buildmaster or buildbot, and to interact with a running buildmaster.
5101 Some of its subcommands are intended for buildmaster admins, while
5102 some are for developers who are editing the code that the buildbot is
5103 monitoring.
5105 @menu
5106 * Administrator Tools::         
5107 * Developer Tools::             
5108 * Other Tools::                 
5109 * .buildbot config directory::  
5110 @end menu
5112 @node Administrator Tools, Developer Tools, Command-line tool, Command-line tool
5113 @section Administrator Tools
5115 The following @command{buildbot} sub-commands are intended for
5116 buildmaster administrators:
5118 @heading create-master
5120 This creates a new directory and populates it with files that allow it
5121 to be used as a buildmaster's base directory.
5123 @example
5124 buildbot create-master BASEDIR
5125 @end example
5127 @heading create-slave
5129 This creates a new directory and populates it with files that let it
5130 be used as a buildslave's base directory. You must provide several
5131 arguments, which are used to create the initial @file{buildbot.tac}
5132 file.
5134 @example
5135 buildbot create-slave @var{BASEDIR} @var{MASTERHOST}:@var{PORT} @var{SLAVENAME} @var{PASSWORD}
5136 @end example
5138 @heading start
5140 This starts a buildmaster or buildslave which was already created in
5141 the given base directory. The daemon is launched in the background,
5142 with events logged to a file named @file{twistd.log}.
5144 @example
5145 buildbot start BASEDIR
5146 @end example
5148 @heading stop
5150 This terminates the daemon (either buildmaster or buildslave) running
5151 in the given directory.
5153 @example
5154 buildbot stop BASEDIR
5155 @end example
5157 @heading sighup
5159 This sends a SIGHUP to the buildmaster running in the given directory,
5160 which causes it to re-read its @file{master.cfg} file.
5162 @example
5163 buildbot sighup BASEDIR
5164 @end example
5166 @node Developer Tools, Other Tools, Administrator Tools, Command-line tool
5167 @section Developer Tools
5169 These tools are provided for use by the developers who are working on
5170 the code that the buildbot is monitoring.
5172 @menu
5173 * statuslog::                   
5174 * statusgui::                   
5175 * try::                         
5176 @end menu
5178 @node statuslog, statusgui, Developer Tools, Developer Tools
5179 @subsection statuslog
5181 @example
5182 buildbot statuslog --master @var{MASTERHOST}:@var{PORT}
5183 @end example
5185 This command starts a simple text-based status client, one which just
5186 prints out a new line each time an event occurs on the buildmaster.
5188 The @option{--master} option provides the location of the
5189 @code{client.PBListener} status port, used to deliver build
5190 information to realtime status clients. The option is always in the
5191 form of a string, with hostname and port number separated by a colon
5192 (@code{HOSTNAME:PORTNUM}). Note that this port is @emph{not} the same
5193 as the slaveport (although a future version may allow the same port
5194 number to be used for both purposes).
5196 The @option{--master} option can also be provided by the
5197 @code{masterstatus} name in @file{.buildbot/options} (@pxref{.buildbot
5198 config directory}).
5200 @node statusgui, try, statuslog, Developer Tools
5201 @subsection statusgui
5203 @cindex statusgui
5205 If you have set up a PBListener (@pxref{PBListener}), you will be able
5206 to monitor your Buildbot using a simple Gtk+ application invoked with
5207 the @code{buildbot statusgui} command:
5209 @example
5210 buildbot statusgui --master @var{MASTERHOST}:@var{PORT}
5211 @end example
5213 This command starts a simple Gtk+-based status client, which contains
5214 a few boxes for each Builder that change color as events occur. It
5215 uses the same @option{--master} argument as the @command{buildbot
5216 statuslog} command (@pxref{statuslog}).
5218 @node try,  , statusgui, Developer Tools
5219 @subsection try
5221 This lets a developer to ask the question ``What would happen if I
5222 committed this patch right now?''. It runs the unit test suite (across
5223 multiple build platforms) on the developer's current code, allowing
5224 them to make sure they will not break the tree when they finally
5225 commit their changes.
5227 The @command{buildbot try} command is meant to be run from within a
5228 developer's local tree, and starts by figuring out the base revision
5229 of that tree (what revision was current the last time the tree was
5230 updated), and a patch that can be applied to that revision of the tree
5231 to make it match the developer's copy. This (revision, patch) pair is
5232 then sent to the buildmaster, which runs a build with that
5233 SourceStamp. If you want, the tool will emit status messages as the
5234 builds run, and will not terminate until the first failure has been
5235 detected (or the last success).
5237 For this command to work, several pieces must be in place:
5240 @heading TryScheduler
5242 @slindex buildbot.scheduler.Try_Jobdir
5243 @slindex buildbot.scheduler.Try_Userpass
5245 The buildmaster must have a @code{scheduler.Try} instance in
5246 the config file's @code{c['schedulers']} list. This lets the
5247 administrator control who may initiate these ``trial'' builds, which
5248 branches are eligible for trial builds, and which Builders should be
5249 used for them.
5251 The @code{TryScheduler} has various means to accept build requests:
5252 all of them enforce more security than the usual buildmaster ports do.
5253 Any source code being built can be used to compromise the buildslave
5254 accounts, but in general that code must be checked out from the VC
5255 repository first, so only people with commit privileges can get
5256 control of the buildslaves. The usual force-build control channels can
5257 waste buildslave time but do not allow arbitrary commands to be
5258 executed by people who don't have those commit privileges. However,
5259 the source code patch that is provided with the trial build does not
5260 have to go through the VC system first, so it is important to make
5261 sure these builds cannot be abused by a non-committer to acquire as
5262 much control over the buildslaves as a committer has. Ideally, only
5263 developers who have commit access to the VC repository would be able
5264 to start trial builds, but unfortunately the buildmaster does not, in
5265 general, have access to VC system's user list.
5267 As a result, the @code{TryScheduler} requires a bit more
5268 configuration. There are currently two ways to set this up:
5270 @table @strong
5271 @item jobdir (ssh)
5273 This approach creates a command queue directory, called the
5274 ``jobdir'', in the buildmaster's working directory. The buildmaster
5275 admin sets the ownership and permissions of this directory to only
5276 grant write access to the desired set of developers, all of whom must
5277 have accounts on the machine. The @code{buildbot try} command creates
5278 a special file containing the source stamp information and drops it in
5279 the jobdir, just like a standard maildir. When the buildmaster notices
5280 the new file, it unpacks the information inside and starts the builds.
5282 The config file entries used by 'buildbot try' either specify a local
5283 queuedir (for which write and mv are used) or a remote one (using scp
5284 and ssh).
5286 The advantage of this scheme is that it is quite secure, the
5287 disadvantage is that it requires fiddling outside the buildmaster
5288 config (to set the permissions on the jobdir correctly). If the
5289 buildmaster machine happens to also house the VC repository, then it
5290 can be fairly easy to keep the VC userlist in sync with the
5291 trial-build userlist. If they are on different machines, this will be
5292 much more of a hassle. It may also involve granting developer accounts
5293 on a machine that would not otherwise require them.
5295 To implement this, the buildslave invokes 'ssh -l username host
5296 buildbot tryserver ARGS', passing the patch contents over stdin. The
5297 arguments must include the inlet directory and the revision
5298 information.
5300 @item user+password (PB)
5302 In this approach, each developer gets a username/password pair, which
5303 are all listed in the buildmaster's configuration file. When the
5304 developer runs @code{buildbot try}, their machine connects to the
5305 buildmaster via PB and authenticates themselves using that username
5306 and password, then sends a PB command to start the trial build.
5308 The advantage of this scheme is that the entire configuration is
5309 performed inside the buildmaster's config file. The disadvantages are
5310 that it is less secure (while the ``cred'' authentication system does
5311 not expose the password in plaintext over the wire, it does not offer
5312 most of the other security properties that SSH does). In addition, the
5313 buildmaster admin is responsible for maintaining the username/password
5314 list, adding and deleting entries as developers come and go.
5316 @end table
5319 For example, to set up the ``jobdir'' style of trial build, using a
5320 command queue directory of @file{MASTERDIR/jobdir} (and assuming that
5321 all your project developers were members of the @code{developers} unix
5322 group), you would first create that directory (with @command{mkdir
5323 MASTERDIR/jobdir MASTERDIR/jobdir/new MASTERDIR/jobdir/cur
5324 MASTERDIR/jobdir/tmp; chgrp developers MASTERDIR/jobdir
5325 MASTERDIR/jobdir/*; chmod g+rwx,o-rwx MASTERDIR/jobdir
5326 MASTERDIR/jobdir/*}), and then use the following scheduler in the
5327 buildmaster's config file:
5329 @example
5330 from buildbot.scheduler import Try_Jobdir
5331 s = Try_Jobdir("try1", ["full-linux", "full-netbsd", "full-OSX"],
5332                jobdir="jobdir")
5333 c['schedulers'] = [s]
5334 @end example
5336 Note that you must create the jobdir before telling the buildmaster to
5337 use this configuration, otherwise you will get an error. Also remember
5338 that the buildmaster must be able to read and write to the jobdir as
5339 well. Be sure to watch the @file{twistd.log} file (@pxref{Logfiles})
5340 as you start using the jobdir, to make sure the buildmaster is happy
5341 with it.
5343 To use the username/password form of authentication, create a
5344 @code{Try_Userpass} instance instead. It takes the same
5345 @code{builderNames} argument as the @code{Try_Jobdir} form, but
5346 accepts an addtional @code{port} argument (to specify the TCP port to
5347 listen on) and a @code{userpass} list of username/password pairs to
5348 accept. Remember to use good passwords for this: the security of the
5349 buildslave accounts depends upon it:
5351 @example
5352 from buildbot.scheduler import Try_Userpass
5353 s = Try_Userpass("try2", ["full-linux", "full-netbsd", "full-OSX"],
5354                  port=8031, userpass=[("alice","pw1"), ("bob", "pw2")] )
5355 c['schedulers'] = [s]
5356 @end example
5358 Like most places in the buildbot, the @code{port} argument takes a
5359 strports specification. See @code{twisted.application.strports} for
5360 details.
5363 @heading locating the master
5365 The @command{try} command needs to be told how to connect to the
5366 @code{TryScheduler}, and must know which of the authentication
5367 approaches described above is in use by the buildmaster. You specify
5368 the approach by using @option{--connect=ssh} or @option{--connect=pb}
5369 (or @code{try_connect = 'ssh'} or @code{try_connect = 'pb'} in
5370 @file{.buildbot/options}).
5372 For the PB approach, the command must be given a @option{--master}
5373 argument (in the form HOST:PORT) that points to TCP port that you
5374 picked in the @code{Try_Userpass} scheduler. It also takes a
5375 @option{--username} and @option{--passwd} pair of arguments that match
5376 one of the entries in the buildmaster's @code{userpass} list. These
5377 arguments can also be provided as @code{try_master},
5378 @code{try_username}, and @code{try_password} entries in the
5379 @file{.buildbot/options} file.
5381 For the SSH approach, the command must be given @option{--tryhost},
5382 @option{--username}, and optionally @option{--password} (TODO:
5383 really?) to get to the buildmaster host. It must also be given
5384 @option{--trydir}, which points to the inlet directory configured
5385 above. The trydir can be relative to the user's home directory, but
5386 most of the time you will use an explicit path like
5387 @file{~buildbot/project/trydir}. These arguments can be provided in
5388 @file{.buildbot/options} as @code{try_host}, @code{try_username},
5389 @code{try_password}, and @code{try_dir}.
5391 In addition, the SSH approach needs to connect to a PBListener status
5392 port, so it can retrieve and report the results of the build (the PB
5393 approach uses the existing connection to retrieve status information,
5394 so this step is not necessary). This requires a @option{--master}
5395 argument, or a @code{masterstatus} entry in @file{.buildbot/options},
5396 in the form of a HOSTNAME:PORT string.
5399 @heading choosing the Builders
5401 A trial build is performed on multiple Builders at the same time, and
5402 the developer gets to choose which Builders are used (limited to a set
5403 selected by the buildmaster admin with the TryScheduler's
5404 @code{builderNames=} argument). The set you choose will depend upon
5405 what your goals are: if you are concerned about cross-platform
5406 compatibility, you should use multiple Builders, one from each
5407 platform of interest. You might use just one builder if that platform
5408 has libraries or other facilities that allow better test coverage than
5409 what you can accomplish on your own machine, or faster test runs.
5411 The set of Builders to use can be specified with multiple
5412 @option{--builder} arguments on the command line. It can also be
5413 specified with a single @code{try_builders} option in
5414 @file{.buildbot/options} that uses a list of strings to specify all
5415 the Builder names:
5417 @example
5418 try_builders = ["full-OSX", "full-win32", "full-linux"]
5419 @end example
5421 @heading specifying the VC system
5423 The @command{try} command also needs to know how to take the
5424 developer's current tree and extract the (revision, patch)
5425 source-stamp pair. Each VC system uses a different process, so you
5426 start by telling the @command{try} command which VC system you are
5427 using, with an argument like @option{--vc=cvs} or @option{--vc=tla}.
5428 This can also be provided as @code{try_vc} in
5429 @file{.buildbot/options}.
5431 The following names are recognized: @code{cvs} @code{svn} @code{baz}
5432 @code{tla} @code{hg} @code{darcs}
5435 @heading finding the top of the tree
5437 Some VC systems (notably CVS and SVN) track each directory
5438 more-or-less independently, which means the @command{try} command
5439 needs to move up to the top of the project tree before it will be able
5440 to construct a proper full-tree patch. To accomplish this, the
5441 @command{try} command will crawl up through the parent directories
5442 until it finds a marker file. The default name for this marker file is
5443 @file{.buildbot-top}, so when you are using CVS or SVN you should
5444 @code{touch .buildbot-top} from the top of your tree before running
5445 @command{buildbot try}. Alternatively, you can use a filename like
5446 @file{ChangeLog} or @file{README}, since many projects put one of
5447 these files in their top-most directory (and nowhere else). To set
5448 this filename, use @option{--try-topfile=ChangeLog}, or set it in the
5449 options file with @code{try_topfile = 'ChangeLog'}.
5451 You can also manually set the top of the tree with
5452 @option{--try-topdir=~/trees/mytree}, or @code{try_topdir =
5453 '~/trees/mytree'}. If you use @code{try_topdir}, in a
5454 @file{.buildbot/options} file, you will need a separate options file
5455 for each tree you use, so it may be more convenient to use the
5456 @code{try_topfile} approach instead.
5458 Other VC systems which work on full projects instead of individual
5459 directories (tla, baz, darcs, monotone, mercurial) do not require
5460 @command{try} to know the top directory, so the @option{--try-topfile}
5461 and @option{--try-topdir} arguments will be ignored.
5462 @c is this true? I think I currently require topdirs all the time.
5464 If the @command{try} command cannot find the top directory, it will
5465 abort with an error message.
5467 @heading determining the branch name
5469 Some VC systems record the branch information in a way that ``try''
5470 can locate it, in particular Arch (both @command{tla} and
5471 @command{baz}). For the others, if you are using something other than
5472 the default branch, you will have to tell the buildbot which branch
5473 your tree is using. You can do this with either the @option{--branch}
5474 argument, or a @option{try_branch} entry in the
5475 @file{.buildbot/options} file.
5477 @heading determining the revision and patch
5479 Each VC system has a separate approach for determining the tree's base
5480 revision and computing a patch.
5482 @table @code
5484 @item CVS
5486 @command{try} pretends that the tree is up to date. It converts the
5487 current time into a @code{-D} time specification, uses it as the base
5488 revision, and computes the diff between the upstream tree as of that
5489 point in time versus the current contents. This works, more or less,
5490 but requires that the local clock be in reasonably good sync with the
5491 repository.
5493 @item SVN
5494 @command{try} does a @code{svn status -u} to find the latest
5495 repository revision number (emitted on the last line in the ``Status
5496 against revision: NN'' message). It then performs an @code{svn diff
5497 -rNN} to find out how your tree differs from the repository version,
5498 and sends the resulting patch to the buildmaster. If your tree is not
5499 up to date, this will result in the ``try'' tree being created with
5500 the latest revision, then @emph{backwards} patches applied to bring it
5501 ``back'' to the version you actually checked out (plus your actual
5502 code changes), but this will still result in the correct tree being
5503 used for the build.
5505 @item baz
5506 @command{try} does a @code{baz tree-id} to determine the
5507 fully-qualified version and patch identifier for the tree
5508 (ARCHIVE/VERSION--patch-NN), and uses the VERSION--patch-NN component
5509 as the base revision. It then does a @code{baz diff} to obtain the
5510 patch.
5512 @item tla
5513 @command{try} does a @code{tla tree-version} to get the
5514 fully-qualified version identifier (ARCHIVE/VERSION), then takes the
5515 first line of @code{tla logs --reverse} to figure out the base
5516 revision. Then it does @code{tla changes --diffs} to obtain the patch.
5518 @item Darcs
5519 @code{darcs changes --context} emits a text file that contains a list
5520 of all patches back to and including the last tag was made. This text
5521 file (plus the location of a repository that contains all these
5522 patches) is sufficient to re-create the tree. Therefore the contents
5523 of this ``context'' file @emph{are} the revision stamp for a
5524 Darcs-controlled source tree.
5526 So @command{try} does a @code{darcs changes --context} to determine
5527 what your tree's base revision is, and then does a @code{darcs diff
5528 -u} to compute the patch relative to that revision.
5530 @item Mercurial
5531 @code{hg identify} emits a short revision ID (basically a truncated
5532 SHA1 hash of the current revision's contents), which is used as the
5533 base revision. @code{hg diff} then provides the patch relative to that
5534 revision. For @command{try} to work, your working directory must only
5535 have patches that are available from the same remotely-available
5536 repository that the build process' @code{step.Mercurial} will use.
5538 @c TODO: monotone, git
5539 @end table
5541 @heading waiting for results
5543 If you provide the @option{--wait} option (or @code{try_wait = True}
5544 in @file{.buildbot/options}), the @command{buildbot try} command will
5545 wait until your changes have either been proven good or bad before
5546 exiting. Unless you use the @option{--quiet} option (or
5547 @code{try_quiet=True}), it will emit a progress message every 60
5548 seconds until the builds have completed.
5551 @node Other Tools, .buildbot config directory, Developer Tools, Command-line tool
5552 @section Other Tools
5554 These tools are generally used by buildmaster administrators.
5556 @menu
5557 * sendchange::                  
5558 * debugclient::                 
5559 @end menu
5561 @node sendchange, debugclient, Other Tools, Other Tools
5562 @subsection sendchange
5564 This command is used to tell the buildmaster about source changes. It
5565 is intended to be used from within a commit script, installed on the
5566 VC server. It requires that you have a PBChangeSource
5567 (@pxref{PBChangeSource}) running in the buildmaster (by being included
5568 in the @code{c['sources']} list).
5571 @example
5572 buildbot sendchange --master @var{MASTERHOST}:@var{PORT} --username @var{USER} @var{FILENAMES..}
5573 @end example
5575 There are other (optional) arguments which can influence the
5576 @code{Change} that gets submitted:
5578 @table @code
5579 @item --branch
5580 This provides the (string) branch specifier. If omitted, it defaults
5581 to None, indicating the ``default branch''. All files included in this
5582 Change must be on the same branch.
5584 @item --revision_number
5585 This provides a (numeric) revision number for the change, used for VC systems
5586 that use numeric transaction numbers (like Subversion).
5588 @item --revision
5589 This provides a (string) revision specifier, for VC systems that use
5590 strings (Arch would use something like patch-42 etc).
5592 @item --revision_file
5593 This provides a filename which will be opened and the contents used as
5594 the revision specifier. This is specifically for Darcs, which uses the
5595 output of @command{darcs changes --context} as a revision specifier.
5596 This context file can be a couple of kilobytes long, spanning a couple
5597 lines per patch, and would be a hassle to pass as a command-line
5598 argument.
5600 @item --comments
5601 This provides the change comments as a single argument. You may want
5602 to use @option{--logfile} instead.
5604 @item --logfile
5605 This instructs the tool to read the change comments from the given
5606 file. If you use @code{-} as the filename, the tool will read the
5607 change comments from stdin.
5608 @end table
5611 @node debugclient,  , sendchange, Other Tools
5612 @subsection debugclient
5614 @example
5615 buildbot debugclient --master @var{MASTERHOST}:@var{PORT} --passwd @var{DEBUGPW}
5616 @end example
5618 This launches a small Gtk+/Glade-based debug tool, connecting to the
5619 buildmaster's ``debug port''. This debug port shares the same port
5620 number as the slaveport (@pxref{Setting the slaveport}), but the
5621 @code{debugPort} is only enabled if you set a debug password in the
5622 buildmaster's config file (@pxref{Debug options}). The
5623 @option{--passwd} option must match the @code{c['debugPassword']}
5624 value.
5626 @option{--master} can also be provided in @file{.debug/options} by the
5627 @code{master} key. @option{--passwd} can be provided by the
5628 @code{debugPassword} key.
5630 The @code{Connect} button must be pressed before any of the other
5631 buttons will be active. This establishes the connection to the
5632 buildmaster. The other sections of the tool are as follows:
5634 @table @code
5635 @item Reload .cfg
5636 Forces the buildmaster to reload its @file{master.cfg} file. This is
5637 equivalent to sending a SIGHUP to the buildmaster, but can be done
5638 remotely through the debug port. Note that it is a good idea to be
5639 watching the buildmaster's @file{twistd.log} as you reload the config
5640 file, as any errors which are detected in the config file will be
5641 announced there.
5643 @item Rebuild .py
5644 (not yet implemented). The idea here is to use Twisted's ``rebuild''
5645 facilities to replace the buildmaster's running code with a new
5646 version. Even if this worked, it would only be used by buildbot
5647 developers.
5649 @item poke IRC
5650 This locates a @code{words.IRC} status target and causes it to emit a
5651 message on all the channels to which it is currently connected. This
5652 was used to debug a problem in which the buildmaster lost the
5653 connection to the IRC server and did not attempt to reconnect.
5655 @item Commit
5656 This allows you to inject a Change, just as if a real one had been
5657 delivered by whatever VC hook you are using. You can set the name of
5658 the committed file and the name of the user who is doing the commit.
5659 Optionally, you can also set a revision for the change. If the
5660 revision you provide looks like a number, it will be sent as an
5661 integer, otherwise it will be sent as a string.
5663 @item Force Build
5664 This lets you force a Builder (selected by name) to start a build of
5665 the current source tree.
5667 @item Currently
5668 (obsolete). This was used to manually set the status of the given
5669 Builder, but the status-assignment code was changed in an incompatible
5670 way and these buttons are no longer meaningful.
5672 @end table
5675 @node .buildbot config directory,  , Other Tools, Command-line tool
5676 @section .buildbot config directory
5678 Many of the @command{buildbot} tools must be told how to contact the
5679 buildmaster that they interact with. This specification can be
5680 provided as a command-line argument, but most of the time it will be
5681 easier to set them in an ``options'' file. The @command{buildbot}
5682 command will look for a special directory named @file{.buildbot},
5683 starting from the current directory (where the command was run) and
5684 crawling upwards, eventually looking in the user's home directory. It
5685 will look for a file named @file{options} in this directory, and will
5686 evaluate it as a python script, looking for certain names to be set.
5687 You can just put simple @code{name = 'value'} pairs in this file to
5688 set the options.
5690 For a description of the names used in this file, please see the
5691 documentation for the individual @command{buildbot} sub-commands. The
5692 following is a brief sample of what this file's contents could be.
5694 @example
5695 # for status-reading tools
5696 masterstatus = 'buildbot.example.org:12345'
5697 # for 'sendchange' or the debug port
5698 master = 'buildbot.example.org:18990'
5699 debugPassword = 'eiv7Po'
5700 @end example
5702 @table @code
5703 @item masterstatus
5704 Location of the @code{client.PBListener} status port, used by
5705 @command{statuslog} and @command{statusgui}.
5707 @item master
5708 Location of the @code{debugPort} (for @command{debugclient}). Also the
5709 location of the @code{pb.PBChangeSource} (for @command{sendchange}).
5710 Usually shares the slaveport, but a future version may make it
5711 possible to have these listen on a separate port number.
5713 @item debugPassword
5714 Must match the value of @code{c['debugPassword']}, used to protect the
5715 debug port, for the @command{debugclient} command.
5717 @item username
5718 Provides a default username for the @command{sendchange} command.
5720 @end table
5723 The following options are used by the @code{buildbot try} command
5724 (@pxref{try}):
5726 @table @code
5727 @item try_connect
5728 This specifies how the ``try'' command should deliver its request to
5729 the buildmaster. The currently accepted values are ``ssh'' and ``pb''.
5730 @item try_builders
5731 Which builders should be used for the ``try'' build.
5732 @item try_vc
5733 This specifies the version control system being used.
5734 @item try_branch
5735 This indicates that the current tree is on a non-trunk branch.
5736 @item try_topdir
5737 @item try_topfile
5738 Use @code{try_topdir} to explicitly indicate the top of your working
5739 tree, or @code{try_topfile} to name a file that will only be found in
5740 that top-most directory.
5742 @item try_host
5743 @item try_username
5744 @item try_dir
5745 When try_connect is ``ssh'', the command will pay attention to
5746 @code{try_host}, @code{try_username}, and @code{try_dir}.
5748 @item try_username
5749 @item try_password
5750 @item try_master
5751 Instead, when @code{try_connect} is ``pb'', the command will pay
5752 attention to @code{try_username}, @code{try_password}, and
5753 @code{try_master}.
5755 @item try_wait
5756 @item masterstatus
5757 @code{try_wait} and @code{masterstatus} are used to ask the ``try''
5758 command to wait for the requested build to complete.
5760 @end table
5764 @node Resources, Developer's Appendix, Command-line tool, Top
5765 @chapter Resources
5767 The Buildbot's home page is at @uref{http://buildbot.sourceforge.net/}
5769 For configuration questions and general discussion, please use the
5770 @code{buildbot-devel} mailing list. The subscription instructions and
5771 archives are available at
5772 @uref{http://lists.sourceforge.net/lists/listinfo/buildbot-devel}
5774 @node Developer's Appendix, Index of Useful Classes, Resources, Top
5775 @unnumbered Developer's Appendix
5777 This appendix contains random notes about the implementation of the
5778 Buildbot, and is likely to only be of use to people intending to
5779 extend the Buildbot's internals.
5781 The buildmaster consists of a tree of Service objects, which is shaped
5782 as follows:
5784 @example
5785 BuildMaster
5786  ChangeMaster  (in .change_svc)
5787   [IChangeSource instances]
5788  [IScheduler instances]  (in .schedulers)
5789  BotMaster  (in .botmaster)
5790  [IStatusTarget instances]  (in .statusTargets)
5791 @end example
5793 The BotMaster has a collection of Builder objects as values of its
5794 @code{.builders} dictionary.
5797 @node Index of Useful Classes, Index of master.cfg keys, Developer's Appendix, Top
5798 @unnumbered Index of Useful Classes
5800 This is a list of all user-visible classes. There are the ones that
5801 are useful in @file{master.cfg}, the buildmaster's configuration file.
5802 Classes that are not listed here are generally internal things that
5803 admins are unlikely to have much use for.
5806 @heading Change Sources
5807 @printindex cs
5809 @heading Schedulers and Locks
5810 @printindex sl
5812 @heading Build Factories
5813 @printindex bf
5815 @heading Build Steps
5816 @printindex bs
5818 @c undocumented steps
5819 @bsindex buildbot.steps.source.Git
5820 @bsindex buildbot.steps.maxq.MaxQ
5823 @heading Status Targets
5824 @printindex st
5826 @c TODO: undocumented targets
5827 @stindex buildbot.status.mail.MailNotifier
5829 @node Index of master.cfg keys, Index, Index of Useful Classes, Top
5830 @unnumbered Index of master.cfg keys
5832 This is a list of all of the significant keys in master.cfg . Recall
5833 that master.cfg is effectively a small python program one
5834 responsibility: create a dictionary named @code{BuildmasterConfig}.
5835 The keys of this dictionary are listed here. The beginning of the
5836 master.cfg file typically starts with something like:
5838 @example
5839 BuildmasterConfig = c = @{@}
5840 @end example
5842 Therefore a config key of @code{sources} will usually appear in
5843 master.cfg as @code{c['sources']}.
5845 @printindex bc
5848 @node Index,  , Index of master.cfg keys, Top
5849 @unnumbered Index
5851 @printindex cp
5854 @bye