add max_builds= to BuildSlave, thanks to Dustin Mitchell. Closes #48.
[buildbot.git] / docs / buildbot.texinfo
blobaee901f37e64e9252308fc7917e3e09c1b6bb1d4
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename buildbot.info
4 @settitle BuildBot Manual 0.7.5+
5 @defcodeindex cs
6 @defcodeindex sl
7 @defcodeindex bf
8 @defcodeindex bs
9 @defcodeindex st
10 @defcodeindex bc
11 @c %**end of header
13 @c these indices are for classes useful in a master.cfg config file
14 @c @csindex : Change Sources
15 @c @slindex : Schedulers and Locks
16 @c @bfindex : Build Factories
17 @c @bsindex : Build Steps
18 @c @stindex : Status Targets
20 @c @bcindex : keys that make up BuildmasterConfig
22 @copying
23 This is the BuildBot manual.
25 Copyright (C) 2005,2006 Brian Warner
27 Copying and distribution of this file, with or without
28 modification, are permitted in any medium without royalty
29 provided the copyright notice and this notice are preserved.
31 @end copying
33 @titlepage
34 @title BuildBot
35 @page
36 @vskip 0pt plus 1filll
37 @insertcopying
38 @end titlepage
40 @c Output the table of the contents at the beginning.
41 @contents
43 @ifnottex
44 @node Top, Introduction, (dir), (dir)
45 @top BuildBot
47 @insertcopying
48 @end ifnottex
50 @menu
51 * Introduction::                What the BuildBot does.
52 * Installation::                Creating a buildmaster and buildslaves,
53                                 running them.
54 * Concepts::                    What goes on in the buildbot's little mind.
55 * Configuration::               Controlling the buildbot.
56 * Getting Source Code Changes::  Discovering when to run a build.
57 * Build Process::               Controlling how each build is run.
58 * Status Delivery::             Telling the world about the build's results.
59 * Command-line tool::           
60 * Resources::                   Getting help.
61 * Developer's Appendix::        
62 * Index of Useful Classes::     
63 * Index of master.cfg keys::    
64 * Index::                       Complete index.
66 @detailmenu
67  --- The Detailed Node Listing ---
69 Introduction
71 * History and Philosophy::      
72 * System Architecture::         
73 * Control Flow::                
75 System Architecture
77 * BuildSlave Connections::      
78 * Buildmaster Architecture::    
79 * Status Delivery Architecture::  
81 Installation
83 * Requirements::                
84 * Installing the code::         
85 * Creating a buildmaster::      
86 * Creating a buildslave::       
87 * Launching the daemons::       
88 * Logfiles::                    
89 * Shutdown::                    
90 * Maintenance::                 
91 * Troubleshooting::             
93 Creating a buildslave
95 * Buildslave Options::          
97 Troubleshooting
99 * Starting the buildslave::     
100 * Connecting to the buildmaster::  
101 * Forcing Builds::              
103 Concepts
105 * Version Control Systems::     
106 * Schedulers::                  
107 * BuildSet::                    
108 * BuildRequest::                
109 * Builder::                     
110 * Users::                       
112 Version Control Systems
114 * Generalizing VC Systems::     
115 * Source Tree Specifications::  
116 * How Different VC Systems Specify Sources::  
117 * Attributes of Changes::       
119 Users
121 * Doing Things With Users::     
122 * Email Addresses::             
123 * IRC Nicknames::               
124 * Live Status Clients::         
126 Configuration
128 * Config File Format::          
129 * Loading the Config File::     
130 * Defining the Project::        
131 * Listing Change Sources and Schedulers::  
132 * Setting the slaveport::       
133 * Buildslave Specifiers::       
134 * Defining Builders::           
135 * Defining Status Targets::     
136 * Debug options::               
138 Listing Change Sources and Schedulers
140 * Scheduler Types::             
141 * Build Dependencies::          
143 Getting Source Code Changes
145 * Change Sources::              
146 * Choosing ChangeSources::      
147 * CVSToys - PBService::         
148 * Mail-parsing ChangeSources::  
149 * PBChangeSource::              
150 * P4Source::                    
151 * BonsaiPoller::                
152 * SVNPoller::                   
153 * MercurialHook::               
155 Mail-parsing ChangeSources
157 * Subscribing the Buildmaster::  
158 * Using Maildirs::              
159 * Parsing Email Change Messages::  
161 Parsing Email Change Messages
163 * FCMaildirSource::             
164 * SyncmailMaildirSource::       
165 * BonsaiMaildirSource::         
166 * SVNCommitEmailMaildirSource::  
168 Build Process
170 * Build Steps::                 
171 * Interlocks::                  
172 * Build Factories::             
174 Build Steps
176 * Common Parameters::           
177 * Source Checkout::             
178 * ShellCommand::                
179 * Simple ShellCommand Subclasses::  
180 * Python BuildSteps::           
181 * Transferring Files::          
182 * Writing New BuildSteps::      
184 Source Checkout
186 * CVS::                         
187 * SVN::                         
188 * Darcs::                       
189 * Mercurial::                   
190 * Arch::                        
191 * Bazaar::                      
192 * Bzr::                         
193 * P4::                          
195 Simple ShellCommand Subclasses
197 * Configure::                   
198 * Compile::                     
199 * Test::                        
200 * Build Properties::            
202 Python BuildSteps
204 * BuildEPYDoc::                 
205 * PyFlakes::                    
207 Writing New BuildSteps
209 * BuildStep LogFiles::          
210 * Reading Logfiles::            
211 * Adding LogObservers::         
212 * BuildStep URLs::              
214 Build Factories
216 * BuildStep Objects::           
217 * BuildFactory::                
218 * Process-Specific build factories::  
220 BuildStep Objects
222 * BuildFactory Attributes::     
223 * Quick builds::                
225 BuildFactory
227 * BuildFactory Attributes::     
228 * Quick builds::                
230 Process-Specific build factories
232 * GNUAutoconf::                 
233 * CPAN::                        
234 * Python distutils::            
235 * Python/Twisted/trial projects::  
237 Status Delivery
239 * HTML Waterfall::              
240 * WebStatus::                   
241 * IRC Bot::                     
242 * PBListener::                  
243 * Writing New Status Plugins::  
245 WebStatus
247 * Buildbot Web Resources::      
248 * XMLRPC server::               
250 Command-line tool
252 * Administrator Tools::         
253 * Developer Tools::             
254 * Other Tools::                 
255 * .buildbot config directory::  
257 Developer Tools
259 * statuslog::                   
260 * statusgui::                   
261 * try::                         
263 waiting for results
265 * try --diff::                  
267 Other Tools
269 * sendchange::                  
270 * debugclient::                 
272 @end detailmenu
273 @end menu
275 @node Introduction, Installation, Top, Top
276 @chapter Introduction
278 @cindex introduction
280 The BuildBot is a system to automate the compile/test cycle required by most
281 software projects to validate code changes. By automatically rebuilding and
282 testing the tree each time something has changed, build problems are
283 pinpointed quickly, before other developers are inconvenienced by the
284 failure. The guilty developer can be identified and harassed without human
285 intervention. By running the builds on a variety of platforms, developers
286 who do not have the facilities to test their changes everywhere before
287 checkin will at least know shortly afterwards whether they have broken the
288 build or not. Warning counts, lint checks, image size, compile time, and
289 other build parameters can be tracked over time, are more visible, and
290 are therefore easier to improve.
292 The overall goal is to reduce tree breakage and provide a platform to
293 run tests or code-quality checks that are too annoying or pedantic for
294 any human to waste their time with. Developers get immediate (and
295 potentially public) feedback about their changes, encouraging them to
296 be more careful about testing before checkin.
298 Features:
300 @itemize @bullet
301 @item
302 run builds on a variety of slave platforms
303 @item
304 arbitrary build process: handles projects using C, Python, whatever
305 @item
306 minimal host requirements: python and Twisted
307 @item
308 slaves can be behind a firewall if they can still do checkout
309 @item
310 status delivery through web page, email, IRC, other protocols
311 @item
312 track builds in progress, provide estimated completion time
313 @item
314 flexible configuration by subclassing generic build process classes
315 @item
316 debug tools to force a new build, submit fake Changes, query slave status
317 @item
318 released under the GPL
319 @end itemize
321 @menu
322 * History and Philosophy::      
323 * System Architecture::         
324 * Control Flow::                
325 @end menu
328 @node History and Philosophy, System Architecture, Introduction, Introduction
329 @section History and Philosophy
331 @cindex Philosophy of operation
333 The Buildbot was inspired by a similar project built for a development
334 team writing a cross-platform embedded system. The various components
335 of the project were supposed to compile and run on several flavors of
336 unix (linux, solaris, BSD), but individual developers had their own
337 preferences and tended to stick to a single platform. From time to
338 time, incompatibilities would sneak in (some unix platforms want to
339 use @code{string.h}, some prefer @code{strings.h}), and then the tree
340 would compile for some developers but not others. The buildbot was
341 written to automate the human process of walking into the office,
342 updating a tree, compiling (and discovering the breakage), finding the
343 developer at fault, and complaining to them about the problem they had
344 introduced. With multiple platforms it was difficult for developers to
345 do the right thing (compile their potential change on all platforms);
346 the buildbot offered a way to help.
348 Another problem was when programmers would change the behavior of a
349 library without warning its users, or change internal aspects that
350 other code was (unfortunately) depending upon. Adding unit tests to
351 the codebase helps here: if an application's unit tests pass despite
352 changes in the libraries it uses, you can have more confidence that
353 the library changes haven't broken anything. Many developers
354 complained that the unit tests were inconvenient or took too long to
355 run: having the buildbot run them reduces the developer's workload to
356 a minimum.
358 In general, having more visibility into the project is always good,
359 and automation makes it easier for developers to do the right thing.
360 When everyone can see the status of the project, developers are
361 encouraged to keep the tree in good working order. Unit tests that
362 aren't run on a regular basis tend to suffer from bitrot just like
363 code does: exercising them on a regular basis helps to keep them
364 functioning and useful.
366 The current version of the Buildbot is additionally targeted at
367 distributed free-software projects, where resources and platforms are
368 only available when provided by interested volunteers. The buildslaves
369 are designed to require an absolute minimum of configuration, reducing
370 the effort a potential volunteer needs to expend to be able to
371 contribute a new test environment to the project. The goal is for
372 anyone who wishes that a given project would run on their favorite
373 platform should be able to offer that project a buildslave, running on
374 that platform, where they can verify that their portability code
375 works, and keeps working.
377 @node System Architecture, Control Flow, History and Philosophy, Introduction
378 @comment  node-name,  next,  previous,  up
379 @section System Architecture
381 The Buildbot consists of a single @code{buildmaster} and one or more
382 @code{buildslaves}, connected in a star topology. The buildmaster
383 makes all decisions about what, when, and how to build. It sends
384 commands to be run on the build slaves, which simply execute the
385 commands and return the results. (certain steps involve more local
386 decision making, where the overhead of sending a lot of commands back
387 and forth would be inappropriate, but in general the buildmaster is
388 responsible for everything).
390 The buildmaster is usually fed @code{Changes} by some sort of version
391 control system (@pxref{Change Sources}), which may cause builds to be
392 run. As the builds are performed, various status messages are
393 produced, which are then sent to any registered Status Targets
394 (@pxref{Status Delivery}).
396 @c @image{FILENAME, WIDTH, HEIGHT, ALTTEXT, EXTENSION}
397 @image{images/overview,,,Overview Diagram,}
399 The buildmaster is configured and maintained by the ``buildmaster
400 admin'', who is generally the project team member responsible for
401 build process issues. Each buildslave is maintained by a ``buildslave
402 admin'', who do not need to be quite as involved. Generally slaves are
403 run by anyone who has an interest in seeing the project work well on
404 their favorite platform.
406 @menu
407 * BuildSlave Connections::      
408 * Buildmaster Architecture::    
409 * Status Delivery Architecture::  
410 @end menu
412 @node BuildSlave Connections, Buildmaster Architecture, System Architecture, System Architecture
413 @subsection BuildSlave Connections
415 The buildslaves are typically run on a variety of separate machines,
416 at least one per platform of interest. These machines connect to the
417 buildmaster over a TCP connection to a publically-visible port. As a
418 result, the buildslaves can live behind a NAT box or similar
419 firewalls, as long as they can get to buildmaster. The TCP connections
420 are initiated by the buildslave and accepted by the buildmaster, but
421 commands and results travel both ways within this connection. The
422 buildmaster is always in charge, so all commands travel exclusively
423 from the buildmaster to the buildslave.
425 To perform builds, the buildslaves must typically obtain source code
426 from a CVS/SVN/etc repository. Therefore they must also be able to
427 reach the repository. The buildmaster provides instructions for
428 performing builds, but does not provide the source code itself.
430 @image{images/slaves,,,BuildSlave Connections,}
432 @node Buildmaster Architecture, Status Delivery Architecture, BuildSlave Connections, System Architecture
433 @subsection Buildmaster Architecture
435 The Buildmaster consists of several pieces:
437 @image{images/master,,,BuildMaster Architecture,}
439 @itemize @bullet
441 @item
442 Change Sources, which create a Change object each time something is
443 modified in the VC repository. Most ChangeSources listen for messages
444 from a hook script of some sort. Some sources actively poll the
445 repository on a regular basis. All Changes are fed to the Schedulers.
447 @item
448 Schedulers, which decide when builds should be performed. They collect
449 Changes into BuildRequests, which are then queued for delivery to
450 Builders until a buildslave is available.
452 @item
453 Builders, which control exactly @emph{how} each build is performed
454 (with a series of BuildSteps, configured in a BuildFactory). Each
455 Build is run on a single buildslave.
457 @item
458 Status plugins, which deliver information about the build results
459 through protocols like HTTP, mail, and IRC.
461 @end itemize
463 @image{images/slavebuilder,,,SlaveBuilders,}
465 Each Builder is configured with a list of BuildSlaves that it will use
466 for its builds. These buildslaves are expected to behave identically:
467 the only reason to use multiple BuildSlaves for a single Builder is to
468 provide a measure of load-balancing.
470 Within a single BuildSlave, each Builder creates its own SlaveBuilder
471 instance. These SlaveBuilders operate independently from each other.
472 Each gets its own base directory to work in. It is quite common to
473 have many Builders sharing the same buildslave. For example, there
474 might be two buildslaves: one for i386, and a second for PowerPC.
475 There may then be a pair of Builders that do a full compile/test run,
476 one for each architecture, and a lone Builder that creates snapshot
477 source tarballs if the full builders complete successfully. The full
478 builders would each run on a single buildslave, whereas the tarball
479 creation step might run on either buildslave (since the platform
480 doesn't matter when creating source tarballs). In this case, the
481 mapping would look like:
483 @example
484 Builder(full-i386)  ->  BuildSlaves(slave-i386)
485 Builder(full-ppc)   ->  BuildSlaves(slave-ppc)
486 Builder(source-tarball) -> BuildSlaves(slave-i386, slave-ppc)
487 @end example
489 and each BuildSlave would have two SlaveBuilders inside it, one for a
490 full builder, and a second for the source-tarball builder.
492 Once a SlaveBuilder is available, the Builder pulls one or more
493 BuildRequests off its incoming queue. (It may pull more than one if it
494 determines that it can merge the requests together; for example, there
495 may be multiple requests to build the current HEAD revision). These
496 requests are merged into a single Build instance, which includes the
497 SourceStamp that describes what exact version of the source code
498 should be used for the build. The Build is then randomly assigned to a
499 free SlaveBuilder and the build begins.
502 @node Status Delivery Architecture,  , Buildmaster Architecture, System Architecture
503 @subsection Status Delivery Architecture
505 The buildmaster maintains a central Status object, to which various
506 status plugins are connected. Through this Status object, a full
507 hierarchy of build status objects can be obtained.
509 @image{images/status,,,Status Delivery,}
511 The configuration file controls which status plugins are active. Each
512 status plugin gets a reference to the top-level Status object. From
513 there they can request information on each Builder, Build, Step, and
514 LogFile. This query-on-demand interface is used by the html.Waterfall
515 plugin to create the main status page each time a web browser hits the
516 main URL.
518 The status plugins can also subscribe to hear about new Builds as they
519 occur: this is used by the MailNotifier to create new email messages
520 for each recently-completed Build.
522 The Status object records the status of old builds on disk in the
523 buildmaster's base directory. This allows it to return information
524 about historical builds.
526 There are also status objects that correspond to Schedulers and
527 BuildSlaves. These allow status plugins to report information about
528 upcoming builds, and the online/offline status of each buildslave.
531 @node Control Flow,  , System Architecture, Introduction
532 @comment  node-name,  next,  previous,  up
533 @section Control Flow
535 A day in the life of the buildbot:
537 @itemize @bullet
539 @item
540 A developer commits some source code changes to the repository. A hook
541 script or commit trigger of some sort sends information about this
542 change to the buildmaster through one of its configured Change
543 Sources. This notification might arrive via email, or over a network
544 connection (either initiated by the buildmaster as it ``subscribes''
545 to changes, or by the commit trigger as it pushes Changes towards the
546 buildmaster). The Change contains information about who made the
547 change, what files were modified, which revision contains the change,
548 and any checkin comments.
550 @item
551 The buildmaster distributes this change to all of its configured
552 Schedulers. Any ``important'' changes cause the ``tree-stable-timer''
553 to be started, and the Change is added to a list of those that will go
554 into a new Build. When the timer expires, a Build is started on each
555 of a set of configured Builders, all compiling/testing the same source
556 code. Unless configured otherwise, all Builds run in parallel on the
557 various buildslaves.
559 @item
560 The Build consists of a series of Steps. Each Step causes some number
561 of commands to be invoked on the remote buildslave associated with
562 that Builder. The first step is almost always to perform a checkout of
563 the appropriate revision from the same VC system that produced the
564 Change. The rest generally perform a compile and run unit tests. As
565 each Step runs, the buildslave reports back command output and return
566 status to the buildmaster.
568 @item
569 As the Build runs, status messages like ``Build Started'', ``Step
570 Started'', ``Build Finished'', etc, are published to a collection of
571 Status Targets. One of these targets is usually the HTML ``Waterfall''
572 display, which shows a chronological list of events, and summarizes
573 the results of the most recent build at the top of each column.
574 Developers can periodically check this page to see how their changes
575 have fared. If they see red, they know that they've made a mistake and
576 need to fix it. If they see green, they know that they've done their
577 duty and don't need to worry about their change breaking anything.
579 @item
580 If a MailNotifier status target is active, the completion of a build
581 will cause email to be sent to any developers whose Changes were
582 incorporated into this Build. The MailNotifier can be configured to
583 only send mail upon failing builds, or for builds which have just
584 transitioned from passing to failing. Other status targets can provide
585 similar real-time notification via different communication channels,
586 like IRC.
588 @end itemize
591 @node Installation, Concepts, Introduction, Top
592 @chapter Installation
594 @menu
595 * Requirements::                
596 * Installing the code::         
597 * Creating a buildmaster::      
598 * Creating a buildslave::       
599 * Launching the daemons::       
600 * Logfiles::                    
601 * Shutdown::                    
602 * Maintenance::                 
603 * Troubleshooting::             
604 @end menu
606 @node Requirements, Installing the code, Installation, Installation
607 @section Requirements
609 At a bare minimum, you'll need the following (for both the buildmaster
610 and a buildslave):
612 @itemize @bullet
613 @item
614 Python: http://www.python.org
616 Buildbot requires python-2.3 or later, and is primarily developed
617 against python-2.4. It is also tested against python-2.5 .
619 @item
620 Twisted: http://twistedmatrix.com
622 Both the buildmaster and the buildslaves require Twisted-2.0.x or
623 later. It has been tested against all releases of Twisted up to
624 Twisted-2.5.0 (the most recent as of this writing). As always, the
625 most recent version is recommended.
627 Twisted is delivered as a collection of subpackages. You'll need at
628 least "Twisted" (the core package), and you'll also want TwistedMail,
629 TwistedWeb, and TwistedWords (for sending email, serving a web status
630 page, and delivering build status via IRC, respectively). You might
631 also want TwistedConch (for the encrypted Manhole debug port). Note
632 that Twisted requires ZopeInterface to be installed as well.
634 @end itemize
636 Certain other packages may be useful on the system running the
637 buildmaster:
639 @itemize @bullet
640 @item
641 CVSToys: http://purl.net/net/CVSToys
643 If your buildmaster uses FreshCVSSource to receive change notification
644 from a cvstoys daemon, it will require CVSToys be installed (tested
645 with CVSToys-1.0.10). If the it doesn't use that source (i.e. if you
646 only use a mail-parsing change source, or the SVN notification
647 script), you will not need CVSToys.
649 @end itemize
651 And of course, your project's build process will impose additional
652 requirements on the buildslaves. These hosts must have all the tools
653 necessary to compile and test your project's source code.
656 @node Installing the code, Creating a buildmaster, Requirements, Installation
657 @section Installing the code
659 @cindex installation
661 The Buildbot is installed using the standard python @code{distutils}
662 module. After unpacking the tarball, the process is:
664 @example
665 python setup.py build
666 python setup.py install
667 @end example
669 where the install step may need to be done as root. This will put the
670 bulk of the code in somewhere like
671 /usr/lib/python2.3/site-packages/buildbot . It will also install the
672 @code{buildbot} command-line tool in /usr/bin/buildbot.
674 To test this, shift to a different directory (like /tmp), and run:
676 @example
677 buildbot --version
678 @end example
680 If it shows you the versions of Buildbot and Twisted, the install went
681 ok. If it says @code{no such command} or it gets an @code{ImportError}
682 when it tries to load the libaries, then something went wrong.
683 @code{pydoc buildbot} is another useful diagnostic tool.
685 Windows users will find these files in other places. You will need to
686 make sure that python can find the libraries, and will probably find
687 it convenient to have @code{buildbot} on your PATH.
689 If you wish, you can run the buildbot unit test suite like this:
691 @example
692 PYTHONPATH=. trial buildbot.test
693 @end example
695 This should run up to 192 tests, depending upon what VC tools you have
696 installed. On my desktop machine it takes about five minutes to
697 complete. Nothing should fail, a few might be skipped. If any of the
698 tests fail, you should stop and investigate the cause before
699 continuing the installation process, as it will probably be easier to
700 track down the bug early.
702 If you cannot or do not wish to install the buildbot into a site-wide
703 location like @file{/usr} or @file{/usr/local}, you can also install
704 it into the account's home directory. Do the install command like
705 this:
707 @example
708 python setup.py install --home=~
709 @end example
711 That will populate @file{~/lib/python} and create
712 @file{~/bin/buildbot}. Make sure this lib directory is on your
713 @code{PYTHONPATH}.
716 @node Creating a buildmaster, Creating a buildslave, Installing the code, Installation
717 @section Creating a buildmaster
719 As you learned earlier (@pxref{System Architecture}), the buildmaster
720 runs on a central host (usually one that is publically visible, so
721 everybody can check on the status of the project), and controls all
722 aspects of the buildbot system. Let us call this host
723 @code{buildbot.example.org}.
725 You may wish to create a separate user account for the buildmaster,
726 perhaps named @code{buildmaster}. This can help keep your personal
727 configuration distinct from that of the buildmaster and is useful if
728 you have to use a mail-based notification system (@pxref{Change
729 Sources}). However, the Buildbot will work just fine with your regular
730 user account.
732 You need to choose a directory for the buildmaster, called the
733 @code{basedir}. This directory will be owned by the buildmaster, which
734 will use configuration files therein, and create status files as it
735 runs. @file{~/Buildbot} is a likely value. If you run multiple
736 buildmasters in the same account, or if you run both masters and
737 slaves, you may want a more distinctive name like
738 @file{~/Buildbot/master/gnomovision} or
739 @file{~/Buildmasters/fooproject}. If you are using a separate user
740 account, this might just be @file{~buildmaster/masters/fooproject}.
742 Once you've picked a directory, use the @command{buildbot
743 create-master} command to create the directory and populate it with
744 startup files:
746 @example
747 buildbot create-master @var{basedir}
748 @end example
750 You will need to create a configuration file (@pxref{Configuration})
751 before starting the buildmaster. Most of the rest of this manual is
752 dedicated to explaining how to do this. A sample configuration file is
753 placed in the working directory, named @file{master.cfg.sample}, which
754 can be copied to @file{master.cfg} and edited to suit your purposes.
756 (Internal details: This command creates a file named
757 @file{buildbot.tac} that contains all the state necessary to create
758 the buildmaster. Twisted has a tool called @code{twistd} which can use
759 this .tac file to create and launch a buildmaster instance. twistd
760 takes care of logging and daemonization (running the program in the
761 background). @file{/usr/bin/buildbot} is a front end which runs twistd
762 for you.)
764 In addition to @file{buildbot.tac}, a small @file{Makefile.sample} is
765 installed. This can be used as the basis for customized daemon startup,
766 @xref{Launching the daemons}.
769 @node Creating a buildslave, Launching the daemons, Creating a buildmaster, Installation
770 @section Creating a buildslave
772 Typically, you will be adding a buildslave to an existing buildmaster,
773 to provide additional architecture coverage. The buildbot
774 administrator will give you several pieces of information necessary to
775 connect to the buildmaster. You should also be somewhat familiar with
776 the project being tested, so you can troubleshoot build problems
777 locally.
779 The buildbot exists to make sure that the project's stated ``how to
780 build it'' process actually works. To this end, the buildslave should
781 run in an environment just like that of your regular developers.
782 Typically the project build process is documented somewhere
783 (@file{README}, @file{INSTALL}, etc), in a document that should
784 mention all library dependencies and contain a basic set of build
785 instructions. This document will be useful as you configure the host
786 and account in which the buildslave runs.
788 Here's a good checklist for setting up a buildslave:
790 @enumerate
791 @item
792 Set up the account
794 It is recommended (although not mandatory) to set up a separate user
795 account for the buildslave. This account is frequently named
796 @code{buildbot} or @code{buildslave}. This serves to isolate your
797 personal working environment from that of the slave's, and helps to
798 minimize the security threat posed by letting possibly-unknown
799 contributors run arbitrary code on your system. The account should
800 have a minimum of fancy init scripts.
802 @item
803 Install the buildbot code
805 Follow the instructions given earlier (@pxref{Installing the code}).
806 If you use a separate buildslave account, and you didn't install the
807 buildbot code to a shared location, then you will need to install it
808 with @code{--home=~} for each account that needs it.
810 @item
811 Set up the host
813 Make sure the host can actually reach the buildmaster. Usually the
814 buildmaster is running a status webserver on the same machine, so
815 simply point your web browser at it and see if you can get there.
816 Install whatever additional packages or libraries the project's
817 INSTALL document advises. (or not: if your buildslave is supposed to
818 make sure that building without optional libraries still works, then
819 don't install those libraries).
821 Again, these libraries don't necessarily have to be installed to a
822 site-wide shared location, but they must be available to your build
823 process. Accomplishing this is usually very specific to the build
824 process, so installing them to @file{/usr} or @file{/usr/local} is
825 usually the best approach.
827 @item
828 Test the build process
830 Follow the instructions in the INSTALL document, in the buildslave's
831 account. Perform a full CVS (or whatever) checkout, configure, make,
832 run tests, etc. Confirm that the build works without manual fussing.
833 If it doesn't work when you do it by hand, it will be unlikely to work
834 when the buildbot attempts to do it in an automated fashion.
836 @item
837 Choose a base directory
839 This should be somewhere in the buildslave's account, typically named
840 after the project which is being tested. The buildslave will not touch
841 any file outside of this directory. Something like @file{~/Buildbot}
842 or @file{~/Buildslaves/fooproject} is appropriate.
844 @item
845 Get the buildmaster host/port, botname, and password
847 When the buildbot admin configures the buildmaster to accept and use
848 your buildslave, they will provide you with the following pieces of
849 information:
851 @itemize @bullet
852 @item
853 your buildslave's name
854 @item
855 the password assigned to your buildslave
856 @item
857 the hostname and port number of the buildmaster, i.e. buildbot.example.org:8007
858 @end itemize
860 @item
861 Create the buildslave
863 Now run the 'buildbot' command as follows:
865 @example
866 buildbot create-slave @var{BASEDIR} @var{MASTERHOST}:@var{PORT} @var{SLAVENAME} @var{PASSWORD}
867 @end example
869 This will create the base directory and a collection of files inside,
870 including the @file{buildbot.tac} file that contains all the
871 information you passed to the @code{buildbot} command.
873 @item
874 Fill in the hostinfo files
876 When it first connects, the buildslave will send a few files up to the
877 buildmaster which describe the host that it is running on. These files
878 are presented on the web status display so that developers have more
879 information to reproduce any test failures that are witnessed by the
880 buildbot. There are sample files in the @file{info} subdirectory of
881 the buildbot's base directory. You should edit these to correctly
882 describe you and your host.
884 @file{BASEDIR/info/admin} should contain your name and email address.
885 This is the ``buildslave admin address'', and will be visible from the
886 build status page (so you may wish to munge it a bit if
887 address-harvesting spambots are a concern).
889 @file{BASEDIR/info/host} should be filled with a brief description of
890 the host: OS, version, memory size, CPU speed, versions of relevant
891 libraries installed, and finally the version of the buildbot code
892 which is running the buildslave.
894 If you run many buildslaves, you may want to create a single
895 @file{~buildslave/info} file and share it among all the buildslaves
896 with symlinks.
898 @end enumerate
900 @menu
901 * Buildslave Options::          
902 @end menu
904 @node Buildslave Options,  , Creating a buildslave, Creating a buildslave
905 @subsection Buildslave Options
907 There are a handful of options you might want to use when creating the
908 buildslave with the @command{buildbot create-slave <options> DIR <params>}
909 command. You can type @command{buildbot create-slave --help} for a summary.
910 To use these, just include them on the @command{buildbot create-slave}
911 command line, like this:
913 @example
914 buildbot create-slave --umask=022 ~/buildslave buildmaster.example.org:42012 myslavename mypasswd
915 @end example
917 @table @code
918 @item --usepty
919 This is a boolean flag that tells the buildslave whether to launch
920 child processes in a PTY (the default) or with regular pipes. The
921 advantage of using a PTY is that ``grandchild'' processes are more
922 likely to be cleaned up if the build is interrupted or times out
923 (since it enables the use of a ``process group'' in which all child
924 processes will be placed). The disadvantages: some forms of Unix have
925 problems with PTYs, some of your unit tests may behave differently
926 when run under a PTY (generally those which check to see if they are
927 being run interactively), and PTYs will merge the stdout and stderr
928 streams into a single output stream (which means the red-vs-black
929 coloring in the logfiles will be lost). If you encounter problems, you
930 can add @code{--usepty=0} to disable the use of PTYs. Note that
931 windows buildslaves never use PTYs.
933 @item --umask
934 This is a string (generally an octal representation of an integer)
935 which will cause the buildslave process' ``umask'' value to be set
936 shortly after initialization. The ``twistd'' daemonization utility
937 forces the umask to 077 at startup (which means that all files created
938 by the buildslave or its child processes will be unreadable by any
939 user other than the buildslave account). If you want build products to
940 be readable by other accounts, you can add @code{--umask=022} to tell
941 the buildslave to fix the umask after twistd clobbers it. If you want
942 build products to be @emph{writable} by other accounts too, use
943 @code{--umask=000}, but this is likely to be a security problem.
945 @item --keepalive
946 This is a number that indicates how frequently ``keepalive'' messages
947 should be sent from the buildslave to the buildmaster, expressed in
948 seconds. The default (600) causes a message to be sent to the
949 buildmaster at least once every 10 minutes. To set this to a lower
950 value, use e.g. @code{--keepalive=120}.
952 If the buildslave is behind a NAT box or stateful firewall, these
953 messages may help to keep the connection alive: some NAT boxes tend to
954 forget about a connection if it has not been used in a while. When
955 this happens, the buildmaster will think that the buildslave has
956 disappeared, and builds will time out. Meanwhile the buildslave will
957 not realize than anything is wrong.
959 @end table
962 @node Launching the daemons, Logfiles, Creating a buildslave, Installation
963 @section Launching the daemons
965 Both the buildmaster and the buildslave run as daemon programs. To
966 launch them, pass the working directory to the @code{buildbot}
967 command:
969 @example
970 buildbot start @var{BASEDIR}
971 @end example
973 This command will start the daemon and then return, so normally it
974 will not produce any output. To verify that the programs are indeed
975 running, look for a pair of files named @file{twistd.log} and
976 @file{twistd.pid} that should be created in the working directory.
977 @file{twistd.pid} contains the process ID of the newly-spawned daemon.
979 When the buildslave connects to the buildmaster, new directories will
980 start appearing in its base directory. The buildmaster tells the slave
981 to create a directory for each Builder which will be using that slave.
982 All build operations are performed within these directories: CVS
983 checkouts, compiles, and tests.
985 Once you get everything running, you will want to arrange for the
986 buildbot daemons to be started at boot time. One way is to use
987 @code{cron}, by putting them in a @@reboot crontab entry@footnote{this
988 @@reboot syntax is understood by Vixie cron, which is the flavor
989 usually provided with linux systems. Other unices may have a cron that
990 doesn't understand @@reboot}:
992 @example
993 @@reboot buildbot start @var{BASEDIR}
994 @end example
996 When you run @command{crontab} to set this up, remember to do it as
997 the buildmaster or buildslave account! If you add this to your crontab
998 when running as your regular account (or worse yet, root), then the
999 daemon will run as the wrong user, quite possibly as one with more
1000 authority than you intended to provide.
1002 It is important to remember that the environment provided to cron jobs
1003 and init scripts can be quite different that your normal runtime.
1004 There may be fewer environment variables specified, and the PATH may
1005 be shorter than usual. It is a good idea to test out this method of
1006 launching the buildslave by using a cron job with a time in the near
1007 future, with the same command, and then check @file{twistd.log} to
1008 make sure the slave actually started correctly. Common problems here
1009 are for @file{/usr/local} or @file{~/bin} to not be on your
1010 @code{PATH}, or for @code{PYTHONPATH} to not be set correctly.
1011 Sometimes @code{HOME} is messed up too.
1013 To modify the way the daemons are started (perhaps you want to set
1014 some environment variables first, or perform some cleanup each time),
1015 you can create a file named @file{Makefile.buildbot} in the base
1016 directory. When the @file{buildbot} front-end tool is told to
1017 @command{start} the daemon, and it sees this file (and
1018 @file{/usr/bin/make} exists), it will do @command{make -f
1019 Makefile.buildbot start} instead of its usual action (which involves
1020 running @command{twistd}). When the buildmaster or buildslave is
1021 installed, a @file{Makefile.sample} is created which implements the
1022 same behavior as the the @file{buildbot} tool uses, so if you want to
1023 customize the process, just copy @file{Makefile.sample} to
1024 @file{Makefile.buildbot} and edit it as necessary.
1026 @node Logfiles, Shutdown, Launching the daemons, Installation
1027 @section Logfiles
1029 @cindex logfiles
1031 While a buildbot daemon runs, it emits text to a logfile, named
1032 @file{twistd.log}. A command like @code{tail -f twistd.log} is useful
1033 to watch the command output as it runs.
1035 The buildmaster will announce any errors with its configuration file
1036 in the logfile, so it is a good idea to look at the log at startup
1037 time to check for any problems. Most buildmaster activities will cause
1038 lines to be added to the log.
1040 @node Shutdown, Maintenance, Logfiles, Installation
1041 @section Shutdown
1043 To stop a buildmaster or buildslave manually, use:
1045 @example
1046 buildbot stop @var{BASEDIR}
1047 @end example
1049 This simply looks for the @file{twistd.pid} file and kills whatever
1050 process is identified within.
1052 At system shutdown, all processes are sent a @code{SIGKILL}. The
1053 buildmaster and buildslave will respond to this by shutting down
1054 normally.
1056 The buildmaster will respond to a @code{SIGHUP} by re-reading its
1057 config file. The following shortcut is available:
1059 @example
1060 buildbot reconfig @var{BASEDIR}
1061 @end example
1063 When you update the Buildbot code to a new release, you will need to
1064 restart the buildmaster and/or buildslave before it can take advantage
1065 of the new code. You can do a @code{buildbot stop @var{BASEDIR}} and
1066 @code{buildbot start @var{BASEDIR}} in quick succession, or you can
1067 use the @code{restart} shortcut, which does both steps for you:
1069 @example
1070 buildbot restart @var{BASEDIR}
1071 @end example
1074 @node Maintenance, Troubleshooting, Shutdown, Installation
1075 @section Maintenance
1077 It is a good idea to check the buildmaster's status page every once in
1078 a while, to see if your buildslave is still online. Eventually the
1079 buildbot will probably be enhanced to send you email (via the
1080 @file{info/admin} email address) when the slave has been offline for
1081 more than a few hours.
1083 If you find you can no longer provide a buildslave to the project, please
1084 let the project admins know, so they can put out a call for a
1085 replacement.
1087 The Buildbot records status and logs output continually, each time a
1088 build is performed. The status tends to be small, but the build logs
1089 can become quite large. Each build and log are recorded in a separate
1090 file, arranged hierarchically under the buildmaster's base directory.
1091 To prevent these files from growing without bound, you should
1092 periodically delete old build logs. A simple cron job to delete
1093 anything older than, say, two weeks should do the job. The only trick
1094 is to leave the @file{buildbot.tac} and other support files alone, for
1095 which find's @code{-mindepth} argument helps skip everything in the
1096 top directory. You can use something like the following:
1098 @example
1099 @@weekly cd BASEDIR && find . -mindepth 2 -type f -mtime +14 -exec rm @{@} \;
1100 @@weekly cd BASEDIR && find twistd.log* -mtime +14 -exec rm @{@} \;
1101 @end example
1103 @node Troubleshooting,  , Maintenance, Installation
1104 @section Troubleshooting
1106 Here are a few hints on diagnosing common problems.
1108 @menu
1109 * Starting the buildslave::     
1110 * Connecting to the buildmaster::  
1111 * Forcing Builds::              
1112 @end menu
1114 @node Starting the buildslave, Connecting to the buildmaster, Troubleshooting, Troubleshooting
1115 @subsection Starting the buildslave
1117 Cron jobs are typically run with a minimal shell (@file{/bin/sh}, not
1118 @file{/bin/bash}), and tilde expansion is not always performed in such
1119 commands. You may want to use explicit paths, because the @code{PATH}
1120 is usually quite short and doesn't include anything set by your
1121 shell's startup scripts (@file{.profile}, @file{.bashrc}, etc). If
1122 you've installed buildbot (or other python libraries) to an unusual
1123 location, you may need to add a @code{PYTHONPATH} specification (note
1124 that python will do tilde-expansion on @code{PYTHONPATH} elements by
1125 itself). Sometimes it is safer to fully-specify everything:
1127 @example
1128 @@reboot PYTHONPATH=~/lib/python /usr/local/bin/buildbot start /usr/home/buildbot/basedir
1129 @end example
1131 Take the time to get the @@reboot job set up. Otherwise, things will work
1132 fine for a while, but the first power outage or system reboot you have will
1133 stop the buildslave with nothing but the cries of sorrowful developers to
1134 remind you that it has gone away.
1136 @node Connecting to the buildmaster, Forcing Builds, Starting the buildslave, Troubleshooting
1137 @subsection Connecting to the buildmaster
1139 If the buildslave cannot connect to the buildmaster, the reason should
1140 be described in the @file{twistd.log} logfile. Some common problems
1141 are an incorrect master hostname or port number, or a mistyped bot
1142 name or password. If the buildslave loses the connection to the
1143 master, it is supposed to attempt to reconnect with an
1144 exponentially-increasing backoff. Each attempt (and the time of the
1145 next attempt) will be logged. If you get impatient, just manually stop
1146 and re-start the buildslave.
1148 When the buildmaster is restarted, all slaves will be disconnected,
1149 and will attempt to reconnect as usual. The reconnect time will depend
1150 upon how long the buildmaster is offline (i.e. how far up the
1151 exponential backoff curve the slaves have travelled). Again,
1152 @code{buildbot stop @var{BASEDIR}; buildbot start @var{BASEDIR}} will
1153 speed up the process.
1155 @node Forcing Builds,  , Connecting to the buildmaster, Troubleshooting
1156 @subsection Forcing Builds
1158 From the buildmaster's main status web page, you can force a build to
1159 be run on your build slave. Figure out which column is for a builder
1160 that runs on your slave, click on that builder's name, and the page
1161 that comes up will have a ``Force Build'' button. Fill in the form,
1162 hit the button, and a moment later you should see your slave's
1163 @file{twistd.log} filling with commands being run. Using @code{pstree}
1164 or @code{top} should also reveal the cvs/make/gcc/etc processes being
1165 run by the buildslave. Note that the same web page should also show
1166 the @file{admin} and @file{host} information files that you configured
1167 earlier.
1169 @node Concepts, Configuration, Installation, Top
1170 @chapter Concepts
1172 This chapter defines some of the basic concepts that the Buildbot
1173 uses. You'll need to understand how the Buildbot sees the world to
1174 configure it properly.
1176 @menu
1177 * Version Control Systems::     
1178 * Schedulers::                  
1179 * BuildSet::                    
1180 * BuildRequest::                
1181 * Builder::                     
1182 * Users::                       
1183 @end menu
1185 @node Version Control Systems, Schedulers, Concepts, Concepts
1186 @section Version Control Systems
1188 @cindex Version Control
1190 These source trees come from a Version Control System of some kind.
1191 CVS and Subversion are two popular ones, but the Buildbot supports
1192 others. All VC systems have some notion of an upstream
1193 @code{repository} which acts as a server@footnote{except Darcs, but
1194 since the Buildbot never modifies its local source tree we can ignore
1195 the fact that Darcs uses a less centralized model}, from which clients
1196 can obtain source trees according to various parameters. The VC
1197 repository provides source trees of various projects, for different
1198 branches, and from various points in time. The first thing we have to
1199 do is to specify which source tree we want to get.
1201 @menu
1202 * Generalizing VC Systems::     
1203 * Source Tree Specifications::  
1204 * How Different VC Systems Specify Sources::  
1205 * Attributes of Changes::       
1206 @end menu
1208 @node Generalizing VC Systems, Source Tree Specifications, Version Control Systems, Version Control Systems
1209 @subsection Generalizing VC Systems
1211 For the purposes of the Buildbot, we will try to generalize all VC
1212 systems as having repositories that each provide sources for a variety
1213 of projects. Each project is defined as a directory tree with source
1214 files. The individual files may each have revisions, but we ignore
1215 that and treat the project as a whole as having a set of revisions
1216 (CVS is really the only VC system still in widespread use that has
1217 per-file revisions.. everything modern has moved to atomic tree-wide
1218 changesets). Each time someone commits a change to the project, a new
1219 revision becomes available. These revisions can be described by a
1220 tuple with two items: the first is a branch tag, and the second is
1221 some kind of revision stamp or timestamp. Complex projects may have
1222 multiple branch tags, but there is always a default branch. The
1223 timestamp may be an actual timestamp (such as the -D option to CVS),
1224 or it may be a monotonically-increasing transaction number (such as
1225 the change number used by SVN and P4, or the revision number used by
1226 Arch/Baz/Bazaar, or a labeled tag used in CVS)@footnote{many VC
1227 systems provide more complexity than this: in particular the local
1228 views that P4 and ClearCase can assemble out of various source
1229 directories are more complex than we're prepared to take advantage of
1230 here}. The SHA1 revision ID used by Monotone and Mercurial is also a
1231 kind of revision stamp, in that it specifies a unique copy of the
1232 source tree, as does a Darcs ``context'' file.
1234 When we aren't intending to make any changes to the sources we check out
1235 (at least not any that need to be committed back upstream), there are two
1236 basic ways to use a VC system:
1238 @itemize @bullet
1239 @item
1240 Retrieve a specific set of source revisions: some tag or key is used
1241 to index this set, which is fixed and cannot be changed by subsequent
1242 developers committing new changes to the tree. Releases are built from
1243 tagged revisions like this, so that they can be rebuilt again later
1244 (probably with controlled modifications).
1245 @item
1246 Retrieve the latest sources along a specific branch: some tag is used
1247 to indicate which branch is to be used, but within that constraint we want
1248 to get the latest revisions.
1249 @end itemize
1251 Build personnel or CM staff typically use the first approach: the
1252 build that results is (ideally) completely specified by the two
1253 parameters given to the VC system: repository and revision tag. This
1254 gives QA and end-users something concrete to point at when reporting
1255 bugs. Release engineers are also reportedly fond of shipping code that
1256 can be traced back to a concise revision tag of some sort.
1258 Developers are more likely to use the second approach: each morning
1259 the developer does an update to pull in the changes committed by the
1260 team over the last day. These builds are not easy to fully specify: it
1261 depends upon exactly when you did a checkout, and upon what local
1262 changes the developer has in their tree. Developers do not normally
1263 tag each build they produce, because there is usually significant
1264 overhead involved in creating these tags. Recreating the trees used by
1265 one of these builds can be a challenge. Some VC systems may provide
1266 implicit tags (like a revision number), while others may allow the use
1267 of timestamps to mean ``the state of the tree at time X'' as opposed
1268 to a tree-state that has been explicitly marked.
1270 The Buildbot is designed to help developers, so it usually works in
1271 terms of @emph{the latest} sources as opposed to specific tagged
1272 revisions. However, it would really prefer to build from reproducible
1273 source trees, so implicit revisions are used whenever possible.
1275 @node Source Tree Specifications, How Different VC Systems Specify Sources, Generalizing VC Systems, Version Control Systems
1276 @subsection Source Tree Specifications
1278 So for the Buildbot's purposes we treat each VC system as a server
1279 which can take a list of specifications as input and produce a source
1280 tree as output. Some of these specifications are static: they are
1281 attributes of the builder and do not change over time. Others are more
1282 variable: each build will have a different value. The repository is
1283 changed over time by a sequence of Changes, each of which represents a
1284 single developer making changes to some set of files. These Changes
1285 are cumulative@footnote{Monotone's @emph{multiple heads} feature
1286 violates this assumption of cumulative Changes, but in most situations
1287 the changes don't occur frequently enough for this to be a significant
1288 problem}.
1290 For normal builds, the Buildbot wants to get well-defined source trees
1291 that contain specific Changes, and exclude other Changes that may have
1292 occurred after the desired ones. We assume that the Changes arrive at
1293 the buildbot (through one of the mechanisms described in @pxref{Change
1294 Sources}) in the same order in which they are committed to the
1295 repository. The Buildbot waits for the tree to become ``stable''
1296 before initiating a build, for two reasons. The first is that
1297 developers frequently make multiple related commits in quick
1298 succession, even when the VC system provides ways to make atomic
1299 transactions involving multiple files at the same time. Running a
1300 build in the middle of these sets of changes would use an inconsistent
1301 set of source files, and is likely to fail (and is certain to be less
1302 useful than a build which uses the full set of changes). The
1303 tree-stable-timer is intended to avoid these useless builds that
1304 include some of the developer's changes but not all. The second reason
1305 is that some VC systems (i.e. CVS) do not provide repository-wide
1306 transaction numbers, so that timestamps are the only way to refer to
1307 a specific repository state. These timestamps may be somewhat
1308 ambiguous, due to processing and notification delays. By waiting until
1309 the tree has been stable for, say, 10 minutes, we can choose a
1310 timestamp from the middle of that period to use for our source
1311 checkout, and then be reasonably sure that any clock-skew errors will
1312 not cause the build to be performed on an inconsistent set of source
1313 files.
1315 The Schedulers always use the tree-stable-timer, with a timeout that
1316 is configured to reflect a reasonable tradeoff between build latency
1317 and change frequency. When the VC system provides coherent
1318 repository-wide revision markers (such as Subversion's revision
1319 numbers, or in fact anything other than CVS's timestamps), the
1320 resulting Build is simply performed against a source tree defined by
1321 that revision marker. When the VC system does not provide this, a
1322 timestamp from the middle of the tree-stable period is used to
1323 generate the source tree@footnote{this @code{checkoutDelay} defaults
1324 to half the tree-stable timer, but it can be overridden with an
1325 argument to the Source Step}.
1327 @node How Different VC Systems Specify Sources, Attributes of Changes, Source Tree Specifications, Version Control Systems
1328 @subsection How Different VC Systems Specify Sources
1330 For CVS, the static specifications are @code{repository} and
1331 @code{module}. In addition to those, each build uses a timestamp (or
1332 omits the timestamp to mean @code{the latest}) and @code{branch tag}
1333 (which defaults to HEAD). These parameters collectively specify a set
1334 of sources from which a build may be performed.
1336 @uref{http://subversion.tigris.org, Subversion} combines the
1337 repository, module, and branch into a single @code{Subversion URL}
1338 parameter. Within that scope, source checkouts can be specified by a
1339 numeric @code{revision number} (a repository-wide
1340 monotonically-increasing marker, such that each transaction that
1341 changes the repository is indexed by a different revision number), or
1342 a revision timestamp. When branches are used, the repository and
1343 module form a static @code{baseURL}, while each build has a
1344 @code{revision number} and a @code{branch} (which defaults to a
1345 statically-specified @code{defaultBranch}). The @code{baseURL} and
1346 @code{branch} are simply concatenated together to derive the
1347 @code{svnurl} to use for the checkout.
1349 @uref{http://www.perforce.com/, Perforce} is similar. The server
1350 is specified through a @code{P4PORT} parameter. Module and branch
1351 are specified in a single depot path, and revisions are
1352 depot-wide. When branches are used, the @code{p4base} and
1353 @code{defaultBranch} are concatenated together to produce the depot
1354 path.
1356 @uref{http://wiki.gnuarch.org/, Arch} and
1357 @uref{http://bazaar.canonical.com/, Bazaar} specify a repository by
1358 URL, as well as a @code{version} which is kind of like a branch name.
1359 Arch uses the word @code{archive} to represent the repository. Arch
1360 lets you push changes from one archive to another, removing the strict
1361 centralization required by CVS and SVN. It retains the distinction
1362 between repository and working directory that most other VC systems
1363 use. For complex multi-module directory structures, Arch has a
1364 built-in @code{build config} layer with which the checkout process has
1365 two steps. First, an initial bootstrap checkout is performed to
1366 retrieve a set of build-config files. Second, one of these files is
1367 used to figure out which archives/modules should be used to populate
1368 subdirectories of the initial checkout.
1370 Builders which use Arch and Bazaar therefore have a static archive
1371 @code{url}, and a default ``branch'' (which is a string that specifies
1372 a complete category--branch--version triple). Each build can have its
1373 own branch (the category--branch--version string) to override the
1374 default, as well as a revision number (which is turned into a
1375 --patch-NN suffix when performing the checkout).
1378 @uref{http://bazaar-vcs.org, Bzr} (which is a descendant of
1379 Arch/Bazaar, and is frequently referred to as ``Bazaar'') has the same
1380 sort of repository-vs-workspace model as Arch, but the repository data
1381 can either be stored inside the working directory or kept elsewhere
1382 (either on the same machine or on an entirely different machine). For
1383 the purposes of Buildbot (which never commits changes), the repository
1384 is specified with a URL and a revision number.
1386 The most common way to obtain read-only access to a bzr tree is via
1387 HTTP, simply by making the repository visible through a web server
1388 like Apache. Bzr can also use FTP and SFTP servers, if the buildslave
1389 process has sufficient privileges to access them. Higher performance
1390 can be obtained by running a special Bazaar-specific server. None of
1391 these matter to the buildbot: the repository URL just has to match the
1392 kind of server being used. The @code{repoURL} argument provides the
1393 location of the repository.
1395 Branches are expressed as subdirectories of the main central
1396 repository, which means that if branches are being used, the BZR step
1397 is given a @code{baseURL} and @code{defaultBranch} instead of getting
1398 the @code{repoURL} argument.
1401 @uref{http://darcs.net/, Darcs} doesn't really have the
1402 notion of a single master repository. Nor does it really have
1403 branches. In Darcs, each working directory is also a repository, and
1404 there are operations to push and pull patches from one of these
1405 @code{repositories} to another. For the Buildbot's purposes, all you
1406 need to do is specify the URL of a repository that you want to build
1407 from. The build slave will then pull the latest patches from that
1408 repository and build them. Multiple branches are implemented by using
1409 multiple repositories (possibly living on the same server).
1411 Builders which use Darcs therefore have a static @code{repourl} which
1412 specifies the location of the repository. If branches are being used,
1413 the source Step is instead configured with a @code{baseURL} and a
1414 @code{defaultBranch}, and the two strings are simply concatenated
1415 together to obtain the repository's URL. Each build then has a
1416 specific branch which replaces @code{defaultBranch}, or just uses the
1417 default one. Instead of a revision number, each build can have a
1418 ``context'', which is a string that records all the patches that are
1419 present in a given tree (this is the output of @command{darcs changes
1420 --context}, and is considerably less concise than, e.g. Subversion's
1421 revision number, but the patch-reordering flexibility of Darcs makes
1422 it impossible to provide a shorter useful specification).
1424 @uref{http://selenic.com/mercurial, Mercurial} is like Darcs, in that
1425 each branch is stored in a separate repository. The @code{repourl},
1426 @code{baseURL}, and @code{defaultBranch} arguments are all handled the
1427 same way as with Darcs. The ``revision'', however, is the hash
1428 identifier returned by @command{hg identify}.
1431 @node Attributes of Changes,  , How Different VC Systems Specify Sources, Version Control Systems
1432 @subsection Attributes of Changes
1434 @heading Who
1436 Each Change has a @code{who} attribute, which specifies which
1437 developer is responsible for the change. This is a string which comes
1438 from a namespace controlled by the VC repository. Frequently this
1439 means it is a username on the host which runs the repository, but not
1440 all VC systems require this (Arch, for example, uses a fully-qualified
1441 @code{Arch ID}, which looks like an email address, as does Darcs).
1442 Each StatusNotifier will map the @code{who} attribute into something
1443 appropriate for their particular means of communication: an email
1444 address, an IRC handle, etc.
1446 @heading Files
1448 It also has a list of @code{files}, which are just the tree-relative
1449 filenames of any files that were added, deleted, or modified for this
1450 Change. These filenames are used by the @code{isFileImportant}
1451 function (in the Scheduler) to decide whether it is worth triggering a
1452 new build or not, e.g. the function could use
1453 @code{filename.endswith(".c")} to only run a build if a C file were
1454 checked in. Certain BuildSteps can also use the list of changed files
1455 to run a more targeted series of tests, e.g. the
1456 @code{python_twisted.Trial} step can run just the unit tests that
1457 provide coverage for the modified .py files instead of running the
1458 full test suite.
1460 @heading Comments
1462 The Change also has a @code{comments} attribute, which is a string
1463 containing any checkin comments.
1465 @heading Revision
1467 Each Change can have a @code{revision} attribute, which describes how
1468 to get a tree with a specific state: a tree which includes this Change
1469 (and all that came before it) but none that come after it. If this
1470 information is unavailable, the @code{.revision} attribute will be
1471 @code{None}. These revisions are provided by the ChangeSource, and
1472 consumed by the @code{computeSourceRevision} method in the appropriate
1473 @code{step.Source} class.
1475 @table @samp
1476 @item CVS
1477 @code{revision} is an int, seconds since the epoch
1478 @item SVN
1479 @code{revision} is an int, a transation number (r%d)
1480 @item Darcs
1481 @code{revision} is a large string, the output of @code{darcs changes --context}
1482 @item Mercurial
1483 @code{revision} is a short string (a hash ID), the output of @code{hg identify}
1484 @item Arch/Bazaar
1485 @code{revision} is the full revision ID (ending in --patch-%d)
1486 @item P4
1487 @code{revision} is an int, the transaction number
1488 @end table
1490 @heading Branches
1492 The Change might also have a @code{branch} attribute. This indicates
1493 that all of the Change's files are in the same named branch. The
1494 Schedulers get to decide whether the branch should be built or not.
1496 For VC systems like CVS, Arch, and Monotone, the @code{branch} name is
1497 unrelated to the filename. (that is, the branch name and the filename
1498 inhabit unrelated namespaces). For SVN, branches are expressed as
1499 subdirectories of the repository, so the file's ``svnurl'' is a
1500 combination of some base URL, the branch name, and the filename within
1501 the branch. (In a sense, the branch name and the filename inhabit the
1502 same namespace). Darcs branches are subdirectories of a base URL just
1503 like SVN. Mercurial branches are the same as Darcs.
1505 @table @samp
1506 @item CVS
1507 branch='warner-newfeature', files=['src/foo.c']
1508 @item SVN
1509 branch='branches/warner-newfeature', files=['src/foo.c']
1510 @item Darcs
1511 branch='warner-newfeature', files=['src/foo.c']
1512 @item Mercurial
1513 branch='warner-newfeature', files=['src/foo.c']
1514 @item Arch/Bazaar
1515 branch='buildbot--usebranches--0', files=['buildbot/master.py']
1516 @end table
1518 @heading Links
1520 @c TODO: who is using 'links'? how is it being used?
1522 Finally, the Change might have a @code{links} list, which is intended
1523 to provide a list of URLs to a @emph{viewcvs}-style web page that
1524 provides more detail for this Change, perhaps including the full file
1525 diffs.
1528 @node Schedulers, BuildSet, Version Control Systems, Concepts
1529 @section Schedulers
1531 @cindex Scheduler
1533 Each Buildmaster has a set of @code{Scheduler} objects, each of which
1534 gets a copy of every incoming Change. The Schedulers are responsible
1535 for deciding when Builds should be run. Some Buildbot installations
1536 might have a single Scheduler, while others may have several, each for
1537 a different purpose.
1539 For example, a ``quick'' scheduler might exist to give immediate
1540 feedback to developers, hoping to catch obvious problems in the code
1541 that can be detected quickly. These typically do not run the full test
1542 suite, nor do they run on a wide variety of platforms. They also
1543 usually do a VC update rather than performing a brand-new checkout
1544 each time. You could have a ``quick'' scheduler which used a 30 second
1545 timeout, and feeds a single ``quick'' Builder that uses a VC
1546 @code{mode='update'} setting.
1548 A separate ``full'' scheduler would run more comprehensive tests a
1549 little while later, to catch more subtle problems. This scheduler
1550 would have a longer tree-stable-timer, maybe 30 minutes, and would
1551 feed multiple Builders (with a @code{mode=} of @code{'copy'},
1552 @code{'clobber'}, or @code{'export'}).
1554 The @code{tree-stable-timer} and @code{isFileImportant} decisions are
1555 made by the Scheduler. Dependencies are also implemented here.
1556 Periodic builds (those which are run every N seconds rather than after
1557 new Changes arrive) are triggered by a special @code{Periodic}
1558 Scheduler subclass. The default Scheduler class can also be told to
1559 watch for specific branches, ignoring Changes on other branches. This
1560 may be useful if you have a trunk and a few release branches which
1561 should be tracked, but when you don't want to have the Buildbot pay
1562 attention to several dozen private user branches.
1564 Some Schedulers may trigger builds for other reasons, other than
1565 recent Changes. For example, a Scheduler subclass could connect to a
1566 remote buildmaster and watch for builds of a library to succeed before
1567 triggering a local build that uses that library.
1569 Each Scheduler creates and submits @code{BuildSet} objects to the
1570 @code{BuildMaster}, which is then responsible for making sure the
1571 individual @code{BuildRequests} are delivered to the target
1572 @code{Builders}.
1574 @code{Scheduler} instances are activated by placing them in the
1575 @code{c['schedulers']} list in the buildmaster config file. Each
1576 Scheduler has a unique name.
1579 @node BuildSet, BuildRequest, Schedulers, Concepts
1580 @section BuildSet
1582 @cindex BuildSet
1584 A @code{BuildSet} is the name given to a set of Builds that all
1585 compile/test the same version of the tree on multiple Builders. In
1586 general, all these component Builds will perform the same sequence of
1587 Steps, using the same source code, but on different platforms or
1588 against a different set of libraries.
1590 The @code{BuildSet} is tracked as a single unit, which fails if any of
1591 the component Builds have failed, and therefore can succeed only if
1592 @emph{all} of the component Builds have succeeded. There are two kinds
1593 of status notification messages that can be emitted for a BuildSet:
1594 the @code{firstFailure} type (which fires as soon as we know the
1595 BuildSet will fail), and the @code{Finished} type (which fires once
1596 the BuildSet has completely finished, regardless of whether the
1597 overall set passed or failed).
1599 A @code{BuildSet} is created with a @emph{source stamp} tuple of
1600 (branch, revision, changes, patch), some of which may be None, and a
1601 list of Builders on which it is to be run. They are then given to the
1602 BuildMaster, which is responsible for creating a separate
1603 @code{BuildRequest} for each Builder.
1605 There are a couple of different likely values for the
1606 @code{SourceStamp}:
1608 @table @code
1609 @item (revision=None, changes=[CHANGES], patch=None)
1610 This is a @code{SourceStamp} used when a series of Changes have
1611 triggered a build. The VC step will attempt to check out a tree that
1612 contains CHANGES (and any changes that occurred before CHANGES, but
1613 not any that occurred after them).
1615 @item (revision=None, changes=None, patch=None)
1616 This builds the most recent code on the default branch. This is the
1617 sort of @code{SourceStamp} that would be used on a Build that was
1618 triggered by a user request, or a Periodic scheduler. It is also
1619 possible to configure the VC Source Step to always check out the
1620 latest sources rather than paying attention to the Changes in the
1621 SourceStamp, which will result in same behavior as this.
1623 @item (branch=BRANCH, revision=None, changes=None, patch=None)
1624 This builds the most recent code on the given BRANCH. Again, this is
1625 generally triggered by a user request or Periodic build.
1627 @item (revision=REV, changes=None, patch=(LEVEL, DIFF))
1628 This checks out the tree at the given revision REV, then applies a
1629 patch (using @code{diff -pLEVEL <DIFF}). The @ref{try} feature uses
1630 this kind of @code{SourceStamp}. If @code{patch} is None, the patching
1631 step is bypassed.
1633 @end table
1635 The buildmaster is responsible for turning the @code{BuildSet} into a
1636 set of @code{BuildRequest} objects and queueing them on the
1637 appropriate Builders.
1640 @node BuildRequest, Builder, BuildSet, Concepts
1641 @section BuildRequest
1643 @cindex BuildRequest
1645 A @code{BuildRequest} is a request to build a specific set of sources
1646 on a single specific Builder. Each Builder runs the
1647 @code{BuildRequest} as soon as it can (i.e. when an associated
1648 buildslave becomes free).
1650 The @code{BuildRequest} contains the @code{SourceStamp} specification.
1651 The actual process of running the build (the series of Steps that will
1652 be executed) is implemented by the @code{Build} object. In this future
1653 this might be changed, to have the @code{Build} define @emph{what}
1654 gets built, and a separate @code{BuildProcess} (provided by the
1655 Builder) to define @emph{how} it gets built.
1657 The @code{BuildRequest} may be mergeable with other compatible
1658 @code{BuildRequest}s. Builds that are triggered by incoming Changes
1659 will generally be mergeable. Builds that are triggered by user
1660 requests are generally not, unless they are multiple requests to build
1661 the @emph{latest sources} of the same branch.
1663 @node Builder, Users, BuildRequest, Concepts
1664 @section Builder
1666 @cindex Builder
1668 The @code{Builder} is a long-lived object which controls all Builds of
1669 a given type. Each one is created when the config file is first
1670 parsed, and lives forever (or rather until it is removed from the
1671 config file). It mediates the connections to the buildslaves that do
1672 all the work, and is responsible for creating the @code{Build} objects
1673 that decide @emph{how} a build is performed (i.e., which steps are
1674 executed in what order).
1676 Each @code{Builder} gets a unique name, and the path name of a
1677 directory where it gets to do all its work (there is a
1678 buildmaster-side directory for keeping status information, as well as
1679 a buildslave-side directory where the actual checkout/compile/test
1680 commands are executed). It also gets a @code{BuildFactory}, which is
1681 responsible for creating new @code{Build} instances: because the
1682 @code{Build} instance is what actually performs each build, choosing
1683 the @code{BuildFactory} is the way to specify what happens each time a
1684 build is done.
1686 Each @code{Builder} is associated with one of more @code{BuildSlaves}.
1687 A @code{Builder} which is used to perform OS-X builds (as opposed to
1688 Linux or Solaris builds) should naturally be associated with an
1689 OS-X-based buildslave.
1692 @node Users,  , Builder, Concepts
1693 @section Users
1695 @cindex Users
1697 Buildbot has a somewhat limited awareness of @emph{users}. It assumes
1698 the world consists of a set of developers, each of whom can be
1699 described by a couple of simple attributes. These developers make
1700 changes to the source code, causing builds which may succeed or fail.
1702 Each developer is primarily known through the source control system. Each
1703 Change object that arrives is tagged with a @code{who} field that
1704 typically gives the account name (on the repository machine) of the user
1705 responsible for that change. This string is the primary key by which the
1706 User is known, and is displayed on the HTML status pages and in each Build's
1707 ``blamelist''.
1709 To do more with the User than just refer to them, this username needs to
1710 be mapped into an address of some sort. The responsibility for this mapping
1711 is left up to the status module which needs the address. The core code knows
1712 nothing about email addresses or IRC nicknames, just user names.
1714 @menu
1715 * Doing Things With Users::     
1716 * Email Addresses::             
1717 * IRC Nicknames::               
1718 * Live Status Clients::         
1719 @end menu
1721 @node Doing Things With Users, Email Addresses, Users, Users
1722 @subsection Doing Things With Users
1724 Each Change has a single User who is responsible for that Change. Most
1725 Builds have a set of Changes: the Build represents the first time these
1726 Changes have been built and tested by the Buildbot. The build has a
1727 ``blamelist'' that consists of a simple union of the Users responsible
1728 for all the Build's Changes.
1730 The Build provides (through the IBuildStatus interface) a list of Users
1731 who are ``involved'' in the build. For now this is equal to the
1732 blamelist, but in the future it will be expanded to include a ``build
1733 sheriff'' (a person who is ``on duty'' at that time and responsible for
1734 watching over all builds that occur during their shift), as well as
1735 per-module owners who simply want to keep watch over their domain (chosen by
1736 subdirectory or a regexp matched against the filenames pulled out of the
1737 Changes). The Involved Users are those who probably have an interest in the
1738 results of any given build.
1740 In the future, Buildbot will acquire the concept of ``Problems'',
1741 which last longer than builds and have beginnings and ends. For example, a
1742 test case which passed in one build and then failed in the next is a
1743 Problem. The Problem lasts until the test case starts passing again, at
1744 which point the Problem is said to be ``resolved''.
1746 If there appears to be a code change that went into the tree at the
1747 same time as the test started failing, that Change is marked as being
1748 resposible for the Problem, and the user who made the change is added
1749 to the Problem's ``Guilty'' list. In addition to this user, there may
1750 be others who share responsibility for the Problem (module owners,
1751 sponsoring developers). In addition to the Responsible Users, there
1752 may be a set of Interested Users, who take an interest in the fate of
1753 the Problem.
1755 Problems therefore have sets of Users who may want to be kept aware of
1756 the condition of the problem as it changes over time. If configured, the
1757 Buildbot can pester everyone on the Responsible list with increasing
1758 harshness until the problem is resolved, with the most harshness reserved
1759 for the Guilty parties themselves. The Interested Users may merely be told
1760 when the problem starts and stops, as they are not actually responsible for
1761 fixing anything.
1763 @node Email Addresses, IRC Nicknames, Doing Things With Users, Users
1764 @subsection Email Addresses
1766 The @code{buildbot.status.mail.MailNotifier} class provides a
1767 status target which can send email about the results of each build. It
1768 accepts a static list of email addresses to which each message should be
1769 delivered, but it can also be configured to send mail to the Build's
1770 Interested Users. To do this, it needs a way to convert User names into
1771 email addresses.
1773 For many VC systems, the User Name is actually an account name on the
1774 system which hosts the repository. As such, turning the name into an
1775 email address is a simple matter of appending
1776 ``@@repositoryhost.com''. Some projects use other kinds of mappings
1777 (for example the preferred email address may be at ``project.org''
1778 despite the repository host being named ``cvs.project.org''), and some
1779 VC systems have full separation between the concept of a user and that
1780 of an account on the repository host (like Perforce). Some systems
1781 (like Arch) put a full contact email address in every change.
1783 To convert these names to addresses, the MailNotifier uses an EmailLookup
1784 object. This provides a .getAddress method which accepts a name and
1785 (eventually) returns an address. The default @code{MailNotifier}
1786 module provides an EmailLookup which simply appends a static string,
1787 configurable when the notifier is created. To create more complex behaviors
1788 (perhaps using an LDAP lookup, or using ``finger'' on a central host to
1789 determine a preferred address for the developer), provide a different object
1790 as the @code{lookup} argument.
1792 In the future, when the Problem mechanism has been set up, the Buildbot
1793 will need to send mail to arbitrary Users. It will do this by locating a
1794 MailNotifier-like object among all the buildmaster's status targets, and
1795 asking it to send messages to various Users. This means the User-to-address
1796 mapping only has to be set up once, in your MailNotifier, and every email
1797 message the buildbot emits will take advantage of it.
1799 @node IRC Nicknames, Live Status Clients, Email Addresses, Users
1800 @subsection IRC Nicknames
1802 Like MailNotifier, the @code{buildbot.status.words.IRC} class
1803 provides a status target which can announce the results of each build. It
1804 also provides an interactive interface by responding to online queries
1805 posted in the channel or sent as private messages.
1807 In the future, the buildbot can be configured map User names to IRC
1808 nicknames, to watch for the recent presence of these nicknames, and to
1809 deliver build status messages to the interested parties. Like
1810 @code{MailNotifier} does for email addresses, the @code{IRC} object
1811 will have an @code{IRCLookup} which is responsible for nicknames. The
1812 mapping can be set up statically, or it can be updated by online users
1813 themselves (by claiming a username with some kind of ``buildbot: i am
1814 user warner'' commands).
1816 Once the mapping is established, the rest of the buildbot can ask the
1817 @code{IRC} object to send messages to various users. It can report on
1818 the likelihood that the user saw the given message (based upon how long the
1819 user has been inactive on the channel), which might prompt the Problem
1820 Hassler logic to send them an email message instead.
1822 @node Live Status Clients,  , IRC Nicknames, Users
1823 @subsection Live Status Clients
1825 The Buildbot also offers a PB-based status client interface which can
1826 display real-time build status in a GUI panel on the developer's desktop.
1827 This interface is normally anonymous, but it could be configured to let the
1828 buildmaster know @emph{which} developer is using the status client. The
1829 status client could then be used as a message-delivery service, providing an
1830 alternative way to deliver low-latency high-interruption messages to the
1831 developer (like ``hey, you broke the build'').
1834 @node Configuration, Getting Source Code Changes, Concepts, Top
1835 @chapter Configuration
1837 @cindex Configuration
1839 The buildbot's behavior is defined by the ``config file'', which
1840 normally lives in the @file{master.cfg} file in the buildmaster's base
1841 directory (but this can be changed with an option to the
1842 @code{buildbot create-master} command). This file completely specifies
1843 which Builders are to be run, which slaves they should use, how
1844 Changes should be tracked, and where the status information is to be
1845 sent. The buildmaster's @file{buildbot.tac} file names the base
1846 directory; everything else comes from the config file.
1848 A sample config file was installed for you when you created the
1849 buildmaster, but you will need to edit it before your buildbot will do
1850 anything useful.
1852 This chapter gives an overview of the format of this file and the
1853 various sections in it. You will need to read the later chapters to
1854 understand how to fill in each section properly.
1856 @menu
1857 * Config File Format::          
1858 * Loading the Config File::     
1859 * Defining the Project::        
1860 * Listing Change Sources and Schedulers::  
1861 * Setting the slaveport::       
1862 * Buildslave Specifiers::       
1863 * Defining Builders::           
1864 * Defining Status Targets::     
1865 * Debug options::               
1866 @end menu
1868 @node Config File Format, Loading the Config File, Configuration, Configuration
1869 @section Config File Format
1871 The config file is, fundamentally, just a piece of Python code which
1872 defines a dictionary named @code{BuildmasterConfig}, with a number of
1873 keys that are treated specially. You don't need to know Python to do
1874 basic configuration, though, you can just copy the syntax of the
1875 sample file. If you @emph{are} comfortable writing Python code,
1876 however, you can use all the power of a full programming language to
1877 achieve more complicated configurations.
1879 The @code{BuildmasterConfig} name is the only one which matters: all
1880 other names defined during the execution of the file are discarded.
1881 When parsing the config file, the Buildmaster generally compares the
1882 old configuration with the new one and performs the minimum set of
1883 actions necessary to bring the buildbot up to date: Builders which are
1884 not changed are left untouched, and Builders which are modified get to
1885 keep their old event history.
1887 Basic Python syntax: comments start with a hash character (``#''),
1888 tuples are defined with @code{(parenthesis, pairs)}, arrays are
1889 defined with @code{[square, brackets]}, tuples and arrays are mostly
1890 interchangeable. Dictionaries (data structures which map ``keys'' to
1891 ``values'') are defined with curly braces: @code{@{'key1': 'value1',
1892 'key2': 'value2'@} }. Function calls (and object instantiation) can use
1893 named parameters, like @code{w = html.Waterfall(http_port=8010)}.
1895 The config file starts with a series of @code{import} statements,
1896 which make various kinds of Steps and Status targets available for
1897 later use. The main @code{BuildmasterConfig} dictionary is created,
1898 then it is populated with a variety of keys. These keys are broken
1899 roughly into the following sections, each of which is documented in
1900 the rest of this chapter:
1902 @itemize @bullet
1903 @item
1904 Project Definitions
1905 @item
1906 Change Sources / Schedulers
1907 @item
1908 Slaveport
1909 @item
1910 Buildslave Configuration
1911 @item
1912 Builders / Interlocks
1913 @item
1914 Status Targets
1915 @item
1916 Debug options
1917 @end itemize
1919 The config file can use a few names which are placed into its namespace:
1921 @table @code
1922 @item basedir
1923 the base directory for the buildmaster. This string has not been
1924 expanded, so it may start with a tilde. It needs to be expanded before
1925 use. The config file is located in
1926 @code{os.path.expanduser(os.path.join(basedir, 'master.cfg'))}
1928 @end table
1931 @node Loading the Config File, Defining the Project, Config File Format, Configuration
1932 @section Loading the Config File
1934 The config file is only read at specific points in time. It is first
1935 read when the buildmaster is launched. Once it is running, there are
1936 various ways to ask it to reload the config file. If you are on the
1937 system hosting the buildmaster, you can send a @code{SIGHUP} signal to
1938 it: the @command{buildbot} tool has a shortcut for this:
1940 @example
1941 buildbot reconfig @var{BASEDIR}
1942 @end example
1944 This command will show you all of the lines from @file{twistd.log}
1945 that relate to the reconfiguration. If there are any problems during
1946 the config-file reload, they will be displayed in these lines.
1948 The debug tool (@code{buildbot debugclient --master HOST:PORT}) has a
1949 ``Reload .cfg'' button which will also trigger a reload. In the
1950 future, there will be other ways to accomplish this step (probably a
1951 password-protected button on the web page, as well as a privileged IRC
1952 command).
1954 When reloading the config file, the buildmaster will endeavor to
1955 change as little as possible about the running system. For example,
1956 although old status targets may be shut down and new ones started up,
1957 any status targets that were not changed since the last time the
1958 config file was read will be left running and untouched. Likewise any
1959 Builders which have not been changed will be left running. If a
1960 Builder is modified (say, the build process is changed) while a Build
1961 is currently running, that Build will keep running with the old
1962 process until it completes. Any previously queued Builds (or Builds
1963 which get queued after the reconfig) will use the new process.
1965 @node Defining the Project, Listing Change Sources and Schedulers, Loading the Config File, Configuration
1966 @section Defining the Project
1968 There are a couple of basic settings that you use to tell the buildbot
1969 what project it is working on. This information is used by status
1970 reporters to let users find out more about the codebase being
1971 exercised by this particular Buildbot installation.
1973 @example
1974 c['projectName'] = "Buildbot"
1975 c['projectURL'] = "http://buildbot.sourceforge.net/"
1976 c['buildbotURL'] = "http://localhost:8010/"
1977 @end example
1979 @bcindex c['projectName']
1980 @code{projectName} is a short string will be used to describe the
1981 project that this buildbot is working on. For example, it is used as
1982 the title of the waterfall HTML page. 
1984 @bcindex c['projectURL']
1985 @code{projectURL} is a string that gives a URL for the project as a
1986 whole. HTML status displays will show @code{projectName} as a link to
1987 @code{projectURL}, to provide a link from buildbot HTML pages to your
1988 project's home page.
1990 @bcindex c['buildbotURL']
1991 The @code{buildbotURL} string should point to the location where the
1992 buildbot's internal web server (usually the @code{html.Waterfall}
1993 page) is visible. This typically uses the port number set when you
1994 create the @code{Waterfall} object: the buildbot needs your help to
1995 figure out a suitable externally-visible host name.
1997 When status notices are sent to users (either by email or over IRC),
1998 @code{buildbotURL} will be used to create a URL to the specific build
1999 or problem that they are being notified about. It will also be made
2000 available to queriers (over IRC) who want to find out where to get
2001 more information about this buildbot.
2004 @node Listing Change Sources and Schedulers, Setting the slaveport, Defining the Project, Configuration
2005 @section Listing Change Sources and Schedulers
2007 @bcindex c['sources']
2008 @bcindex c['change_source']
2010 The @code{c['change_source']} key is the ChangeSource
2011 instance@footnote{To be precise, it is an object or a list of objects
2012 which all implement the @code{buildbot.interfaces.IChangeSource}
2013 Interface. It is unusual to have multiple ChangeSources, so this key
2014 accepts either a single ChangeSource or a sequence of them.} that
2015 defines how the buildmaster learns about source code changes. More
2016 information about what goes here is available in @xref{Getting Source
2017 Code Changes}.
2019 @example
2020 from buildbot.changes.pb import PBChangeSource
2021 c['change_source'] = PBChangeSource()
2022 @end example
2024 (note: in buildbot-0.7.5 and earlier, this key was named
2025 @code{c['sources']}, and required a list. @code{c['sources']} is
2026 deprecated as of buildbot-0.7.6 and is scheduled to be removed in a
2027 future release).
2029 @bcindex c['schedulers']
2030 @code{c['schedulers']} is a list of Scheduler instances, each of which
2031 causes builds to be started on a particular set of Builders. The two
2032 basic Scheduler classes you are likely to start with are
2033 @code{Scheduler} and @code{Periodic}, but you can write a customized
2034 subclass to implement more complicated build scheduling.
2036 The docstring for @code{buildbot.scheduler.Scheduler} is the best
2037 place to see all the options that can be used. Type @code{pydoc
2038 buildbot.scheduler.Scheduler} to see it, or look in
2039 @file{buildbot/scheduler.py} directly.
2041 The basic Scheduler takes four arguments:
2043 @table @code
2044 @item name
2045 Each Scheduler must have a unique name. This is only used in status
2046 displays.
2048 @item branch
2049 This Scheduler will pay attention to a single branch, ignoring Changes
2050 that occur on other branches. Setting @code{branch} equal to the
2051 special value of @code{None} means it should only pay attention to the
2052 default branch. Note that @code{None} is a keyword, not a string, so
2053 you want to use @code{None} and not @code{"None"}.
2055 @item treeStableTimer
2056 The Scheduler will wait for this many seconds before starting the
2057 build. If new changes are made during this interval, the timer will be
2058 restarted, so really the build will be started after a change and then
2059 after this many seconds of inactivity.
2061 @item builderNames
2062 When the tree-stable-timer finally expires, builds will be started on
2063 these Builders. Each Builder gets a unique name: these strings must
2064 match.
2066 @end table
2068 @example
2069 from buildbot import scheduler
2070 quick = scheduler.Scheduler("quick", None, 60,
2071                             ["quick-linux", "quick-netbsd"])
2072 full = scheduler.Scheduler("full", None, 5*60,
2073                            ["full-linux", "full-netbsd", "full-OSX"])
2074 nightly = scheduler.Periodic("nightly", ["full-solaris"], 24*60*60)
2075 c['schedulers'] = [quick, full, nightly]
2076 @end example
2078 In this example, the two ``quick'' builds are triggered 60 seconds
2079 after the tree has been changed. The ``full'' builds do not run quite
2080 so quickly (they wait 5 minutes), so hopefully if the quick builds
2081 fail due to a missing file or really simple typo, the developer can
2082 discover and fix the problem before the full builds are started. Both
2083 Schedulers only pay attention to the default branch: any changes on
2084 other branches are ignored by these Schedulers. Each Scheduler
2085 triggers a different set of Builders, referenced by name.
2087 The third Scheduler in this example just runs the full solaris build
2088 once per day. (note that this Scheduler only lets you control the time
2089 between builds, not the absolute time-of-day of each Build, so this
2090 could easily wind up a ``daily'' or ``every afternoon'' scheduler
2091 depending upon when it was first activated).
2093 @menu
2094 * Scheduler Types::             
2095 * Build Dependencies::          
2096 @end menu
2098 @node Scheduler Types, Build Dependencies, Listing Change Sources and Schedulers, Listing Change Sources and Schedulers
2099 @subsection Scheduler Types
2101 @slindex buildbot.scheduler.Scheduler
2102 @slindex buildbot.scheduler.AnyBranchScheduler
2103 @slindex buildbot.scheduler.Periodic
2104 @slindex buildbot.scheduler.Nightly
2106 Here is a brief catalog of the available Scheduler types. All these
2107 Schedulers are classes in @code{buildbot.scheduler}, and the
2108 docstrings there are the best source of documentation on the arguments
2109 taken by each one.
2111 @table @code
2112 @item Scheduler
2113 This is the default Scheduler class. It follows exactly one branch,
2114 and starts a configurable tree-stable-timer after each change on that
2115 branch. When the timer expires, it starts a build on some set of
2116 Builders. The Scheduler accepts a @code{fileIsImportant} function
2117 which can be used to ignore some Changes if they do not affect any
2118 ``important'' files.
2120 @item AnyBranchScheduler
2121 This scheduler uses a tree-stable-timer like the default one, but
2122 follows multiple branches at once. Each branch gets a separate timer.
2124 @item Dependent
2125 This scheduler watches an ``upstream'' Scheduler. When all the
2126 Builders launched by that Scheduler successfully finish, the Dependent
2127 scheduler is triggered. The next section (@pxref{Build Dependencies})
2128 describes this scheduler in more detail.
2130 @item Periodic
2131 This simple scheduler just triggers a build every N seconds.
2133 @item Nightly
2134 This is highly configurable periodic build scheduler, which triggers a
2135 build at particular times of day, week, month, or year. The
2136 configuration syntax is very similar to the well-known @code{crontab}
2137 format, in which you provide values for minute, hour, day, and month
2138 (some of which can be wildcards), and a build is triggered whenever
2139 the current time matches the given constraints. This can run a build
2140 every night, every morning, every weekend, alternate Thursdays, on
2141 your boss's birthday, etc.
2143 @item Try_Jobdir / Try_Userpass
2144 This scheduler allows developers to use the @code{buildbot try}
2145 command to trigger builds of code they have not yet committed. See
2146 @ref{try} for complete details.
2148 @end table
2150 @node Build Dependencies,  , Scheduler Types, Listing Change Sources and Schedulers
2151 @subsection Build Dependencies
2153 @cindex Dependent
2154 @cindex Dependencies
2155 @slindex buildbot.scheduler.Dependent
2157 It is common to wind up with one kind of build which should only be
2158 performed if the same source code was successfully handled by some
2159 other kind of build first. An example might be a packaging step: you
2160 might only want to produce .deb or RPM packages from a tree that was
2161 known to compile successfully and pass all unit tests. You could put
2162 the packaging step in the same Build as the compile and testing steps,
2163 but there might be other reasons to not do this (in particular you
2164 might have several Builders worth of compiles/tests, but only wish to
2165 do the packaging once). Another example is if you want to skip the
2166 ``full'' builds after a failing ``quick'' build of the same source
2167 code. Or, if one Build creates a product (like a compiled library)
2168 that is used by some other Builder, you'd want to make sure the
2169 consuming Build is run @emph{after} the producing one.
2171 You can use @code{Dependencies} to express this relationship to the
2172 Buildbot. There is a special kind of Scheduler named
2173 @code{scheduler.Dependent} that will watch an ``upstream'' Scheduler
2174 for builds to complete successfully (on all of its Builders). Each
2175 time that happens, the same source code (i.e. the same
2176 @code{SourceStamp}) will be used to start a new set of builds, on a
2177 different set of Builders. This ``downstream'' scheduler doesn't pay
2178 attention to Changes at all, it only pays attention to the upstream
2179 scheduler.
2181 If the SourceStamp fails on any of the Builders in the upstream set,
2182 the downstream builds will not fire.
2184 @example
2185 from buildbot import scheduler
2186 tests = scheduler.Scheduler("tests", None, 5*60,
2187                             ["full-linux", "full-netbsd", "full-OSX"])
2188 package = scheduler.Dependent("package",
2189                               tests, # upstream scheduler
2190                               ["make-tarball", "make-deb", "make-rpm"])
2191 c['schedulers'] = [tests, package]
2192 @end example
2194 Note that @code{Dependent}'s upstream scheduler argument is given as a
2195 @code{Scheduler} @emph{instance}, not a name. This makes it impossible
2196 to create circular dependencies in the config file.
2199 @node Setting the slaveport, Buildslave Specifiers, Listing Change Sources and Schedulers, Configuration
2200 @section Setting the slaveport
2202 @bcindex c['slavePortnum']
2204 The buildmaster will listen on a TCP port of your choosing for
2205 connections from buildslaves. It can also use this port for
2206 connections from remote Change Sources, status clients, and debug
2207 tools. This port should be visible to the outside world, and you'll
2208 need to tell your buildslave admins about your choice.
2210 It does not matter which port you pick, as long it is externally
2211 visible, however you should probably use something larger than 1024,
2212 since most operating systems don't allow non-root processes to bind to
2213 low-numbered ports. If your buildmaster is behind a firewall or a NAT
2214 box of some sort, you may have to configure your firewall to permit
2215 inbound connections to this port.
2217 @example
2218 c['slavePortnum'] = 10000
2219 @end example
2221 @code{c['slavePortnum']} is a @emph{strports} specification string,
2222 defined in the @code{twisted.application.strports} module (try
2223 @command{pydoc twisted.application.strports} to get documentation on
2224 the format). This means that you can have the buildmaster listen on a
2225 localhost-only port by doing:
2227 @example
2228 c['slavePortnum'] = "tcp:10000:interface=127.0.0.1"
2229 @end example
2231 This might be useful if you only run buildslaves on the same machine,
2232 and they are all configured to contact the buildmaster at
2233 @code{localhost:10000}.
2236 @node Buildslave Specifiers, Defining Builders, Setting the slaveport, Configuration
2237 @section Buildslave Specifiers
2239 @bcindex c['slaves']
2241 The @code{c['slaves']} key is a list of known buildslaves. Each
2242 buildslave is defined by an instance of the BuildSlave class, created
2243 with two values: (slavename, slavepassword). These are the same two
2244 values that need to be provided to the buildslave administrator when
2245 they create the buildslave.
2247 @example
2248 from buildbot.buildslave import BuildSlave
2249 c['slaves'] = [BuildSlave('bot-solaris', 'solarispasswd'),
2250                BuildSlave('bot-bsd', 'bsdpasswd'),
2251               ]
2252 @end example
2254 The slavenames must be unique, of course. The password exists to
2255 prevent evildoers from interfering with the buildbot by inserting
2256 their own (broken) buildslaves into the system and thus displacing the
2257 real ones.
2259 Buildslaves with an unrecognized slavename or a non-matching password
2260 will be rejected when they attempt to connect, and a message
2261 describing the problem will be put in the log file (see @ref{Logfiles}).
2263 The @code{BuildSlave} constructor can take an optional
2264 @code{max_builds} parameter to limit the number of builds that it will
2265 execute simultaneously:
2267 @example
2268 from buildbot.buildslave import BuildSlave
2269 c['slaves'] = [BuildSlave("bot-linux", "linuxpassword", max_builds=2)]
2270 @end example
2272 Historical note: in buildbot-0.7.5 and earlier, the @code{c['bots']}
2273 key was used instead, and it took a list of (name, password) tuples.
2274 This key is accepted for backwards compatibility, but is deprecated as
2275 of 0.7.6 and will go away in some future release.
2277 @node Defining Builders, Defining Status Targets, Buildslave Specifiers, Configuration
2278 @section Defining Builders
2280 @bcindex c['builders']
2282 The @code{c['builders']} key is a list of dictionaries which specify
2283 the Builders. The Buildmaster runs a collection of Builders, each of
2284 which handles a single type of build (e.g. full versus quick), on a
2285 single build slave. A Buildbot which makes sure that the latest code
2286 (``HEAD'') compiles correctly across four separate architecture will
2287 have four Builders, each performing the same build but on different
2288 slaves (one per platform).
2290 Each Builder gets a separate column in the waterfall display. In
2291 general, each Builder runs independently (although various kinds of
2292 interlocks can cause one Builder to have an effect on another).
2294 Each Builder specification dictionary has several required keys:
2296 @table @code
2297 @item name
2298 This specifies the Builder's name, which is used in status
2299 reports.
2301 @item slavename
2302 This specifies which buildslave will be used by this Builder.
2303 @code{slavename} must appear in the @code{c['slaves']} list. Each
2304 buildslave can accomodate multiple Builders.
2306 @item slavenames
2307 If you provide @code{slavenames} instead of @code{slavename}, you can
2308 give a list of buildslaves which are capable of running this Builder.
2309 If multiple buildslaves are available for any given Builder, you will
2310 have some measure of redundancy: in case one slave goes offline, the
2311 others can still keep the Builder working. In addition, multiple
2312 buildslaves will allow multiple simultaneous builds for the same
2313 Builder, which might be useful if you have a lot of forced or ``try''
2314 builds taking place.
2316 If you use this feature, it is important to make sure that the
2317 buildslaves are all, in fact, capable of running the given build. The
2318 slave hosts should be configured similarly, otherwise you will spend a
2319 lot of time trying (unsuccessfully) to reproduce a failure that only
2320 occurs on some of the buildslaves and not the others. Different
2321 platforms, operating systems, versions of major programs or libraries,
2322 all these things mean you should use separate Builders.
2324 @item builddir
2325 This specifies the name of a subdirectory (under the base directory)
2326 in which everything related to this builder will be placed. On the
2327 buildmaster, this holds build status information. On the buildslave,
2328 this is where checkouts, compiles, and tests are run.
2330 @item factory
2331 This is a @code{buildbot.process.factory.BuildFactory} instance which
2332 controls how the build is performed. Full details appear in their own
2333 chapter, @xref{Build Process}. Parameters like the location of the CVS
2334 repository and the compile-time options used for the build are
2335 generally provided as arguments to the factory's constructor.
2337 @end table
2339 Other optional keys may be set on each Builder:
2341 @table @code
2343 @item category
2344 If provided, this is a string that identifies a category for the
2345 builder to be a part of. Status clients can limit themselves to a
2346 subset of the available categories. A common use for this is to add
2347 new builders to your setup (for a new module, or for a new buildslave)
2348 that do not work correctly yet and allow you to integrate them with
2349 the active builders. You can put these new builders in a test
2350 category, make your main status clients ignore them, and have only
2351 private status clients pick them up. As soon as they work, you can
2352 move them over to the active category.
2354 @end table
2357 @node Defining Status Targets, Debug options, Defining Builders, Configuration
2358 @section Defining Status Targets
2360 The Buildmaster has a variety of ways to present build status to
2361 various users. Each such delivery method is a ``Status Target'' object
2362 in the configuration's @code{status} list. To add status targets, you
2363 just append more objects to this list:
2365 @bcindex c['status']
2367 @example
2368 c['status'] = []
2370 from buildbot.status import html
2371 c['status'].append(html.Waterfall(http_port=8010))
2373 from buildbot.status import mail
2374 m = mail.MailNotifier(fromaddr="buildbot@@localhost",
2375                       extraRecipients=["builds@@lists.example.com"],
2376                       sendToInterestedUsers=False)
2377 c['status'].append(m)
2379 from buildbot.status import words
2380 c['status'].append(words.IRC(host="irc.example.com", nick="bb",
2381                              channels=["#example"]))
2382 @end example
2384 Status delivery has its own chapter, @xref{Status Delivery}, in which
2385 all the built-in status targets are documented.
2388 @node Debug options,  , Defining Status Targets, Configuration
2389 @section Debug options
2392 @bcindex c['debugPassword']
2393 If you set @code{c['debugPassword']}, then you can connect to the
2394 buildmaster with the diagnostic tool launched by @code{buildbot
2395 debugclient MASTER:PORT}. From this tool, you can reload the config
2396 file, manually force builds, and inject changes, which may be useful
2397 for testing your buildmaster without actually commiting changes to
2398 your repository (or before you have the Change Sources set up). The
2399 debug tool uses the same port number as the slaves do:
2400 @code{c['slavePortnum']}, and is authenticated with this password.
2402 @example
2403 c['debugPassword'] = "debugpassword"
2404 @end example
2406 @bcindex c['manhole']
2407 If you set @code{c['manhole']} to an instance of one of the classes in
2408 @code{buildbot.manhole}, you can telnet or ssh into the buildmaster
2409 and get an interactive Python shell, which may be useful for debugging
2410 buildbot internals. It is probably only useful for buildbot
2411 developers. It exposes full access to the buildmaster's account
2412 (including the ability to modify and delete files), so it should not
2413 be enabled with a weak or easily guessable password.
2415 There are three separate @code{Manhole} classes. Two of them use SSH,
2416 one uses unencrypted telnet. Two of them use a username+password
2417 combination to grant access, one of them uses an SSH-style
2418 @file{authorized_keys} file which contains a list of ssh public keys.
2420 @table @code
2421 @item manhole.AuthorizedKeysManhole
2422 You construct this with the name of a file that contains one SSH
2423 public key per line, just like @file{~/.ssh/authorized_keys}. If you
2424 provide a non-absolute filename, it will be interpreted relative to
2425 the buildmaster's base directory.
2427 @item manhole.PasswordManhole
2428 This one accepts SSH connections but asks for a username and password
2429 when authenticating. It accepts only one such pair.
2432 @item manhole.TelnetManhole
2433 This accepts regular unencrypted telnet connections, and asks for a
2434 username/password pair before providing access. Because this
2435 username/password is transmitted in the clear, and because Manhole
2436 access to the buildmaster is equivalent to granting full shell
2437 privileges to both the buildmaster and all the buildslaves (and to all
2438 accounts which then run code produced by the buildslaves), it is
2439 highly recommended that you use one of the SSH manholes instead.
2441 @end table
2443 @example
2444 # some examples:
2445 from buildbot import manhole
2446 c['manhole'] = manhole.AuthorizedKeysManhole(1234, "authorized_keys")
2447 c['manhole'] = manhole.PasswordManhole(1234, "alice", "mysecretpassword")
2448 c['manhole'] = manhole.TelnetManhole(1234, "bob", "snoop_my_password_please")
2449 @end example
2451 The @code{Manhole} instance can be configured to listen on a specific
2452 port. You may wish to have this listening port bind to the loopback
2453 interface (sometimes known as ``lo0'', ``localhost'', or 127.0.0.1) to
2454 restrict access to clients which are running on the same host.
2456 @example
2457 from buildbot.manhole import PasswordManhole
2458 c['manhole'] = PasswordManhole("tcp:9999:interface=127.0.0.1","admin","passwd")
2459 @end example
2461 To have the @code{Manhole} listen on all interfaces, use
2462 @code{"tcp:9999"} or simply 9999. This port specification uses
2463 @code{twisted.application.strports}, so you can make it listen on SSL
2464 or even UNIX-domain sockets if you want.
2466 Note that using any Manhole requires that the TwistedConch package be
2467 installed, and that you be using Twisted version 2.0 or later.
2469 The buildmaster's SSH server will use a different host key than the
2470 normal sshd running on a typical unix host. This will cause the ssh
2471 client to complain about a ``host key mismatch'', because it does not
2472 realize there are two separate servers running on the same host. To
2473 avoid this, use a clause like the following in your @file{.ssh/config}
2474 file:
2476 @example
2477 Host remotehost-buildbot
2478  HostName remotehost
2479  HostKeyAlias remotehost-buildbot
2480  Port 9999
2481  # use 'user' if you use PasswordManhole and your name is not 'admin'.
2482  # if you use AuthorizedKeysManhole, this probably doesn't matter.
2483  User admin
2484 @end example
2487 @node Getting Source Code Changes, Build Process, Configuration, Top
2488 @chapter Getting Source Code Changes
2490 The most common way to use the Buildbot is centered around the idea of
2491 @code{Source Trees}: a directory tree filled with source code of some form
2492 which can be compiled and/or tested. Some projects use languages that don't
2493 involve any compilation step: nevertheless there may be a @code{build} phase
2494 where files are copied or rearranged into a form that is suitable for
2495 installation. Some projects do not have unit tests, and the Buildbot is
2496 merely helping to make sure that the sources can compile correctly. But in
2497 all of these cases, the thing-being-tested is a single source tree.
2499 A Version Control System mantains a source tree, and tells the
2500 buildmaster when it changes. The first step of each Build is typically
2501 to acquire a copy of some version of this tree.
2503 This chapter describes how the Buildbot learns about what Changes have
2504 occurred. For more information on VC systems and Changes, see
2505 @ref{Version Control Systems}.
2508 @menu
2509 * Change Sources::              
2510 * Choosing ChangeSources::      
2511 * CVSToys - PBService::         
2512 * Mail-parsing ChangeSources::  
2513 * PBChangeSource::              
2514 * P4Source::                    
2515 * BonsaiPoller::                
2516 * SVNPoller::                   
2517 * MercurialHook::               
2518 @end menu
2522 @node Change Sources, Choosing ChangeSources, Getting Source Code Changes, Getting Source Code Changes
2523 @section Change Sources
2525 @c TODO: rework this, the one-buildmaster-one-tree thing isn't quite
2526 @c so narrow-minded anymore
2528 Each Buildmaster watches a single source tree. Changes can be provided
2529 by a variety of ChangeSource types, however any given project will
2530 typically have only a single ChangeSource active. This section
2531 provides a description of all available ChangeSource types and
2532 explains how to set up each of them.
2534 There are a variety of ChangeSources available, some of which are
2535 meant to be used in conjunction with other tools to deliver Change
2536 events from the VC repository to the buildmaster.
2538 @itemize @bullet
2540 @item CVSToys
2541 This ChangeSource opens a TCP connection from the buildmaster to a
2542 waiting FreshCVS daemon that lives on the repository machine, and
2543 subscribes to hear about Changes.
2545 @item MaildirSource
2546 This one watches a local maildir-format inbox for email sent out by
2547 the repository when a change is made. When a message arrives, it is
2548 parsed to create the Change object. A variety of parsing functions are
2549 available to accomodate different email-sending tools.
2551 @item PBChangeSource
2552 This ChangeSource listens on a local TCP socket for inbound
2553 connections from a separate tool. Usually, this tool would be run on
2554 the VC repository machine in a commit hook. It is expected to connect
2555 to the TCP socket and send a Change message over the network
2556 connection. The @command{buildbot sendchange} command is one example
2557 of a tool that knows how to send these messages, so you can write a
2558 commit script for your VC system that calls it to deliver the Change.
2559 There are other tools in the contrib/ directory that use the same
2560 protocol.
2562 @end itemize
2564 As a quick guide, here is a list of VC systems and the ChangeSources
2565 that might be useful with them. All of these ChangeSources are in the
2566 @code{buildbot.changes} module.
2568 @table @code
2569 @item CVS
2571 @itemize @bullet
2572 @item freshcvs.FreshCVSSource (connected via TCP to the freshcvs daemon)
2573 @item mail.FCMaildirSource (watching for email sent by a freshcvs daemon)
2574 @item mail.BonsaiMaildirSource (watching for email sent by Bonsai)
2575 @item mail.SyncmailMaildirSource (watching for email sent by syncmail)
2576 @item pb.PBChangeSource (listening for connections from @code{buildbot
2577 sendchange} run in a loginfo script)
2578 @item pb.PBChangeSource (listening for connections from a long-running
2579 @code{contrib/viewcvspoll.py} polling process which examines the ViewCVS
2580 database directly
2581 @end itemize
2583 @item SVN
2584 @itemize @bullet
2585 @item pb.PBChangeSource (listening for connections from
2586 @code{contrib/svn_buildbot.py} run in a postcommit script)
2587 @item pb.PBChangeSource (listening for connections from a long-running
2588 @code{contrib/svn_watcher.py} or @code{contrib/svnpoller.py} polling
2589 process
2590 @item mail.SVNCommitEmailMaildirSource (watching for email sent by commit-email.pl)
2591 @item svnpoller.SVNPoller (polling the SVN repository)
2592 @end itemize
2594 @item Darcs
2595 @itemize @bullet
2596 @item pb.PBChangeSource (listening for connections from
2597 @code{contrib/darcs_buildbot.py} in a commit script
2598 @end itemize
2600 @item Mercurial
2601 @itemize @bullet
2602 @item pb.PBChangeSource (listening for connections from
2603 @code{contrib/hg_buildbot.py} run in an 'incoming' hook)
2604 @item pb.PBChangeSource (listening for connections from
2605 @code{buildbot/changes/hgbuildbot.py} run as an in-process 'changegroup'
2606 hook)
2607 @end itemize
2609 @item Arch/Bazaar
2610 @itemize @bullet
2611 @item pb.PBChangeSource (listening for connections from
2612 @code{contrib/arch_buildbot.py} run in a commit hook)
2613 @end itemize
2615 @end table
2617 All VC systems can be driven by a PBChangeSource and the
2618 @code{buildbot sendchange} tool run from some form of commit script.
2619 If you write an email parsing function, they can also all be driven by
2620 a suitable @code{MaildirSource}.
2623 @node Choosing ChangeSources, CVSToys - PBService, Change Sources, Getting Source Code Changes
2624 @section Choosing ChangeSources
2626 The @code{master.cfg} configuration file has a dictionary key named
2627 @code{BuildmasterConfig['change_source']}, which holds the active
2628 @code{IChangeSource} object. The config file will typically create an
2629 object from one of the classes described below and stuff it into this
2630 key.
2632 Each buildmaster typically has just a single ChangeSource, since it is
2633 only watching a single source tree. But if, for some reason, you need
2634 multiple sources, just set @code{c['change_source']} to a list of
2635 ChangeSources.. it will accept that too.
2637 @example
2638 s = FreshCVSSourceNewcred(host="host", port=4519,
2639                           user="alice", passwd="secret",
2640                           prefix="Twisted")
2641 BuildmasterConfig['change_source'] = [s]
2642 @end example
2644 Each source tree has a nominal @code{top}. Each Change has a list of
2645 filenames, which are all relative to this top location. The
2646 ChangeSource is responsible for doing whatever is necessary to
2647 accomplish this. Most sources have a @code{prefix} argument: a partial
2648 pathname which is stripped from the front of all filenames provided to
2649 that @code{ChangeSource}. Files which are outside this sub-tree are
2650 ignored by the changesource: it does not generate Changes for those
2651 files.
2654 @node CVSToys - PBService, Mail-parsing ChangeSources, Choosing ChangeSources, Getting Source Code Changes
2655 @section CVSToys - PBService
2657 @csindex buildbot.changes.freshcvs.FreshCVSSource
2659 The @uref{http://purl.net/net/CVSToys, CVSToys} package provides a
2660 server which runs on the machine that hosts the CVS repository it
2661 watches. It has a variety of ways to distribute commit notifications,
2662 and offers a flexible regexp-based way to filter out uninteresting
2663 changes. One of the notification options is named @code{PBService} and
2664 works by listening on a TCP port for clients. These clients subscribe
2665 to hear about commit notifications.
2667 The buildmaster has a CVSToys-compatible @code{PBService} client built
2668 in. There are two versions of it, one for old versions of CVSToys
2669 (1.0.9 and earlier) which used the @code{oldcred} authentication
2670 framework, and one for newer versions (1.0.10 and later) which use
2671 @code{newcred}. Both are classes in the
2672 @code{buildbot.changes.freshcvs} package.
2674 @code{FreshCVSSourceNewcred} objects are created with the following
2675 parameters:
2677 @table @samp
2679 @item @code{host} and @code{port}
2680 these specify where the CVSToys server can be reached
2682 @item @code{user} and @code{passwd}
2683 these specify the login information for the CVSToys server
2684 (@code{freshcvs}). These must match the server's values, which are
2685 defined in the @code{freshCfg} configuration file (which lives in the
2686 CVSROOT directory of the repository).
2688 @item @code{prefix}
2689 this is the prefix to be found and stripped from filenames delivered
2690 by the CVSToys server. Most projects live in sub-directories of the
2691 main repository, as siblings of the CVSROOT sub-directory, so
2692 typically this prefix is set to that top sub-directory name.
2694 @end table
2696 @heading Example
2698 To set up the freshCVS server, add a statement like the following to
2699 your @file{freshCfg} file:
2701 @example
2702 pb = ConfigurationSet([
2703     (None, None, None, PBService(userpass=('foo', 'bar'), port=4519)),
2704     ])
2705 @end example
2707 This will announce all changes to a client which connects to port 4519
2708 using a username of 'foo' and a password of 'bar'.
2710 Then add a clause like this to your buildmaster's @file{master.cfg}:
2712 @example
2713 BuildmasterConfig['change_source'] = FreshCVSSource("cvs.example.com", 4519,
2714                                                     "foo", "bar",
2715                                                     prefix="glib/")
2716 @end example
2718 where "cvs.example.com" is the host that is running the FreshCVS daemon, and
2719 "glib" is the top-level directory (relative to the repository's root) where
2720 all your source code lives. Most projects keep one or more projects in the
2721 same repository (along with CVSROOT/ to hold admin files like loginfo and
2722 freshCfg); the prefix= argument tells the buildmaster to ignore everything
2723 outside that directory, and to strip that common prefix from all pathnames
2724 it handles.
2727 @node Mail-parsing ChangeSources, PBChangeSource, CVSToys - PBService, Getting Source Code Changes
2728 @section Mail-parsing ChangeSources
2730 Many projects publish information about changes to their source tree
2731 by sending an email message out to a mailing list, frequently named
2732 PROJECT-commits or PROJECT-changes. Each message usually contains a
2733 description of the change (who made the change, which files were
2734 affected) and sometimes a copy of the diff. Humans can subscribe to
2735 this list to stay informed about what's happening to the source tree.
2737 The Buildbot can also be subscribed to a -commits mailing list, and
2738 can trigger builds in response to Changes that it hears about. The
2739 buildmaster admin needs to arrange for these email messages to arrive
2740 in a place where the buildmaster can find them, and configure the
2741 buildmaster to parse the messages correctly. Once that is in place,
2742 the email parser will create Change objects and deliver them to the
2743 Schedulers (see @pxref{Scheduler Types}) just like any other
2744 ChangeSource.
2746 There are two components to setting up an email-based ChangeSource.
2747 The first is to route the email messages to the buildmaster, which is
2748 done by dropping them into a ``maildir''. The second is to actually
2749 parse the messages, which is highly dependent upon the tool that was
2750 used to create them. Each VC system has a collection of favorite
2751 change-emailing tools, and each has a slightly different format, so
2752 each has a different parsing function. There is a separate
2753 ChangeSource variant for each parsing function.
2755 Once you've chosen a maildir location and a parsing function, create
2756 the change source and put it in @code{c['change_source']}:
2758 @example
2759 from buildbot.changes.mail import SyncmailMaildirSource
2760 c['change_source'] = SyncmailMaildirSource("~/maildir-buildbot",
2761                                            prefix="/trunk/")
2762 @end example
2764 @menu
2765 * Subscribing the Buildmaster::  
2766 * Using Maildirs::              
2767 * Parsing Email Change Messages::  
2768 @end menu
2770 @node Subscribing the Buildmaster, Using Maildirs, Mail-parsing ChangeSources, Mail-parsing ChangeSources
2771 @subsection Subscribing the Buildmaster
2773 The recommended way to install the buildbot is to create a dedicated
2774 account for the buildmaster. If you do this, the account will probably
2775 have a distinct email address (perhaps
2776 @email{buildmaster@@example.org}). Then just arrange for this
2777 account's email to be delivered to a suitable maildir (described in
2778 the next section).
2780 If the buildbot does not have its own account, ``extension addresses''
2781 can be used to distinguish between email intended for the buildmaster
2782 and email intended for the rest of the account. In most modern MTAs,
2783 the e.g. @code{foo@@example.org} account has control over every email
2784 address at example.org which begins with "foo", such that email
2785 addressed to @email{account-foo@@example.org} can be delivered to a
2786 different destination than @email{account-bar@@example.org}. qmail
2787 does this by using separate .qmail files for the two destinations
2788 (@file{.qmail-foo} and @file{.qmail-bar}, with @file{.qmail}
2789 controlling the base address and @file{.qmail-default} controlling all
2790 other extensions). Other MTAs have similar mechanisms.
2792 Thus you can assign an extension address like
2793 @email{foo-buildmaster@@example.org} to the buildmaster, and retain
2794 @email{foo@@example.org} for your own use.
2797 @node Using Maildirs, Parsing Email Change Messages, Subscribing the Buildmaster, Mail-parsing ChangeSources
2798 @subsection Using Maildirs
2800 A ``maildir'' is a simple directory structure originally developed for
2801 qmail that allows safe atomic update without locking. Create a base
2802 directory with three subdirectories: ``new'', ``tmp'', and ``cur''.
2803 When messages arrive, they are put into a uniquely-named file (using
2804 pids, timestamps, and random numbers) in ``tmp''. When the file is
2805 complete, it is atomically renamed into ``new''. Eventually the
2806 buildmaster notices the file in ``new'', reads and parses the
2807 contents, then moves it into ``cur''. A cronjob can be used to delete
2808 files in ``cur'' at leisure.
2810 Maildirs are frequently created with the @command{maildirmake} tool,
2811 but a simple @command{mkdir -p ~/MAILDIR/@{cur,new,tmp@}} is pretty much
2812 equivalent.
2814 Many modern MTAs can deliver directly to maildirs. The usual .forward
2815 or .procmailrc syntax is to name the base directory with a trailing
2816 slash, so something like @code{~/MAILDIR/} . qmail and postfix are
2817 maildir-capable MTAs, and procmail is a maildir-capable MDA (Mail
2818 Delivery Agent).
2820 For MTAs which cannot put files into maildirs directly, the
2821 ``safecat'' tool can be executed from a .forward file to accomplish
2822 the same thing.
2824 The Buildmaster uses the linux DNotify facility to receive immediate
2825 notification when the maildir's ``new'' directory has changed. When
2826 this facility is not available, it polls the directory for new
2827 messages, every 10 seconds by default.
2829 @node Parsing Email Change Messages,  , Using Maildirs, Mail-parsing ChangeSources
2830 @subsection Parsing Email Change Messages
2832 The second component to setting up an email-based ChangeSource is to
2833 parse the actual notices. This is highly dependent upon the VC system
2834 and commit script in use.
2836 A couple of common tools used to create these change emails are:
2838 @table @samp
2840 @item CVS
2841 @table @samp
2842 @item CVSToys MailNotifier
2843 @ref{FCMaildirSource}
2844 @item Bonsai notification
2845 @ref{BonsaiMaildirSource}
2846 @item syncmail
2847 @ref{SyncmailMaildirSource}
2848 @end table
2850 @item SVN
2851 @table @samp
2852 @item svnmailer
2853 http://opensource.perlig.de/en/svnmailer/
2854 @item commit-email.pl
2855 @ref{SVNCommitEmailMaildirSource}
2856 @end table
2858 @item Mercurial
2859 @table @samp
2860 @item NotifyExtension
2861 http://www.selenic.com/mercurial/wiki/index.cgi/NotifyExtension
2862 @end table
2864 @end table
2867 The following sections describe the parsers available for each of
2868 these tools.
2870 Most of these parsers accept a @code{prefix=} argument, which is used
2871 to limit the set of files that the buildmaster pays attention to. This
2872 is most useful for systems like CVS and SVN which put multiple
2873 projects in a single repository (or use repository names to indicate
2874 branches). Each filename that appears in the email is tested against
2875 the prefix: if the filename does not start with the prefix, the file
2876 is ignored. If the filename @emph{does} start with the prefix, that
2877 prefix is stripped from the filename before any further processing is
2878 done. Thus the prefix usually ends with a slash.
2880 @menu
2881 * FCMaildirSource::             
2882 * SyncmailMaildirSource::       
2883 * BonsaiMaildirSource::         
2884 * SVNCommitEmailMaildirSource::  
2885 @end menu
2887 @node FCMaildirSource, SyncmailMaildirSource, Parsing Email Change Messages, Parsing Email Change Messages
2888 @subsubsection FCMaildirSource
2891 @csindex buildbot.changes.mail.FCMaildirSource
2893 http://twistedmatrix.com/users/acapnotic/wares/code/CVSToys/
2895 This parser works with the CVSToys @code{MailNotification} action,
2896 which will send email to a list of recipients for each commit. This
2897 tends to work better than using @code{/bin/mail} from within the
2898 CVSROOT/loginfo file directly, as CVSToys will batch together all
2899 files changed during the same CVS invocation, and can provide more
2900 information (like creating a ViewCVS URL for each file changed).
2902 The Buildbot's @code{FCMaildirSource} knows for to parse these CVSToys
2903 messages and turn them into Change objects. It can be given two
2904 parameters: the directory name of the maildir root, and the prefix to
2905 strip.
2907 @example
2908 from buildbot.changes.mail import FCMaildirSource
2909 c['change_source'] = FCMaildirSource("~/maildir-buildbot")
2910 @end example
2912 @node SyncmailMaildirSource, BonsaiMaildirSource, FCMaildirSource, Parsing Email Change Messages
2913 @subsubsection SyncmailMaildirSource
2915 @csindex buildbot.changes.mail.SyncmailMaildirSource
2917 http://sourceforge.net/projects/cvs-syncmail
2919 @code{SyncmailMaildirSource} knows how to parse the message format used by
2920 the CVS ``syncmail'' script.
2922 @example
2923 from buildbot.changes.mail import SyncmailMaildirSource
2924 c['change_source'] = SyncmailMaildirSource("~/maildir-buildbot")
2925 @end example
2927 @node BonsaiMaildirSource, SVNCommitEmailMaildirSource, SyncmailMaildirSource, Parsing Email Change Messages
2928 @subsubsection BonsaiMaildirSource
2930 @csindex buildbot.changes.mail.BonsaiMaildirSource
2932 http://www.mozilla.org/bonsai.html
2934 @code{BonsaiMaildirSource} parses messages sent out by Bonsai, the CVS
2935 tree-management system built by Mozilla.
2937 @example
2938 from buildbot.changes.mail import BonsaiMaildirSource
2939 c['change_source'] = BonsaiMaildirSource("~/maildir-buildbot")
2940 @end example
2942 @node SVNCommitEmailMaildirSource,  , BonsaiMaildirSource, Parsing Email Change Messages
2943 @subsubsection SVNCommitEmailMaildirSource
2945 @csindex buildbot.changes.mail.SVNCommitEmailMaildirSource
2947 @code{SVNCommitEmailMaildirSource} parses message sent out by the
2948 @code{commit-email.pl} script, which is included in the Subversion
2949 distribution.
2951 It does not currently handle branches: all of the Change objects that
2952 it creates will be associated with the default (i.e. trunk) branch.
2954 @example
2955 from buildbot.changes.mail import SVNCommitEmailMaildirSource
2956 c['change_source'] = SVNCommitEmailMaildirSource("~/maildir-buildbot")
2957 @end example
2960 @node PBChangeSource, P4Source, Mail-parsing ChangeSources, Getting Source Code Changes
2961 @section PBChangeSource
2963 @csindex buildbot.changes.pb.PBChangeSource
2965 The last kind of ChangeSource actually listens on a TCP port for
2966 clients to connect and push change notices @emph{into} the
2967 Buildmaster. This is used by the built-in @code{buildbot sendchange}
2968 notification tool, as well as the VC-specific
2969 @file{contrib/svn_buildbot.py}, @file{contrib/arch_buildbot.py},
2970 @file{contrib/hg_buildbot.py} tools, and the
2971 @code{buildbot.changes.hgbuildbot} hook. These tools are run by the
2972 repository (in a commit hook script), and connect to the buildmaster
2973 directly each time a file is comitted. This is also useful for
2974 creating new kinds of change sources that work on a @code{push} model
2975 instead of some kind of subscription scheme, for example a script
2976 which is run out of an email .forward file.
2978 This ChangeSource can be configured to listen on its own TCP port, or
2979 it can share the port that the buildmaster is already using for the
2980 buildslaves to connect. (This is possible because the
2981 @code{PBChangeSource} uses the same protocol as the buildslaves, and
2982 they can be distinguished by the @code{username} attribute used when
2983 the initial connection is established). It might be useful to have it
2984 listen on a different port if, for example, you wanted to establish
2985 different firewall rules for that port. You could allow only the SVN
2986 repository machine access to the @code{PBChangeSource} port, while
2987 allowing only the buildslave machines access to the slave port. Or you
2988 could just expose one port and run everything over it. @emph{Note:
2989 this feature is not yet implemented, the PBChangeSource will always
2990 share the slave port and will always have a @code{user} name of
2991 @code{change}, and a passwd of @code{changepw}. These limitations will
2992 be removed in the future.}.
2995 The @code{PBChangeSource} is created with the following arguments. All
2996 are optional.
2998 @table @samp
2999 @item @code{port}
3000 which port to listen on. If @code{None} (which is the default), it
3001 shares the port used for buildslave connections. @emph{Not
3002 Implemented, always set to @code{None}}.
3004 @item @code{user} and @code{passwd}
3005 The user/passwd account information that the client program must use
3006 to connect. Defaults to @code{change} and @code{changepw}. @emph{Not
3007 Implemented, @code{user} is currently always set to @code{change},
3008 @code{passwd} is always set to @code{changepw}}.
3010 @item @code{prefix}
3011 The prefix to be found and stripped from filenames delivered over the
3012 connection. Any filenames which do not start with this prefix will be
3013 removed. If all the filenames in a given Change are removed, the that
3014 whole Change will be dropped. This string should probably end with a
3015 directory separator.
3017 This is useful for changes coming from version control systems that
3018 represent branches as parent directories within the repository (like
3019 SVN and Perforce). Use a prefix of 'trunk/' or
3020 'project/branches/foobranch/' to only follow one branch and to get
3021 correct tree-relative filenames. Without a prefix, the PBChangeSource
3022 will probably deliver Changes with filenames like @file{trunk/foo.c}
3023 instead of just @file{foo.c}. Of course this also depends upon the
3024 tool sending the Changes in (like @command{buildbot sendchange}) and
3025 what filenames it is delivering: that tool may be filtering and
3026 stripping prefixes at the sending end.
3028 @end table
3030 @node P4Source, BonsaiPoller, PBChangeSource, Getting Source Code Changes
3031 @section P4Source
3033 @csindex buildbot.changes.p4poller.P4Source
3035 The @code{P4Source} periodically polls a @uref{http://www.perforce.com/,
3036 Perforce} depot for changes. It accepts the following arguments:
3038 @table @samp
3039 @item @code{p4base}
3040 The base depot path to watch, without the trailing '/...'.
3042 @item @code{p4port}
3043 The Perforce server to connect to (as host:port).
3045 @item @code{p4user}
3046 The Perforce user.
3048 @item @code{p4passwd}
3049 The Perforce password.
3051 @item @code{split_file}
3052 A function that maps a pathname, without the leading @code{p4base}, to a
3053 (branch, filename) tuple. The default just returns (None, branchfile),
3054 which effectively disables branch support. You should supply a function
3055 which understands your repository structure.
3057 @item @code{pollinterval}
3058 How often to poll, in seconds. Defaults to 600 (10 minutes).
3060 @item @code{histmax}
3061 The maximum number of changes to inspect at a time. If more than this
3062 number occur since the last poll, older changes will be silently
3063 ignored.
3064 @end table
3066 @heading Example
3068 This configuration uses the @code{P4PORT}, @code{P4USER}, and @code{P4PASSWD}
3069 specified in the buildmaster's environment. It watches a project in which the
3070 branch name is simply the next path component, and the file is all path
3071 components after.
3073 @example
3074 import buildbot.changes.p4poller
3075 s = p4poller.P4Source(p4base='//depot/project/',
3076                       split_file=lambda branchfile: branchfile.split('/',1),
3077                      )
3078 c['change_source'] = s
3079 @end example
3081 @node BonsaiPoller, SVNPoller, P4Source, Getting Source Code Changes
3082 @section BonsaiPoller
3084 @csindex buildbot.changes.bonsaipoller.BonsaiPoller
3086 The @code{BonsaiPoller} periodically polls a Bonsai server. This is a
3087 CGI script accessed through a web server that provides information
3088 about a CVS tree, for example the Mozilla bonsai server at
3089 @uref{http://bonsai.mozilla.org}. Bonsai servers are usable by both
3090 humans and machines. In this case, the buildbot's change source forms
3091 a query which asks about any files in the specified branch which have
3092 changed since the last query.
3094 Please take a look at the BonsaiPoller docstring for details about the
3095 arguments it accepts.
3098 @node SVNPoller, MercurialHook, BonsaiPoller, Getting Source Code Changes
3099 @section SVNPoller
3101 @csindex buildbot.changes.svnpoller.SVNPoller
3103 The @code{buildbot.changes.svnpoller.SVNPoller} is a ChangeSource
3104 which periodically polls a @uref{http://subversion.tigris.org/,
3105 Subversion} repository for new revisions, by running the @code{svn
3106 log} command in a subshell. It can watch a single branch or multiple
3107 branches.
3109 @code{SVNPoller} accepts the following arguments:
3111 @table @code
3112 @item svnurl
3113 The base URL path to watch, like
3114 @code{svn://svn.twistedmatrix.com/svn/Twisted/trunk}, or
3115 @code{http://divmod.org/svn/Divmod/}, or even
3116 @code{file:///home/svn/Repository/ProjectA/branches/1.5/}. This must
3117 include the access scheme, the location of the repository (both the
3118 hostname for remote ones, and any additional directory names necessary
3119 to get to the repository), and the sub-path within the repository's
3120 virtual filesystem for the project and branch of interest.
3122 The @code{SVNPoller} will only pay attention to files inside the
3123 subdirectory specified by the complete svnurl.
3125 @item split_file
3126 A function to convert pathnames into (branch, relative_pathname)
3127 tuples. Use this to explain your repository's branch-naming policy to
3128 @code{SVNPoller}. This function must accept a single string and return
3129 a two-entry tuple. There are a few utility functions in
3130 @code{buildbot.changes.svnpoller} that can be used as a
3131 @code{split_file} function, see below for details.
3133 The default value always returns (None, path), which indicates that
3134 all files are on the trunk.
3136 Subclasses of @code{SVNPoller} can override the @code{split_file}
3137 method instead of using the @code{split_file=} argument.
3139 @item svnuser
3140 An optional string parameter. If set, the @code{--user} argument will
3141 be added to all @code{svn} commands. Use this if you have to
3142 authenticate to the svn server before you can do @code{svn info} or
3143 @code{svn log} commands.
3145 @item svnpasswd
3146 Like @code{svnuser}, this will cause a @code{--password} argument to
3147 be passed to all svn commands.
3149 @item pollinterval
3150 How often to poll, in seconds. Defaults to 600 (checking once every 10
3151 minutes). Lower this if you want the buildbot to notice changes
3152 faster, raise it if you want to reduce the network and CPU load on
3153 your svn server. Please be considerate of public SVN repositories by
3154 using a large interval when polling them.
3156 @item histmax
3157 The maximum number of changes to inspect at a time. Every POLLINTERVAL
3158 seconds, the @code{SVNPoller} asks for the last HISTMAX changes and
3159 looks through them for any ones it does not already know about. If
3160 more than HISTMAX revisions have been committed since the last poll,
3161 older changes will be silently ignored. Larger values of histmax will
3162 cause more time and memory to be consumed on each poll attempt.
3163 @code{histmax} defaults to 100.
3165 @item svnbin
3166 This controls the @code{svn} executable to use. If subversion is
3167 installed in a weird place on your system (outside of the
3168 buildmaster's @code{$PATH}), use this to tell @code{SVNPoller} where
3169 to find it. The default value of ``svn'' will almost always be
3170 sufficient.
3172 @end table
3174 @heading Branches
3176 Each source file that is tracked by a Subversion repository has a
3177 fully-qualified SVN URL in the following form:
3178 (REPOURL)(PROJECT-plus-BRANCH)(FILEPATH). When you create the
3179 @code{SVNPoller}, you give it a @code{svnurl} value that includes all
3180 of the REPOURL and possibly some portion of the PROJECT-plus-BRANCH
3181 string. The @code{SVNPoller} is responsible for producing Changes that
3182 contain a branch name and a FILEPATH (which is relative to the top of
3183 a checked-out tree). The details of how these strings are split up
3184 depend upon how your repository names its branches.
3186 @subheading PROJECT/BRANCHNAME/FILEPATH repositories
3188 One common layout is to have all the various projects that share a
3189 repository get a single top-level directory each. Then under a given
3190 project's directory, you get two subdirectories, one named ``trunk''
3191 and another named ``branches''. Under ``branches'' you have a bunch of
3192 other directories, one per branch, with names like ``1.5.x'' and
3193 ``testing''. It is also common to see directories like ``tags'' and
3194 ``releases'' next to ``branches'' and ``trunk''.
3196 For example, the Twisted project has a subversion server on
3197 ``svn.twistedmatrix.com'' that hosts several sub-projects. The
3198 repository is available through a SCHEME of ``svn:''. The primary
3199 sub-project is Twisted, of course, with a repository root of
3200 ``svn://svn.twistedmatrix.com/svn/Twisted''. Another sub-project is
3201 Informant, with a root of
3202 ``svn://svn.twistedmatrix.com/svn/Informant'', etc. Inside any
3203 checked-out Twisted tree, there is a file named bin/trial (which is
3204 used to run unit test suites).
3206 The trunk for Twisted is in
3207 ``svn://svn.twistedmatrix.com/svn/Twisted/trunk'', and the
3208 fully-qualified SVN URL for the trunk version of @code{trial} would be
3209 ``svn://svn.twistedmatrix.com/svn/Twisted/trunk/bin/trial''. The same
3210 SVNURL for that file on a branch named ``1.5.x'' would be
3211 ``svn://svn.twistedmatrix.com/svn/Twisted/branches/1.5.x/bin/trial''.
3213 To set up a @code{SVNPoller} that watches the Twisted trunk (and
3214 nothing else), we would use the following:
3216 @example
3217 from buildbot.changes.svnpoller import SVNPoller
3218 c['change_source'] = SVNPoller("svn://svn.twistedmatrix.com/svn/Twisted/trunk")
3219 @end example
3221 In this case, every Change that our @code{SVNPoller} produces will
3222 have @code{.branch=None}, to indicate that the Change is on the trunk.
3223 No other sub-projects or branches will be tracked.
3225 If we want our ChangeSource to follow multiple branches, we have to do
3226 two things. First we have to change our @code{svnurl=} argument to
3227 watch more than just ``.../Twisted/trunk''. We will set it to
3228 ``.../Twisted'' so that we'll see both the trunk and all the branches.
3229 Second, we have to tell @code{SVNPoller} how to split the
3230 (PROJECT-plus-BRANCH)(FILEPATH) strings it gets from the repository
3231 out into (BRANCH) and (FILEPATH) pairs.
3233 We do the latter by providing a ``split_file'' function. This function
3234 is responsible for splitting something like
3235 ``branches/1.5.x/bin/trial'' into @code{branch}=''branches/1.5.x'' and
3236 @code{filepath}=''bin/trial''. This function is always given a string
3237 that names a file relative to the subdirectory pointed to by the
3238 @code{SVNPoller}'s @code{svnurl=} argument. It is expected to return a
3239 (BRANCHNAME, FILEPATH) tuple (in which FILEPATH is relative to the
3240 branch indicated), or None to indicate that the file is outside any
3241 project of interest.
3243 (note that we want to see ``branches/1.5.x'' rather than just
3244 ``1.5.x'' because when we perform the SVN checkout, we will probably
3245 append the branch name to the baseURL, which requires that we keep the
3246 ``branches'' component in there. Other VC schemes use a different
3247 approach towards branches and may not require this artifact.)
3249 If your repository uses this same PROJECT/BRANCH/FILEPATH naming
3250 scheme, the following function will work:
3252 @example
3253 def split_file_branches(path):
3254     pieces = path.split('/')
3255     if pieces[0] == 'trunk':
3256         return (None, '/'.join(pieces[1:]))
3257     elif pieces[0] == 'branches':
3258         return ('/'.join(pieces[0:2]),
3259                 '/'.join(pieces[2:]))
3260     else:
3261         return None
3262 @end example
3264 This function is provided as
3265 @code{buildbot.changes.svnpoller.split_file_branches} for your
3266 convenience. So to have our Twisted-watching @code{SVNPoller} follow
3267 multiple branches, we would use this:
3269 @example
3270 from buildbot.changes.svnpoller import SVNPoller, split_file_branches
3271 c['change_source'] = SVNPoller("svn://svn.twistedmatrix.com/svn/Twisted",
3272                                split_file=split_file_branches)
3273 @end example
3275 Changes for all sorts of branches (with names like ``branches/1.5.x'',
3276 and None to indicate the trunk) will be delivered to the Schedulers.
3277 Each Scheduler is then free to use or ignore each branch as it sees
3278 fit.
3280 @subheading BRANCHNAME/PROJECT/FILEPATH repositories
3282 Another common way to organize a Subversion repository is to put the
3283 branch name at the top, and the projects underneath. This is
3284 especially frequent when there are a number of related sub-projects
3285 that all get released in a group.
3287 For example, Divmod.org hosts a project named ``Nevow'' as well as one
3288 named ``Quotient''. In a checked-out Nevow tree there is a directory
3289 named ``formless'' that contains a python source file named
3290 ``webform.py''. This repository is accessible via webdav (and thus
3291 uses an ``http:'' scheme) through the divmod.org hostname. There are
3292 many branches in this repository, and they use a
3293 (BRANCHNAME)/(PROJECT) naming policy.
3295 The fully-qualified SVN URL for the trunk version of webform.py is
3296 @code{http://divmod.org/svn/Divmod/trunk/Nevow/formless/webform.py}.
3297 You can do an @code{svn co} with that URL and get a copy of the latest
3298 version. The 1.5.x branch version of this file would have a URL of
3299 @code{http://divmod.org/svn/Divmod/branches/1.5.x/Nevow/formless/webform.py}.
3300 The whole Nevow trunk would be checked out with
3301 @code{http://divmod.org/svn/Divmod/trunk/Nevow}, while the Quotient
3302 trunk would be checked out using
3303 @code{http://divmod.org/svn/Divmod/trunk/Quotient}.
3305 Now suppose we want to have an @code{SVNPoller} that only cares about
3306 the Nevow trunk. This case looks just like the PROJECT/BRANCH layout
3307 described earlier:
3309 @example
3310 from buildbot.changes.svnpoller import SVNPoller
3311 c['change_source'] = SVNPoller("http://divmod.org/svn/Divmod/trunk/Nevow")
3312 @end example
3314 But what happens when we want to track multiple Nevow branches? We
3315 have to point our @code{svnurl=} high enough to see all those
3316 branches, but we also don't want to include Quotient changes (since
3317 we're only building Nevow). To accomplish this, we must rely upon the
3318 @code{split_file} function to help us tell the difference between
3319 files that belong to Nevow and those that belong to Quotient, as well
3320 as figuring out which branch each one is on.
3322 @example
3323 from buildbot.changes.svnpoller import SVNPoller
3324 c['change_source'] = SVNPoller("http://divmod.org/svn/Divmod",
3325                                split_file=my_file_splitter)
3326 @end example
3328 The @code{my_file_splitter} function will be called with
3329 repository-relative pathnames like:
3331 @table @code
3332 @item trunk/Nevow/formless/webform.py
3333 This is a Nevow file, on the trunk. We want the Change that includes this
3334 to see a filename of @code{formless/webform.py"}, and a branch of None
3336 @item branches/1.5.x/Nevow/formless/webform.py
3337 This is a Nevow file, on a branch. We want to get
3338 branch=''branches/1.5.x'' and filename=''formless/webform.py''.
3340 @item trunk/Quotient/setup.py
3341 This is a Quotient file, so we want to ignore it by having
3342 @code{my_file_splitter} return None.
3344 @item branches/1.5.x/Quotient/setup.py
3345 This is also a Quotient file, which should be ignored.
3346 @end table
3348 The following definition for @code{my_file_splitter} will do the job:
3350 @example
3351 def my_file_splitter(path):
3352     pieces = path.split('/')
3353     if pieces[0] == 'trunk':
3354         branch = None
3355         pieces.pop(0) # remove 'trunk'
3356     elif pieces[0] == 'branches':
3357         pieces.pop(0) # remove 'branches'
3358         # grab branch name
3359         branch = 'branches/' + pieces.pop(0)
3360     else:
3361         return None # something weird
3362     projectname = pieces.pop(0)
3363     if projectname != 'Nevow':
3364         return None # wrong project
3365     return (branch, '/'.join(pieces))
3366 @end example
3368 @node MercurialHook,  , SVNPoller, Getting Source Code Changes
3369 @section MercurialHook
3371 Since Mercurial is written in python, the hook script can invoke
3372 Buildbot's @code{sendchange} function directly, rather than having to
3373 spawn an external process. This function delivers the same sort of
3374 changes as @code{buildbot sendchange} and the various hook scripts in
3375 contrib/, so you'll need to add a @code{pb.PBChangeSource} to your
3376 buildmaster to receive these changes.
3378 To set this up, first choose a Mercurial repository that represents
3379 your central ``official'' source tree. This will be the same
3380 repository that your buildslaves will eventually pull from. Install
3381 Buildbot on the machine that hosts this repository, using the same
3382 version of python as Mercurial is using (so that the Mercurial hook
3383 can import code from buildbot). Then add the following to the
3384 @code{.hg/hgrc} file in that repository, replacing the buildmaster
3385 hostname/portnumber as appropriate for your buildbot:
3387 @example
3388 [hooks]
3389 changegroup.buildbot = python:buildbot.changes.hgbuildbot.hook
3391 [hgbuildbot]
3392 master = buildmaster.example.org:9987
3393 @end example
3395 (Note that Mercurial lets you define multiple @code{changegroup} hooks
3396 by giving them distinct names, like @code{changegroup.foo} and
3397 @code{changegroup.bar}, which is why we use
3398 @code{changegroup.buildbot} in this example. There is nothing magical
3399 about the ``buildbot'' suffix in the hook name. The
3400 @code{[hgbuildbot]} section @emph{is} special, however, as it is the
3401 only section that the buildbot hook pays attention to.)
3403 Also note that this runs as a @code{changegroup} hook, rather than as
3404 an @code{incoming} hook. The @code{changegroup} hook is run with
3405 multiple revisions at a time (say, if multiple revisions are being
3406 pushed to this repository in a single @command{hg push} command),
3407 whereas the @code{incoming} hook is run with just one revision at a
3408 time. The @code{hgbuildbot.hook} function will only work with the
3409 @code{changegroup} hook.
3411 The @code{[hgbuildbot]} section has two other parameters that you
3412 might specify, both of which control the name of the branch that is
3413 attached to the changes coming from this hook.
3415 One common branch naming policy for Mercurial repositories is to use
3416 it just like Darcs: each branch goes into a separate repository, and
3417 all the branches for a single project share a common parent directory.
3418 For example, you might have @file{/var/repos/PROJECT/trunk/} and
3419 @file{/var/repos/PROJECT/release}. To use this style, use the
3420 @code{branchtype = dirname} setting, which simply uses the last
3421 component of the repository's enclosing directory as the branch name:
3423 @example
3424 [hgbuildbot]
3425 master = buildmaster.example.org:9987
3426 branchtype = dirname
3427 @end example
3429 Another approach is to use Mercurial's built-in branches (the kind
3430 created with @command{hg branch} and listed with @command{hg
3431 branches}). This feature associates persistent names with particular
3432 lines of descent within a single repository. (note that the buildbot
3433 @code{source.Mercurial} checkout step does not yet support this kind
3434 of branch). To have the commit hook deliver this sort of branch name
3435 with the Change object, use @code{branchtype = inrepo}:
3437 @example
3438 [hgbuildbot]
3439 master = buildmaster.example.org:9987
3440 branchtype = inrepo
3441 @end example
3443 Finally, if you want to simply specify the branchname directly, for
3444 all changes, use @code{branch = BRANCHNAME}. This overrides
3445 @code{branchtype}:
3447 @example
3448 [hgbuildbot]
3449 master = buildmaster.example.org:9987
3450 branch = trunk
3451 @end example
3453 If you use @code{branch=} like this, you'll need to put a separate
3454 .hgrc in each repository. If you use @code{branchtype=}, you may be
3455 able to use the same .hgrc for all your repositories, stored in
3456 @file{~/.hgrc} or @file{/etc/mercurial/hgrc}.
3459 @node Build Process, Status Delivery, Getting Source Code Changes, Top
3460 @chapter Build Process
3462 A @code{Build} object is responsible for actually performing a build.
3463 It gets access to a remote @code{SlaveBuilder} where it may run
3464 commands, and a @code{BuildStatus} object where it must emit status
3465 events. The @code{Build} is created by the Builder's
3466 @code{BuildFactory}.
3468 The default @code{Build} class is made up of a fixed sequence of
3469 @code{BuildSteps}, executed one after another until all are complete
3470 (or one of them indicates that the build should be halted early). The
3471 default @code{BuildFactory} creates instances of this @code{Build}
3472 class with a list of @code{BuildSteps}, so the basic way to configure
3473 the build is to provide a list of @code{BuildSteps} to your
3474 @code{BuildFactory}.
3476 More complicated @code{Build} subclasses can make other decisions:
3477 execute some steps only if certain files were changed, or if certain
3478 previous steps passed or failed. The base class has been written to
3479 allow users to express basic control flow without writing code, but
3480 you can always subclass and customize to achieve more specialized
3481 behavior.
3483 @menu
3484 * Build Steps::                 
3485 * Interlocks::                  
3486 * Build Factories::             
3487 @end menu
3489 @node Build Steps, Interlocks, Build Process, Build Process
3490 @section Build Steps
3492 @code{BuildStep}s are usually specified in the buildmaster's
3493 configuration file, in a list that goes into the @code{BuildFactory}.
3494 The @code{BuildStep} instances in this list are used as templates to
3495 construct new independent copies for each build (so that state can be
3496 kept on the @code{BuildStep} in one build without affecting a later
3497 build). Each @code{BuildFactory} can be created with a list of steps,
3498 or the factory can be created empty and then steps added to it using
3499 the @code{addStep} method:
3501 @example
3502 from buildbot.steps import source, shell
3503 from buildbot.process import factory
3505 f = factory.BuildFactory()
3506 f.addStep(source.SVN(svnurl="http://svn.example.org/Trunk/"))
3507 f.addStep(shell.ShellCommand(command=["make", "all"]))
3508 f.addStep(shell.ShellCommand(command=["make", "test"]))
3509 @end example
3511 In earlier versions (0.7.5 and older), these steps were specified with
3512 a tuple of (step_class, keyword_arguments). Steps can still be
3513 specified this way, but the preferred form is to pass actual
3514 @code{BuildStep} instances to @code{addStep}, because that gives the
3515 @code{BuildStep} class a chance to do some validation on the
3516 arguments.
3518 The rest of this section lists all the standard BuildStep objects
3519 available for use in a Build, and the parameters which can be used to
3520 control each.
3522 @menu
3523 * Common Parameters::           
3524 * Source Checkout::             
3525 * ShellCommand::                
3526 * Simple ShellCommand Subclasses::  
3527 * Python BuildSteps::           
3528 * Transferring Files::          
3529 * Writing New BuildSteps::      
3530 @end menu
3532 @node Common Parameters, Source Checkout, Build Steps, Build Steps
3533 @subsection Common Parameters
3535 The standard @code{Build} runs a series of @code{BuildStep}s in order,
3536 only stopping when it runs out of steps or if one of them requests
3537 that the build be halted. It collects status information from each one
3538 to create an overall build status (of SUCCESS, WARNINGS, or FAILURE).
3540 All BuildSteps accept some common parameters. Some of these control
3541 how their individual status affects the overall build. Others are used
3542 to specify which @code{Locks} (see @pxref{Interlocks}) should be
3543 acquired before allowing the step to run.
3545 Arguments common to all @code{BuildStep} subclasses:
3548 @table @code
3549 @item name
3550 the name used to describe the step on the status display. It is also
3551 used to give a name to any LogFiles created by this step.
3553 @item haltOnFailure
3554 if True, a FAILURE of this build step will cause the build to halt
3555 immediately with an overall result of FAILURE.
3557 @item flunkOnWarnings
3558 when True, a WARNINGS or FAILURE of this build step will mark the
3559 overall build as FAILURE. The remaining steps will still be executed.
3561 @item flunkOnFailure
3562 when True, a FAILURE of this build step will mark the overall build as
3563 a FAILURE. The remaining steps will still be executed.
3565 @item warnOnWarnings
3566 when True, a WARNINGS or FAILURE of this build step will mark the
3567 overall build as having WARNINGS. The remaining steps will still be
3568 executed.
3570 @item warnOnFailure
3571 when True, a FAILURE of this build step will mark the overall build as
3572 having WARNINGS. The remaining steps will still be executed.
3574 @item locks
3575 a list of Locks (instances of @code{buildbot.locks.SlaveLock} or
3576 @code{buildbot.locks.MasterLock}) that should be acquired before
3577 starting this Step. The Locks will be released when the step is
3578 complete. Note that this is a list of actual Lock instances, not
3579 names. Also note that all Locks must have unique names.
3581 @end table
3584 @node Source Checkout, ShellCommand, Common Parameters, Build Steps
3585 @subsection Source Checkout
3587 The first step of any build is typically to acquire the source code
3588 from which the build will be performed. There are several classes to
3589 handle this, one for each of the different source control system that
3590 Buildbot knows about. For a description of how Buildbot treats source
3591 control in general, see @ref{Version Control Systems}.
3593 All source checkout steps accept some common parameters to control how
3594 they get the sources and where they should be placed. The remaining
3595 per-VC-system parameters are mostly to specify where exactly the
3596 sources are coming from.
3598 @table @code
3599 @item mode
3601 a string describing the kind of VC operation that is desired. Defaults
3602 to @code{update}.
3604 @table @code
3605 @item update
3606 specifies that the CVS checkout/update should be performed directly
3607 into the workdir. Each build is performed in the same directory,
3608 allowing for incremental builds. This minimizes disk space, bandwidth,
3609 and CPU time. However, it may encounter problems if the build process
3610 does not handle dependencies properly (sometimes you must do a ``clean
3611 build'' to make sure everything gets compiled), or if source files are
3612 deleted but generated files can influence test behavior (e.g. python's
3613 .pyc files), or when source directories are deleted but generated
3614 files prevent CVS from removing them. Builds ought to be correct
3615 regardless of whether they are done ``from scratch'' or incrementally,
3616 but it is useful to test both kinds: this mode exercises the
3617 incremental-build style.
3619 @item copy
3620 specifies that the CVS workspace should be maintained in a separate
3621 directory (called the 'copydir'), using checkout or update as
3622 necessary. For each build, a new workdir is created with a copy of the
3623 source tree (rm -rf workdir; cp -r copydir workdir). This doubles the
3624 disk space required, but keeps the bandwidth low (update instead of a
3625 full checkout). A full 'clean' build is performed each time. This
3626 avoids any generated-file build problems, but is still occasionally
3627 vulnerable to CVS problems such as a repository being manually
3628 rearranged, causing CVS errors on update which are not an issue with a
3629 full checkout.
3631 @c TODO: something is screwy about this, revisit. Is it the source
3632 @c directory or the working directory that is deleted each time?
3634 @item clobber
3635 specifes that the working directory should be deleted each time,
3636 necessitating a full checkout for each build. This insures a clean
3637 build off a complete checkout, avoiding any of the problems described
3638 above. This mode exercises the ``from-scratch'' build style.
3640 @item export
3641 this is like @code{clobber}, except that the 'cvs export' command is
3642 used to create the working directory. This command removes all CVS
3643 metadata files (the CVS/ directories) from the tree, which is
3644 sometimes useful for creating source tarballs (to avoid including the
3645 metadata in the tar file).
3646 @end table
3648 @item workdir
3649 like all Steps, this indicates the directory where the build will take
3650 place. Source Steps are special in that they perform some operations
3651 outside of the workdir (like creating the workdir itself).
3653 @item alwaysUseLatest
3654 if True, bypass the usual ``update to the last Change'' behavior, and
3655 always update to the latest changes instead.
3657 @item retry
3658 If set, this specifies a tuple of @code{(delay, repeats)} which means
3659 that when a full VC checkout fails, it should be retried up to
3660 @var{repeats} times, waiting @var{delay} seconds between attempts. If
3661 you don't provide this, it defaults to @code{None}, which means VC
3662 operations should not be retried. This is provided to make life easier
3663 for buildslaves which are stuck behind poor network connections.
3665 @end table
3668 My habit as a developer is to do a @code{cvs update} and @code{make} each
3669 morning. Problems can occur, either because of bad code being checked in, or
3670 by incomplete dependencies causing a partial rebuild to fail where a
3671 complete from-scratch build might succeed. A quick Builder which emulates
3672 this incremental-build behavior would use the @code{mode='update'}
3673 setting.
3675 On the other hand, other kinds of dependency problems can cause a clean
3676 build to fail where a partial build might succeed. This frequently results
3677 from a link step that depends upon an object file that was removed from a
3678 later version of the tree: in the partial tree, the object file is still
3679 around (even though the Makefiles no longer know how to create it).
3681 ``official'' builds (traceable builds performed from a known set of
3682 source revisions) are always done as clean builds, to make sure it is
3683 not influenced by any uncontrolled factors (like leftover files from a
3684 previous build). A ``full'' Builder which behaves this way would want
3685 to use the @code{mode='clobber'} setting.
3687 Each VC system has a corresponding source checkout class: their
3688 arguments are described on the following pages.
3691 @menu
3692 * CVS::                         
3693 * SVN::                         
3694 * Darcs::                       
3695 * Mercurial::                   
3696 * Arch::                        
3697 * Bazaar::                      
3698 * Bzr::                         
3699 * P4::                          
3700 @end menu
3702 @node CVS, SVN, Source Checkout, Source Checkout
3703 @subsubsection CVS
3704 @cindex CVS Checkout
3705 @bsindex buildbot.steps.source.CVS
3708 The @code{CVS} build step performs a @uref{http://www.nongnu.org/cvs/,
3709 CVS} checkout or update. It takes the following arguments:
3711 @table @code
3712 @item cvsroot
3713 (required): specify the CVSROOT value, which points to a CVS
3714 repository, probably on a remote machine. For example, the cvsroot
3715 value you would use to get a copy of the Buildbot source code is
3716 @code{:pserver:anonymous@@cvs.sourceforge.net:/cvsroot/buildbot}
3718 @item cvsmodule
3719 (required): specify the cvs @code{module}, which is generally a
3720 subdirectory of the CVSROOT. The cvsmodule for the Buildbot source
3721 code is @code{buildbot}.
3723 @item branch
3724 a string which will be used in a @code{-r} argument. This is most
3725 useful for specifying a branch to work on. Defaults to @code{HEAD}.
3727 @item global_options
3728 a list of flags to be put before the verb in the CVS command.
3730 @item checkoutDelay
3731 if set, the number of seconds to put between the timestamp of the last
3732 known Change and the value used for the @code{-D} option. Defaults to
3733 half of the parent Build's treeStableTimer.
3735 @end table
3738 @node SVN, Darcs, CVS, Source Checkout
3739 @subsubsection SVN
3741 @cindex SVN Checkout
3742 @bsindex buildbot.steps.source.SVN
3745 The @code{SVN} build step performs a
3746 @uref{http://subversion.tigris.org, Subversion} checkout or update.
3747 There are two basic ways of setting up the checkout step, depending
3748 upon whether you are using multiple branches or not.
3750 If all of your builds use the same branch, then you should create the
3751 @code{SVN} step with the @code{svnurl} argument:
3753 @table @code
3754 @item svnurl
3755 (required): this specifies the @code{URL} argument that will be given
3756 to the @code{svn checkout} command. It dictates both where the
3757 repository is located and which sub-tree should be extracted. In this
3758 respect, it is like a combination of the CVS @code{cvsroot} and
3759 @code{cvsmodule} arguments. For example, if you are using a remote
3760 Subversion repository which is accessible through HTTP at a URL of
3761 @code{http://svn.example.com/repos}, and you wanted to check out the
3762 @code{trunk/calc} sub-tree, you would use
3763 @code{svnurl="http://svn.example.com/repos/trunk/calc"} as an argument
3764 to your @code{SVN} step.
3765 @end table
3767 If, on the other hand, you are building from multiple branches, then
3768 you should create the @code{SVN} step with the @code{baseURL} and
3769 @code{defaultBranch} arguments instead:
3771 @table @code
3772 @item baseURL
3773 (required): this specifies the base repository URL, to which a branch
3774 name will be appended. It should probably end in a slash.
3776 @item defaultBranch
3777 this specifies the name of the branch to use when a Build does not
3778 provide one of its own. This will be appended to @code{baseURL} to
3779 create the string that will be passed to the @code{svn checkout}
3780 command.
3781 @end table
3783 If you are using branches, you must also make sure your
3784 @code{ChangeSource} will report the correct branch names.
3786 @heading branch example
3788 Let's suppose that the ``MyProject'' repository uses branches for the
3789 trunk, for various users' individual development efforts, and for
3790 several new features that will require some amount of work (involving
3791 multiple developers) before they are ready to merge onto the trunk.
3792 Such a repository might be organized as follows:
3794 @example
3795 svn://svn.example.org/MyProject/trunk
3796 svn://svn.example.org/MyProject/branches/User1/foo
3797 svn://svn.example.org/MyProject/branches/User1/bar
3798 svn://svn.example.org/MyProject/branches/User2/baz
3799 svn://svn.example.org/MyProject/features/newthing
3800 svn://svn.example.org/MyProject/features/otherthing
3801 @end example
3803 Further assume that we want the Buildbot to run tests against the
3804 trunk and against all the feature branches (i.e., do a
3805 checkout/compile/build of branch X when a file has been changed on
3806 branch X, when X is in the set [trunk, features/newthing,
3807 features/otherthing]). We do not want the Buildbot to automatically
3808 build any of the user branches, but it should be willing to build a
3809 user branch when explicitly requested (most likely by the user who
3810 owns that branch).
3812 There are three things that need to be set up to accomodate this
3813 system. The first is a ChangeSource that is capable of identifying the
3814 branch which owns any given file. This depends upon a user-supplied
3815 function, in an external program that runs in the SVN commit hook and
3816 connects to the buildmaster's @code{PBChangeSource} over a TCP
3817 connection. (you can use the ``@code{buildbot sendchange}'' utility
3818 for this purpose, but you will still need an external program to
3819 decide what value should be passed to the @code{--branch=} argument).
3820 For example, a change to a file with the SVN url of
3821 ``svn://svn.example.org/MyProject/features/newthing/src/foo.c'' should
3822 be broken down into a Change instance with
3823 @code{branch='features/newthing'} and @code{file='src/foo.c'}.
3825 The second piece is an @code{AnyBranchScheduler} which will pay
3826 attention to the desired branches. It will not pay attention to the
3827 user branches, so it will not automatically start builds in response
3828 to changes there. The AnyBranchScheduler class requires you to
3829 explicitly list all the branches you want it to use, but it would not
3830 be difficult to write a subclass which used
3831 @code{branch.startswith('features/'} to remove the need for this
3832 explicit list. Or, if you want to build user branches too, you can use
3833 AnyBranchScheduler with @code{branches=None} to indicate that you want
3834 it to pay attention to all branches.
3836 The third piece is an @code{SVN} checkout step that is configured to
3837 handle the branches correctly, with a @code{baseURL} value that
3838 matches the way the ChangeSource splits each file's URL into base,
3839 branch, and file.
3841 @example
3842 from buildbot.changes.pb import PBChangeSource
3843 from buildbot.scheduler import AnyBranchScheduler
3844 from buildbot.process import source, factory
3845 from buildbot.steps import source, shell
3847 c['change_source'] = PBChangeSource()
3848 s1 = AnyBranchScheduler('main',
3849                         ['trunk', 'features/newthing', 'features/otherthing'],
3850                         10*60, ['test-i386', 'test-ppc'])
3851 c['schedulers'] = [s1]
3853 f = factory.BuildFactory()
3854 f.addStep(source.SVN(mode='update',
3855                      baseURL='svn://svn.example.org/MyProject/',
3856                      defaultBranch='trunk'))
3857 f.addStep(shell.Compile(command="make all"))
3858 f.addStep(shell.Test(command="make test"))
3860 c['builders'] = [
3861   @{'name':'test-i386', 'slavename':'bot-i386', 'builddir':'test-i386',
3862                        'factory':f @},
3863   @{'name':'test-ppc', 'slavename':'bot-ppc', 'builddir':'test-ppc',
3864                       'factory':f @},
3866 @end example
3868 In this example, when a change arrives with a @code{branch} attribute
3869 of ``trunk'', the resulting build will have an SVN step that
3870 concatenates ``svn://svn.example.org/MyProject/'' (the baseURL) with
3871 ``trunk'' (the branch name) to get the correct svn command. If the
3872 ``newthing'' branch has a change to ``src/foo.c'', then the SVN step
3873 will concatenate ``svn://svn.example.org/MyProject/'' with
3874 ``features/newthing'' to get the svnurl for checkout.
3876 @node Darcs, Mercurial, SVN, Source Checkout
3877 @subsubsection Darcs
3879 @cindex Darcs Checkout
3880 @bsindex buildbot.steps.source.Darcs
3883 The @code{Darcs} build step performs a
3884 @uref{http://darcs.net/, Darcs} checkout or update.
3886 Like @xref{SVN}, this step can either be configured to always check
3887 out a specific tree, or set up to pull from a particular branch that
3888 gets specified separately for each build. Also like SVN, the
3889 repository URL given to Darcs is created by concatenating a
3890 @code{baseURL} with the branch name, and if no particular branch is
3891 requested, it uses a @code{defaultBranch}. The only difference in
3892 usage is that each potential Darcs repository URL must point to a
3893 fully-fledged repository, whereas SVN URLs usually point to sub-trees
3894 of the main Subversion repository. In other words, doing an SVN
3895 checkout of @code{baseURL} is legal, but silly, since you'd probably
3896 wind up with a copy of every single branch in the whole repository.
3897 Doing a Darcs checkout of @code{baseURL} is just plain wrong, since
3898 the parent directory of a collection of Darcs repositories is not
3899 itself a valid repository.
3901 The Darcs step takes the following arguments:
3903 @table @code
3904 @item repourl
3905 (required unless @code{baseURL} is provided): the URL at which the
3906 Darcs source repository is available.
3908 @item baseURL
3909 (required unless @code{repourl} is provided): the base repository URL,
3910 to which a branch name will be appended. It should probably end in a
3911 slash.
3913 @item defaultBranch
3914 (allowed if and only if @code{baseURL} is provided): this specifies
3915 the name of the branch to use when a Build does not provide one of its
3916 own. This will be appended to @code{baseURL} to create the string that
3917 will be passed to the @code{darcs get} command.
3918 @end table
3920 @node Mercurial, Arch, Darcs, Source Checkout
3921 @subsubsection Mercurial
3923 @cindex Mercurial Checkout
3924 @bsindex buildbot.steps.source.Mercurial
3927 The @code{Mercurial} build step performs a
3928 @uref{http://selenic.com/mercurial, Mercurial} (aka ``hg'') checkout
3929 or update.
3931 Branches are handled just like @xref{Darcs}.
3933 The Mercurial step takes the following arguments:
3935 @table @code
3936 @item repourl
3937 (required unless @code{baseURL} is provided): the URL at which the
3938 Mercurial source repository is available.
3940 @item baseURL
3941 (required unless @code{repourl} is provided): the base repository URL,
3942 to which a branch name will be appended. It should probably end in a
3943 slash.
3945 @item defaultBranch
3946 (allowed if and only if @code{baseURL} is provided): this specifies
3947 the name of the branch to use when a Build does not provide one of its
3948 own. This will be appended to @code{baseURL} to create the string that
3949 will be passed to the @code{hg clone} command.
3950 @end table
3953 @node Arch, Bazaar, Mercurial, Source Checkout
3954 @subsubsection Arch
3956 @cindex Arch Checkout
3957 @bsindex buildbot.steps.source.Arch
3960 The @code{Arch} build step performs an @uref{http://gnuarch.org/,
3961 Arch} checkout or update using the @code{tla} client. It takes the
3962 following arguments:
3964 @table @code
3965 @item url
3966 (required): this specifies the URL at which the Arch source archive is
3967 available.
3969 @item version
3970 (required): this specifies which ``development line'' (like a branch)
3971 should be used. This provides the default branch name, but individual
3972 builds may specify a different one.
3974 @item archive
3975 (optional): Each repository knows its own archive name. If this
3976 parameter is provided, it must match the repository's archive name.
3977 The parameter is accepted for compatibility with the @code{Bazaar}
3978 step, below.
3980 @end table
3982 @node Bazaar, Bzr, Arch, Source Checkout
3983 @subsubsection Bazaar
3985 @cindex Bazaar Checkout
3986 @bsindex buildbot.steps.source.Bazaar
3989 @code{Bazaar} is an alternate implementation of the Arch VC system,
3990 which uses a client named @code{baz}. The checkout semantics are just
3991 different enough from @code{tla} that there is a separate BuildStep for
3994 It takes exactly the same arguments as @code{Arch}, except that the
3995 @code{archive=} parameter is required. (baz does not emit the archive
3996 name when you do @code{baz register-archive}, so we must provide it
3997 ourselves).
4000 @node Bzr, P4, Bazaar, Source Checkout
4001 @subsubsection Bzr
4003 @cindex Bzr Checkout
4004 @bsindex buildbot.steps.source.Bzr
4006 @code{bzr} is a descendant of Arch/Baz, and is frequently referred to
4007 as simply ``Bazaar''. The repository-vs-workspace model is similar to
4008 Darcs, but it uses a strictly linear sequence of revisions (one
4009 history per branch) like Arch. Branches are put in subdirectories.
4010 This makes it look very much like Mercurial, so it takes the same
4011 arguments:
4013 @table @code
4015 @item repourl
4016 (required unless @code{baseURL} is provided): the URL at which the
4017 Bzr source repository is available.
4019 @item baseURL
4020 (required unless @code{repourl} is provided): the base repository URL,
4021 to which a branch name will be appended. It should probably end in a
4022 slash.
4024 @item defaultBranch
4025 (allowed if and only if @code{baseURL} is provided): this specifies
4026 the name of the branch to use when a Build does not provide one of its
4027 own. This will be appended to @code{baseURL} to create the string that
4028 will be passed to the @code{bzr checkout} command.
4029 @end table
4033 @node P4,  , Bzr, Source Checkout
4034 @subsubsection P4
4036 @cindex Perforce Update
4037 @bsindex buildbot.steps.source.P4
4038 @c TODO @bsindex buildbot.steps.source.P4Sync
4041 The @code{P4} build step creates a @uref{http://www.perforce.com/,
4042 Perforce} client specification and performs an update.
4044 @table @code
4045 @item p4base
4046 A view into the Perforce depot without branch name or trailing "...".
4047 Typically "//depot/proj/".
4048 @item defaultBranch
4049 A branch name to append on build requests if none is specified.
4050 Typically "trunk".
4051 @item p4port
4052 (optional): the host:port string describing how to get to the P4 Depot
4053 (repository), used as the -p argument for all p4 commands.
4054 @item p4user
4055 (optional): the Perforce user, used as the -u argument to all p4
4056 commands.
4057 @item p4passwd
4058 (optional): the Perforce password, used as the -p argument to all p4
4059 commands.
4060 @item p4extra_views
4061 (optional): a list of (depotpath, clientpath) tuples containing extra
4062 views to be mapped into the client specification. Both will have
4063 "/..." appended automatically. The client name and source directory
4064 will be prepended to the client path.
4065 @item p4client
4066 (optional): The name of the client to use. In mode='copy' and
4067 mode='update', it's particularly important that a unique name is used
4068 for each checkout directory to avoid incorrect synchronization. For
4069 this reason, Python percent substitution will be performed on this value
4070 to replace %(slave)s with the slave name and %(builder)s with the
4071 builder name. The default is "buildbot_%(slave)s_%(build)s".
4072 @end table
4074 @node ShellCommand, Simple ShellCommand Subclasses, Source Checkout, Build Steps
4075 @subsection ShellCommand
4077 @bsindex buildbot.steps.shell.ShellCommand
4078 @c TODO @bsindex buildbot.steps.shell.TreeSize
4080 This is a useful base class for just about everything you might want
4081 to do during a build (except for the initial source checkout). It runs
4082 a single command in a child shell on the buildslave. All stdout/stderr
4083 is recorded into a LogFile. The step finishes with a status of FAILURE
4084 if the command's exit code is non-zero, otherwise it has a status of
4085 SUCCESS.
4087 The preferred way to specify the command is with a list of argv strings,
4088 since this allows for spaces in filenames and avoids doing any fragile
4089 shell-escaping. You can also specify the command with a single string, in
4090 which case the string is given to '/bin/sh -c COMMAND' for parsing.
4092 All ShellCommands are run by default in the ``workdir'', which
4093 defaults to the ``@file{build}'' subdirectory of the slave builder's
4094 base directory. The absolute path of the workdir will thus be the
4095 slave's basedir (set as an option to @code{buildbot create-slave},
4096 @pxref{Creating a buildslave}) plus the builder's basedir (set in the
4097 builder's @code{c['builddir']} key in master.cfg) plus the workdir
4098 itself (a class-level attribute of the BuildFactory, defaults to
4099 ``@file{build}'').
4101 @code{ShellCommand} arguments:
4103 @table @code
4104 @item command
4105 a list of strings (preferred) or single string (discouraged) which
4106 specifies the command to be run. A list of strings is preferred
4107 because it can be used directly as an argv array. Using a single
4108 string (with embedded spaces) requires the buildslave to pass the
4109 string to /bin/sh for interpretation, which raises all sorts of
4110 difficult questions about how to escape or interpret shell
4111 metacharacters.
4113 @item env
4114 a dictionary of environment strings which will be added to the child
4115 command's environment. For example, to run tests with a different i18n
4116 language setting, you might use
4118 @example
4119 f.addStep(ShellCommand, command=["make", "test"],
4120           env=@{'LANG': 'fr_FR'@})
4121 @end example
4123 These variable settings will override any existing ones in the
4124 buildslave's environment. The exception is PYTHONPATH, which is merged
4125 with (actually prepended to) any existing $PYTHONPATH setting. The
4126 value is treated as a list of directories to prepend, and a single
4127 string is treated like a one-item list. For example, to prepend both
4128 @file{/usr/local/lib/python2.3} and @file{/home/buildbot/lib/python}
4129 to any existing $PYTHONPATH setting, you would do something like the
4130 following:
4132 @example
4133 f.addStep(ShellCommand, command=["make", "test"],
4134           env=@{'PYTHONPATH': ["/usr/local/lib/python2.3",
4135                               "/home/buildbot/lib/python"] @})
4136 @end example
4138 @item want_stdout
4139 if False, stdout from the child process is discarded rather than being
4140 sent to the buildmaster for inclusion in the step's LogFile.
4142 @item want_stderr
4143 like @code{want_stdout} but for stderr. Note that commands run through
4144 a PTY do not have separate stdout/stderr streams: both are merged into
4145 stdout.
4147 @item logfiles
4148 Sometimes commands will log interesting data to a local file, rather
4149 than emitting everything to stdout or stderr. For example, Twisted's
4150 ``trial'' command (which runs unit tests) only presents summary
4151 information to stdout, and puts the rest into a file named
4152 @file{_trial_temp/test.log}. It is often useful to watch these files
4153 as the command runs, rather than using @command{/bin/cat} to dump
4154 their contents afterwards.
4156 The @code{logfiles=} argument allows you to collect data from these
4157 secondary logfiles in near-real-time, as the step is running. It
4158 accepts a dictionary which maps from a local Log name (which is how
4159 the log data is presented in the build results) to a remote filename
4160 (interpreted relative to the build's working directory). Each named
4161 file will be polled on a regular basis (every couple of seconds) as
4162 the build runs, and any new text will be sent over to the buildmaster.
4164 @example
4165 f.addStep(ShellCommand, command=["make", "test"],
4166           logfiles=@{"triallog": "_trial_temp/test.log"@})
4167 @end example
4170 @item timeout
4171 if the command fails to produce any output for this many seconds, it
4172 is assumed to be locked up and will be killed.
4174 @item description
4175 This will be used to describe the command (on the Waterfall display)
4176 while the command is still running. It should be a single
4177 imperfect-tense verb, like ``compiling'' or ``testing''. The preferred
4178 form is a list of short strings, which allows the HTML Waterfall
4179 display to create narrower columns by emitting a <br> tag between each
4180 word. You may also provide a single string.
4182 @item descriptionDone
4183 This will be used to describe the command once it has finished. A
4184 simple noun like ``compile'' or ``tests'' should be used. Like
4185 @code{description}, this may either be a list of short strings or a
4186 single string.
4188 If neither @code{description} nor @code{descriptionDone} are set, the
4189 actual command arguments will be used to construct the description.
4190 This may be a bit too wide to fit comfortably on the Waterfall
4191 display.
4193 @example
4194 f.addStep(ShellCommand, command=["make", "test"],
4195           description=["testing"],
4196           descriptionDone=["tests"])
4197 @end example
4199 @end table
4201 @node Simple ShellCommand Subclasses, Python BuildSteps, ShellCommand, Build Steps
4202 @subsection Simple ShellCommand Subclasses
4204 Several subclasses of ShellCommand are provided as starting points for
4205 common build steps. These are all very simple: they just override a few
4206 parameters so you don't have to specify them yourself, making the master.cfg
4207 file less verbose.
4209 @menu
4210 * Configure::                   
4211 * Compile::                     
4212 * Test::                        
4213 * Build Properties::            
4214 @end menu
4216 @node Configure, Compile, Simple ShellCommand Subclasses, Simple ShellCommand Subclasses
4217 @subsubsection Configure
4219 @bsindex buildbot.steps.shell.Configure
4221 This is intended to handle the @code{./configure} step from
4222 autoconf-style projects, or the @code{perl Makefile.PL} step from perl
4223 MakeMaker.pm-style modules. The default command is @code{./configure}
4224 but you can change this by providing a @code{command=} parameter.
4226 @node Compile, Test, Configure, Simple ShellCommand Subclasses
4227 @subsubsection Compile
4229 @bsindex buildbot.steps.shell.Compile
4231 This is meant to handle compiling or building a project written in C. The
4232 default command is @code{make all}. When the compile is finished, the
4233 log file is scanned for GCC error/warning messages and a summary log is
4234 created with any problems that were seen (TODO: the summary is not yet
4235 created).
4237 @node Test, Build Properties, Compile, Simple ShellCommand Subclasses
4238 @subsubsection Test
4240 @bsindex buildbot.steps.shell.Test
4242 This is meant to handle unit tests. The default command is @code{make
4243 test}, and the @code{warnOnFailure} flag is set.
4247 @node Build Properties,  , Test, Simple ShellCommand Subclasses
4248 @subsubsection Build Properties
4250 @cindex build properties
4252 Each build has a set of ``Build Properties'', which can be used by its
4253 BuildStep to modify their actions. For example, the SVN revision
4254 number of the source code being built is available as a build
4255 property, and a ShellCommand step could incorporate this number into a
4256 command which create a numbered release tarball.
4258 Some build properties are set when the build starts, such as the
4259 SourceStamp information. Other properties can be set by BuildSteps as
4260 they run, for example the various Source steps will set the
4261 @code{got_revision} property to the source revision that was actually
4262 checked out (which can be useful when the SourceStamp in use merely
4263 requested the ``latest revision'': @code{got_revision} will tell you
4264 what was actually built).
4266 In custom BuildSteps, you can get and set the build properties with
4267 the @code{getProperty}/@code{setProperty} methods. Each takes a string
4268 for the name of the property, and returns or accepts an
4269 arbitrary@footnote{Build properties are serialized along with the
4270 build results, so they must be serializable. For this reason, the
4271 value of any build property should be simple inert data: strings,
4272 numbers, lists, tuples, and dictionaries. They should not contain
4273 class instances.} object. For example:
4275 @example
4276 class MakeTarball(ShellCommand):
4277     def start(self):
4278         self.setCommand(["tar", "czf",
4279                          "build-%s.tar.gz" % self.getProperty("revision"),
4280                          "source"])
4281         ShellCommand.start(self)
4282 @end example
4284 @cindex WithProperties
4286 You can use build properties in ShellCommands by using the
4287 @code{WithProperties} wrapper when setting the arguments of the
4288 ShellCommand. This interpolates the named build properties into the
4289 generated shell command. You can also use a @code{WithProperties} as
4290 the @code{workdir=} argument: this allows the working directory for a
4291 command to be varied for each build, depending upon various build
4292 properties.
4294 @example
4295 from buildbot.steps.shell import ShellCommand, WithProperties
4297 f.addStep(ShellCommand,
4298           command=["tar", "czf",
4299                    WithProperties("build-%s.tar.gz", "revision"),
4300                    "source"])
4301 @end example
4303 If this BuildStep were used in a tree obtained from Subversion, it
4304 would create a tarball with a name like @file{build-1234.tar.gz}.
4306 The @code{WithProperties} function does @code{printf}-style string
4307 interpolation, using strings obtained by calling
4308 @code{build.getProperty(propname)}. Note that for every @code{%s} (or
4309 @code{%d}, etc), you must have exactly one additional argument to
4310 indicate which build property you want to insert.
4313 You can also use python dictionary-style string interpolation by using
4314 the @code{%(propname)s} syntax. In this form, the property name goes
4315 in the parentheses, and WithProperties takes @emph{no} additional
4316 arguments:
4318 @example
4319 f.addStep(ShellCommand,
4320           command=["tar", "czf",
4321                    WithProperties("build-%(revision)s.tar.gz"),
4322                    "source"])
4323 @end example
4325 Don't forget the extra ``s'' after the closing parenthesis! This is
4326 the cause of many confusing errors. Also note that you can only use
4327 WithProperties in the list form of the command= definition. You cannot
4328 currently use it in the (discouraged) @code{command="stuff"}
4329 single-string form. However, you can use something like
4330 @code{command=["/bin/sh", "-c", "stuff", WithProperties(stuff)]} to
4331 use both shell expansion and WithProperties interpolation.
4333 Note that, like python, you can either do positional-argument
4334 interpolation @emph{or} keyword-argument interpolation, not both. Thus
4335 you cannot use a string like
4336 @code{WithProperties("foo-%(revision)s-%s", "branch")}.
4338 At the moment, the only way to set build properties is by writing a
4339 custom BuildStep.
4341 @heading Common Build Properties
4343 The following build properties are set when the build is started, and
4344 are available to all steps.
4346 @table @code
4347 @item branch
4349 This comes from the build's SourceStamp, and describes which branch is
4350 being checked out. This will be @code{None} (which interpolates into
4351 @code{WithProperties} as an empty string) if the build is on the
4352 default branch, which is generally the trunk. Otherwise it will be a
4353 string like ``branches/beta1.4''. The exact syntax depends upon the VC
4354 system being used.
4356 @item revision
4358 This also comes from the SourceStamp, and is the revision of the
4359 source code tree that was requested from the VC system. When a build
4360 is requested of a specific revision (as is generally the case when the
4361 build is triggered by Changes), this will contain the revision
4362 specification. The syntax depends upon the VC system in use: for SVN
4363 it is an integer, for Mercurial it is a short string, for Darcs it is
4364 a rather large string, etc.
4366 If the ``force build'' button was pressed, the revision will be
4367 @code{None}, which means to use the most recent revision available.
4368 This is a ``trunk build''. This will be interpolated as an empty
4369 string.
4371 @item got_revision
4373 This is set when a Source step checks out the source tree, and
4374 provides the revision that was actually obtained from the VC system.
4375 In general this should be the same as @code{revision}, except for
4376 trunk builds, where @code{got_revision} indicates what revision was
4377 current when the checkout was performed. This can be used to rebuild
4378 the same source code later.
4380 Note that for some VC systems (Darcs in particular), the revision is a
4381 large string containing newlines, and is not suitable for
4382 interpolation into a filename.
4384 @item buildername
4386 This is a string that indicates which Builder the build was a part of.
4387 The combination of buildername and buildnumber uniquely identify a
4388 build.
4390 @item buildnumber
4392 Each build gets a number, scoped to the Builder (so the first build
4393 performed on any given Builder will have a build number of 0). This
4394 integer property contains the build's number.
4396 @item slavename
4398 This is a string which identifies which buildslave the build is
4399 running on.
4401 @end table
4403 @node Python BuildSteps, Transferring Files, Simple ShellCommand Subclasses, Build Steps
4404 @subsection Python BuildSteps
4406 Here are some BuildSteps that are specifcally useful for projects
4407 implemented in Python.
4409 @menu
4410 * BuildEPYDoc::                 
4411 * PyFlakes::                    
4412 @end menu
4414 @node BuildEPYDoc, PyFlakes, Python BuildSteps, Python BuildSteps
4415 @subsubsection BuildEPYDoc
4417 @bsindex buildbot.steps.python.BuildEPYDoc
4419 @url{http://epydoc.sourceforge.net/, epydoc} is a tool for generating
4420 API documentation for Python modules from their docstrings. It reads
4421 all the .py files from your source tree, processes the docstrings
4422 therein, and creates a large tree of .html files (or a single .pdf
4423 file).
4425 The @code{buildbot.steps.python.BuildEPYDoc} step will run
4426 @command{epydoc} to produce this API documentation, and will count the
4427 errors and warnings from its output.
4429 You must supply the command line to be used. The default is
4430 @command{make epydocs}, which assumes that your project has a Makefile
4431 with an ``epydocs'' target. You might wish to use something like
4432 @command{epydoc -o apiref source/PKGNAME} instead. You might also want
4433 to add @command{--pdf} to generate a PDF file instead of a large tree
4434 of HTML files.
4436 The API docs are generated in-place in the build tree (under the
4437 workdir, in the subdirectory controlled by the ``-o'' argument). To
4438 make them useful, you will probably have to copy them to somewhere
4439 they can be read. A command like @command{rsync -ad apiref/
4440 dev.example.com:~public_html/current-apiref/} might be useful. You
4441 might instead want to bundle them into a tarball and publish it in the
4442 same place where the generated install tarball is placed.
4444 @example
4445 from buildbot.steps.python import BuildEPYDoc
4448 f.addStep(BuildEPYDoc, command=["epydoc", "-o", "apiref", "source/mypkg"])
4449 @end example
4452 @node PyFlakes,  , BuildEPYDoc, Python BuildSteps
4453 @subsubsection PyFlakes
4455 @bsindex buildbot.steps.python.PyFlakes
4457 @url{http://divmod.org/trac/wiki/DivmodPyflakes, PyFlakes} is a tool
4458 to perform basic static analysis of Python code to look for simple
4459 errors, like missing imports and references of undefined names. It is
4460 like a fast and simple form of the C ``lint'' program. Other tools
4461 (like pychecker) provide more detailed results but take longer to run.
4463 The @code{buildbot.steps.python.PyFlakes} step will run pyflakes and
4464 count the various kinds of errors and warnings it detects.
4466 You must supply the command line to be used. The default is
4467 @command{make pyflakes}, which assumes you have a top-level Makefile
4468 with a ``pyflakes'' target. You might want to use something like
4469 @command{pyflakes .} or @command{pyflakes src}.
4471 @example
4472 from buildbot.steps.python import PyFlakes
4475 f.addStep(PyFlakes, command=["pyflakes", "src"])
4476 @end example
4479 @node Transferring Files, Writing New BuildSteps, Python BuildSteps, Build Steps
4480 @subsection Transferring Files
4482 @cindex File Transfer
4483 @bsindex buildbot.steps.transfer.FileUpload
4484 @bsindex buildbot.steps.transfer.FileDownload
4486 Most of the work involved in a build will take place on the
4487 buildslave. But occasionally it is useful to do some work on the
4488 buildmaster side. The most basic way to involve the buildmaster is
4489 simply to move a file from the slave to the master, or vice versa.
4490 There are a pair of BuildSteps named @code{FileUpload} and
4491 @code{FileDownload} to provide this functionality. @code{FileUpload}
4492 moves a file @emph{up to} the master, while @code{FileDownload} moves
4493 a file @emph{down from} the master.
4495 As an example, let's assume that there is a step which produces an
4496 HTML file within the source tree that contains some sort of generated
4497 project documentation. We want to move this file to the buildmaster,
4498 into a @file{~/public_html} directory, so it can be visible to
4499 developers. This file will wind up in the slave-side working directory
4500 under the name @file{docs/reference.html}. We want to put it into the
4501 master-side @file{~/public_html/ref.html}.
4503 @example
4504 from buildbot.steps.shell import ShellCommand
4505 from buildbot.steps.transfer import FileUpload
4507 f.addStep(ShellCommand, command=["make", "docs"])
4508 f.addStep(FileUpload,
4509           slavesrc="docs/reference.html",
4510           masterdest="~/public_html/ref.html")
4511 @end example
4513 The @code{masterdest=} argument will be passed to os.path.expanduser,
4514 so things like ``~'' will be expanded properly. Non-absolute paths
4515 will be interpreted relative to the buildmaster's base directory.
4516 Likewise, the @code{slavesrc=} argument will be expanded and
4517 interpreted relative to the builder's working directory.
4520 To move a file from the master to the slave, use the
4521 @code{FileDownload} command. For example, let's assume that some step
4522 requires a configuration file that, for whatever reason, could not be
4523 recorded in the source code repository or generated on the buildslave
4524 side:
4526 @example
4527 from buildbot.steps.shell import ShellCommand
4528 from buildbot.steps.transfer import FileUpload
4530 f.addStep(FileDownload
4531           mastersrc="~/todays_build_config.txt",
4532           slavedest="build_config.txt")
4533 f.addStep(ShellCommand, command=["make", "config"])
4534 @end example
4536 Like @code{FileUpload}, the @code{mastersrc=} argument is interpreted
4537 relative to the buildmaster's base directory, and the
4538 @code{slavedest=} argument is relative to the builder's working
4539 directory. If the buildslave is running in @file{~buildslave}, and the
4540 builder's ``builddir'' is something like @file{tests-i386}, then the
4541 workdir is going to be @file{~buildslave/tests-i386/build}, and a
4542 @code{slavedest=} of @file{foo/bar.html} will get put in
4543 @file{~buildslave/tests-i386/build/foo/bar.html}. Remember that
4544 neither of these commands will create missing directories for you.
4547 @subheading Other Parameters
4549 The @code{maxsize=} argument lets you set a maximum size for the file
4550 to be transferred. This may help to avoid surprises: transferring a
4551 100MB coredump when you were expecting to move a 10kB status file
4552 might take an awfully long time. The @code{blocksize=} argument
4553 controls how the file is sent over the network: larger blocksizes are
4554 slightly more efficient but also consume more memory on each end, and
4555 there is a hard-coded limit of about 640kB.
4557 The @code{mode=} argument allows you to control the access permissions
4558 of the target file, traditionally expressed as an octal integer. The
4559 most common value is probably 0755, which sets the ``x'' executable
4560 bit on the file (useful for shell scripts and the like). The default
4561 value for @code{mode=} is None, which means the permission bits will
4562 default to whatever the umask of the writing process is. The default
4563 umask tends to be fairly restrictive, but at least on the buildslave
4564 you can make it less restrictive with a --umask command-line option at
4565 creation time (@pxref{Buildslave Options}).
4568 @node Writing New BuildSteps,  , Transferring Files, Build Steps
4569 @subsection Writing New BuildSteps
4571 While it is a good idea to keep your build process self-contained in
4572 the source code tree, sometimes it is convenient to put more
4573 intelligence into your Buildbot configuration. One was to do this is
4574 to write a custom BuildStep. Once written, this Step can be used in
4575 the @file{master.cfg} file.
4577 The best reason for writing a custom BuildStep is to better parse the
4578 results of the command being run. For example, a BuildStep that knows
4579 about JUnit could look at the logfiles to determine which tests had
4580 been run, how many passed and how many failed, and then report more
4581 detailed information than a simple @code{rc==0} -based ``good/bad''
4582 decision.
4584 TODO: add more description of BuildSteps.
4586 @menu
4587 * BuildStep LogFiles::          
4588 * Reading Logfiles::            
4589 * Adding LogObservers::         
4590 * BuildStep URLs::              
4591 @end menu
4593 @node BuildStep LogFiles, Reading Logfiles, Writing New BuildSteps, Writing New BuildSteps
4594 @subsubsection BuildStep LogFiles
4596 Each BuildStep has a collection of ``logfiles''. Each one has a short
4597 name, like ``stdio'' or ``warnings''. Each LogFile contains an
4598 arbitrary amount of text, usually the contents of some output file
4599 generated during a build or test step, or a record of everything that
4600 was printed to stdout/stderr during the execution of some command.
4602 These LogFiles are stored to disk, so they can be retrieved later.
4604 Each can contain multiple ``channels'', generally limited to three
4605 basic ones: stdout, stderr, and ``headers''. For example, when a
4606 ShellCommand runs, it writes a few lines to the ``headers'' channel to
4607 indicate the exact argv strings being run, which directory the command
4608 is being executed in, and the contents of the current environment
4609 variables. Then, as the command runs, it adds a lot of ``stdout'' and
4610 ``stderr'' messages. When the command finishes, a final ``header''
4611 line is added with the exit code of the process.
4613 Status display plugins can format these different channels in
4614 different ways. For example, the web page shows LogFiles as text/html,
4615 with header lines in blue text, stdout in black, and stderr in red. A
4616 different URL is available which provides a text/plain format, in
4617 which stdout and stderr are collapsed together, and header lines are
4618 stripped completely. This latter option makes it easy to save the
4619 results to a file and run @command{grep} or whatever against the
4620 output.
4622 Each BuildStep contains a mapping (implemented in a python dictionary)
4623 from LogFile name to the actual LogFile objects. Status plugins can
4624 get a list of LogFiles to display, for example, a list of HREF links
4625 that, when clicked, provide the full contents of the LogFile.
4627 @heading Using LogFiles in custom BuildSteps
4629 The most common way for a custom BuildStep to use a LogFile is to
4630 summarize the results of a ShellCommand (after the command has
4631 finished running). For example, a compile step with thousands of lines
4632 of output might want to create a summary of just the warning messages.
4633 If you were doing this from a shell, you would use something like:
4635 @example
4636 grep "warning:" output.log >warnings.log
4637 @end example
4639 In a custom BuildStep, you could instead create a ``warnings'' LogFile
4640 that contained the same text. To do this, you would add code to your
4641 @code{createSummary} method that pulls lines from the main output log
4642 and creates a new LogFile with the results:
4644 @example
4645     def createSummary(self, log):
4646         warnings = []
4647         for line in log.readlines():
4648             if "warning:" in line:
4649                 warnings.append()
4650         self.addCompleteLog('warnings', "".join(warnings))
4651 @end example
4653 This example uses the @code{addCompleteLog} method, which creates a
4654 new LogFile, puts some text in it, and then ``closes'' it, meaning
4655 that no further contents will be added. This LogFile will appear in
4656 the HTML display under an HREF with the name ``warnings'', since that
4657 is the name of the LogFile.
4659 You can also use @code{addHTMLLog} to create a complete (closed)
4660 LogFile that contains HTML instead of plain text. The normal LogFile
4661 will be HTML-escaped if presented through a web page, but the HTML
4662 LogFile will not. At the moment this is only used to present a pretty
4663 HTML representation of an otherwise ugly exception traceback when
4664 something goes badly wrong during the BuildStep.
4666 In contrast, you might want to create a new LogFile at the beginning
4667 of the step, and add text to it as the command runs. You can create
4668 the LogFile and attach it to the build by calling @code{addLog}, which
4669 returns the LogFile object. You then add text to this LogFile by
4670 calling methods like @code{addStdout} and @code{addHeader}. When you
4671 are done, you must call the @code{finish} method so the LogFile can be
4672 closed. It may be useful to create and populate a LogFile like this
4673 from a LogObserver method @xref{Adding LogObservers}.
4675 The @code{logfiles=} argument to @code{ShellCommand} (see
4676 @pxref{ShellCommand}) creates new LogFiles and fills them in realtime
4677 by asking the buildslave to watch a actual file on disk. The
4678 buildslave will look for additions in the target file and report them
4679 back to the BuildStep. These additions will be added to the LogFile by
4680 calling @code{addStdout}. These secondary LogFiles can be used as the
4681 source of a LogObserver just like the normal ``stdio'' LogFile.
4683 @node Reading Logfiles, Adding LogObservers, BuildStep LogFiles, Writing New BuildSteps
4684 @subsubsection Reading Logfiles
4686 Once a LogFile has been added to a BuildStep with @code{addLog()},
4687 @code{addCompleteLog()}, @code{addHTMLLog()}, or @code{logfiles=},
4688 your BuildStep can retrieve it by using @code{getLog()}:
4690 @example
4691 class MyBuildStep(ShellCommand):
4692     logfiles = @{ "nodelog": "_test/node.log" @}
4694     def evaluateCommand(self, cmd):
4695         nodelog = self.getLog("nodelog")
4696         if "STARTED" in nodelog.getText():
4697             return SUCCESS
4698         else:
4699             return FAILURE
4700 @end example
4702 For a complete list of the methods you can call on a LogFile, please
4703 see the docstrings on the @code{IStatusLog} class in
4704 @file{buildbot/interfaces.py}.
4707 @node Adding LogObservers, BuildStep URLs, Reading Logfiles, Writing New BuildSteps
4708 @subsubsection Adding LogObservers
4710 @cindex LogObserver
4711 @cindex LogLineObserver
4713 Most shell commands emit messages to stdout or stderr as they operate,
4714 especially if you ask them nicely with a @code{--verbose} flag of some
4715 sort. They may also write text to a log file while they run. Your
4716 BuildStep can watch this output as it arrives, to keep track of how
4717 much progress the command has made. You can get a better measure of
4718 progress by counting the number of source files compiled or test cases
4719 run than by merely tracking the number of bytes that have been written
4720 to stdout. This improves the accuracy and the smoothness of the ETA
4721 display.
4723 To accomplish this, you will need to attach a @code{LogObserver} to
4724 one of the log channels, most commonly to the ``stdio'' channel but
4725 perhaps to another one which tracks a log file. This observer is given
4726 all text as it is emitted from the command, and has the opportunity to
4727 parse that output incrementally. Once the observer has decided that
4728 some event has occurred (like a source file being compiled), it can
4729 use the @code{setProgress} method to tell the BuildStep about the
4730 progress that this event represents.
4732 There are a number of pre-built @code{LogObserver} classes that you
4733 can choose from (defined in @code{buildbot.process.buildstep}, and of
4734 course you can subclass them to add further customization. The
4735 @code{LogLineObserver} class handles the grunt work of buffering and
4736 scanning for end-of-line delimiters, allowing your parser to operate
4737 on complete stdout/stderr lines.
4739 For example, let's take a look at the @code{TrialTestCaseCounter},
4740 which is used by the Trial step to count test cases as they are run.
4741 As Trial executes, it emits lines like the following:
4743 @example
4744 buildbot.test.test_config.ConfigTest.testDebugPassword ... [OK]
4745 buildbot.test.test_config.ConfigTest.testEmpty ... [OK]
4746 buildbot.test.test_config.ConfigTest.testIRC ... [FAIL]
4747 buildbot.test.test_config.ConfigTest.testLocks ... [OK]
4748 @end example
4750 When the tests are finished, trial emits a long line of ``======'' and
4751 then some lines which summarize the tests that failed. We want to
4752 avoid parsing these trailing lines, because their format is less
4753 well-defined than the ``[OK]'' lines.
4755 The parser class looks like this:
4757 @example
4758 from buildbot.process.buildstep import LogLineObserver
4760 class TrialTestCaseCounter(LogLineObserver):
4761     _line_re = re.compile(r'^([\w\.]+) \.\.\. \[([^\]]+)\]$')
4762     numTests = 0
4763     finished = False
4765     def outLineReceived(self, line):
4766         if self.finished:
4767             return
4768         if line.startswith("=" * 40):
4769             self.finished = True
4770             return
4772         m = self._line_re.search(line.strip())
4773         if m:
4774             testname, result = m.groups()
4775             self.numTests += 1
4776             self.step.setProgress('tests', self.numTests)
4777 @end example
4779 This parser only pays attention to stdout, since that's where trial
4780 writes the progress lines. It has a mode flag named @code{finished} to
4781 ignore everything after the ``===='' marker, and a scary-looking
4782 regular expression to match each line while hopefully ignoring other
4783 messages that might get displayed as the test runs.
4785 Each time it identifies a test has been completed, it increments its
4786 counter and delivers the new progress value to the step with
4787 @code{self.step.setProgress}. This class is specifically measuring
4788 progress along the ``tests'' metric, in units of test cases (as
4789 opposed to other kinds of progress like the ``output'' metric, which
4790 measures in units of bytes). The Progress-tracking code uses each
4791 progress metric separately to come up with an overall completion
4792 percentage and an ETA value.
4794 To connect this parser into the @code{Trial} BuildStep,
4795 @code{Trial.__init__} ends with the following clause:
4797 @example
4798         # this counter will feed Progress along the 'test cases' metric
4799         counter = TrialTestCaseCounter()
4800         self.addLogObserver('stdio', counter)
4801 @end example
4803 This creates a TrialTestCaseCounter and tells the step that the
4804 counter wants to watch the ``stdio'' log. The observer is
4805 automatically given a reference to the step in its @code{.step}
4806 attribute.
4808 @subheading A Somewhat Whimsical Example
4810 Let's say that we've got some snazzy new unit-test framework called
4811 Framboozle. It's the hottest thing since sliced bread. It slices, it
4812 dices, it runs unit tests like there's no tomorrow. Plus if your unit
4813 tests fail, you can use its name for a Web 2.1 startup company, make
4814 millions of dollars, and hire engineers to fix the bugs for you, while
4815 you spend your afternoons lazily hang-gliding along a scenic pacific
4816 beach, blissfully unconcerned about the state of your
4817 tests.@footnote{framboozle.com is still available. Remember, I get 10%
4818 :).}
4820 To run a Framboozle-enabled test suite, you just run the 'framboozler'
4821 command from the top of your source code tree. The 'framboozler'
4822 command emits a bunch of stuff to stdout, but the most interesting bit
4823 is that it emits the line "FNURRRGH!" every time it finishes running a
4824 test case@footnote{Framboozle gets very excited about running unit
4825 tests.}. You'd like to have a test-case counting LogObserver that
4826 watches for these lines and counts them, because counting them will
4827 help the buildbot more accurately calculate how long the build will
4828 take, and this will let you know exactly how long you can sneak out of
4829 the office for your hang-gliding lessons without anyone noticing that
4830 you're gone.
4832 This will involve writing a new BuildStep (probably named
4833 "Framboozle") which inherits from ShellCommand. The BuildStep class
4834 definition itself will look something like this:
4836 @example
4837 # START
4838 from buildbot.steps.shell import ShellCommand
4839 from buildbot.process.buildstep import LogLineObserver
4841 class FNURRRGHCounter(LogLineObserver):
4842     numTests = 0
4843     def outLineReceived(self, line):
4844         if "FNURRRGH!" in line:
4845             self.numTests += 1
4846             self.step.setProgress('tests', self.numTests)
4848 class Framboozle(ShellCommand):
4849     command = ["framboozler"]
4851     def __init__(self, **kwargs):
4852         ShellCommand.__init__(self, **kwargs)   # always upcall!
4853         counter = FNURRRGHCounter())
4854         self.addLogObserver(counter)
4855 # FINISH
4856 @end example
4858 So that's the code that we want to wind up using. How do we actually
4859 deploy it?
4861 You have a couple of different options.
4863 Option 1: The simplest technique is to simply put this text
4864 (everything from START to FINISH) in your master.cfg file, somewhere
4865 before the BuildFactory definition where you actually use it in a
4866 clause like:
4868 @example
4869 f = BuildFactory()
4870 f.addStep(SVN(svnurl="stuff"))
4871 f.addStep(Framboozle())
4872 @end example
4874 Remember that master.cfg is secretly just a python program with one
4875 job: populating the BuildmasterConfig dictionary. And python programs
4876 are allowed to define as many classes as they like. So you can define
4877 classes and use them in the same file, just as long as the class is
4878 defined before some other code tries to use it.
4880 This is easy, and it keeps the point of definition very close to the
4881 point of use, and whoever replaces you after that unfortunate
4882 hang-gliding accident will appreciate being able to easily figure out
4883 what the heck this stupid "Framboozle" step is doing anyways. The
4884 downside is that every time you reload the config file, the Framboozle
4885 class will get redefined, which means that the buildmaster will think
4886 that you've reconfigured all the Builders that use it, even though
4887 nothing changed. Bleh.
4889 Option 2: Instead, we can put this code in a separate file, and import
4890 it into the master.cfg file just like we would the normal buildsteps
4891 like ShellCommand and SVN.
4893 Create a directory named ~/lib/python, put everything from START to
4894 FINISH in ~/lib/python/framboozle.py, and run your buildmaster using:
4896 @example
4897  PYTHONPATH=~/lib/python buildbot start MASTERDIR
4898 @end example
4900 or use the @file{Makefile.buildbot} to control the way
4901 @command{buildbot start} works. Or add something like this to
4902 something like your ~/.bashrc or ~/.bash_profile or ~/.cshrc:
4904 @example
4905  export PYTHONPATH=~/lib/python
4906 @end example
4908 Once we've done this, our master.cfg can look like:
4910 @example
4911 from framboozle import Framboozle
4912 f = BuildFactory()
4913 f.addStep(SVN(svnurl="stuff"))
4914 f.addStep(Framboozle())
4915 @end example
4919 @example
4920 import framboozle
4921 f = BuildFactory()
4922 f.addStep(SVN(svnurl="stuff"))
4923 f.addStep(framboozle.Framboozle())
4924 @end example
4926 (check out the python docs for details about how "import" and "from A
4927 import B" work).
4929 What we've done here is to tell python that every time it handles an
4930 "import" statement for some named module, it should look in our
4931 ~/lib/python/ for that module before it looks anywhere else. After our
4932 directories, it will try in a bunch of standard directories too
4933 (including the one where buildbot is installed). By setting the
4934 PYTHONPATH environment variable, you can add directories to the front
4935 of this search list.
4937 Python knows that once it "import"s a file, it doesn't need to
4938 re-import it again. This means that reconfiguring the buildmaster
4939 (with "buildbot reconfig", for example) won't make it think the
4940 Framboozle class has changed every time, so the Builders that use it
4941 will not be spuriously restarted. On the other hand, you either have
4942 to start your buildmaster in a slightly weird way, or you have to
4943 modify your environment to set the PYTHONPATH variable.
4946 Option 3: Install this code into a standard python library directory
4948 Find out what your python's standard include path is by asking it:
4950 @example
4951 80:warner@@luther% python
4952 Python 2.4.4c0 (#2, Oct  2 2006, 00:57:46) 
4953 [GCC 4.1.2 20060928 (prerelease) (Debian 4.1.1-15)] on linux2
4954 Type "help", "copyright", "credits" or "license" for more information.
4955 >>> import sys
4956 >>> print sys.path
4957 ['', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/local/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages/Numeric', '/var/lib/python-support/python2.4', '/usr/lib/site-python']
4958 >>> 
4959 @end example
4961 In this case, putting the code into
4962 /usr/local/lib/python2.4/site-packages/framboozle.py would work just
4963 fine. We can use the same master.cfg "import framboozle" statement as
4964 in Option 2. By putting it in a standard include directory (instead of
4965 the decidedly non-standard ~/lib/python), we don't even have to set
4966 PYTHONPATH to anything special. The downside is that you probably have
4967 to be root to write to one of those standard include directories.
4970 Option 4: Submit the code for inclusion in the Buildbot distribution
4972 Contribute the code in an Enhancement Request on SourceForge, via
4973 http://buildbot.sf.net . Lobby, convince, coerce, bribe, badger,
4974 harass, threaten, or otherwise encourage the author to accept the
4975 patch. This lets you do something like:
4977 @example
4978 from buildbot.steps import framboozle
4979 f = BuildFactory()
4980 f.addStep(SVN(svnurl="stuff"))
4981 f.addStep(framboozle.Framboozle())
4982 @end example
4984 And then you don't even have to install framboozle.py anywhere on your
4985 system, since it will ship with Buildbot. You don't have to be root,
4986 you don't have to set PYTHONPATH. But you do have to make a good case
4987 for Framboozle being worth going into the main distribution, you'll
4988 probably have to provide docs and some unit test cases, you'll need to
4989 figure out what kind of beer the author likes, and then you'll have to
4990 wait until the next release. But in some environments, all this is
4991 easier than getting root on your buildmaster box, so the tradeoffs may
4992 actually be worth it.
4996 Putting the code in master.cfg (1) makes it available to that
4997 buildmaster instance. Putting it in a file in a personal library
4998 directory (2) makes it available for any buildmasters you might be
4999 running. Putting it in a file in a system-wide shared library
5000 directory (3) makes it available for any buildmasters that anyone on
5001 that system might be running. Getting it into the buildbot's upstream
5002 repository (4) makes it available for any buildmasters that anyone in
5003 the world might be running. It's all a matter of how widely you want
5004 to deploy that new class.
5008 @node BuildStep URLs,  , Adding LogObservers, Writing New BuildSteps
5009 @subsubsection BuildStep URLs
5011 @cindex links
5012 @cindex BuildStep URLs
5013 @cindex addURL
5015 Each BuildStep has a collection of ``links''. Like its collection of
5016 LogFiles, each link has a name and a target URL. The web status page
5017 creates HREFs for each link in the same box as it does for LogFiles,
5018 except that the target of the link is the external URL instead of an
5019 internal link to a page that shows the contents of the LogFile.
5021 These external links can be used to point at build information hosted
5022 on other servers. For example, the test process might produce an
5023 intricate description of which tests passed and failed, or some sort
5024 of code coverage data in HTML form, or a PNG or GIF image with a graph
5025 of memory usage over time. The external link can provide an easy way
5026 for users to navigate from the buildbot's status page to these
5027 external web sites or file servers. Note that the step itself is
5028 responsible for insuring that there will be a document available at
5029 the given URL (perhaps by using @command{scp} to copy the HTML output
5030 to a @file{~/public_html/} directory on a remote web server). Calling
5031 @code{addURL} does not magically populate a web server.
5033 To set one of these links, the BuildStep should call the @code{addURL}
5034 method with the name of the link and the target URL. Multiple URLs can
5035 be set.
5037 In this example, we assume that the @command{make test} command causes
5038 a collection of HTML files to be created and put somewhere on the
5039 coverage.example.org web server, in a filename that incorporates the
5040 build number.
5042 @example
5043 class TestWithCodeCoverage(BuildStep):
5044     command = ["make", "test",
5045                WithProperties("buildnum=%s" % "buildnumber")]
5047     def createSummary(self, log):
5048         buildnumber = self.getProperty("buildnumber")
5049         url = "http://coverage.example.org/builds/%s.html" % buildnumber
5050         self.addURL("coverage", url)
5051 @end example
5053 You might also want to extract the URL from some special message
5054 output by the build process itself:
5056 @example
5057 class TestWithCodeCoverage(BuildStep):
5058     command = ["make", "test",
5059                WithProperties("buildnum=%s" % "buildnumber")]
5061     def createSummary(self, log):
5062         output = StringIO(log.getText())
5063         for line in output.readlines():
5064             if line.startswith("coverage-url:"):
5065                 url = line[len("coverage-url:"):].strip()
5066                 self.addURL("coverage", url)
5067                 return
5068 @end example
5070 Note that a build process which emits both stdout and stderr might
5071 cause this line to be split or interleaved between other lines. It
5072 might be necessary to restrict the getText() call to only stdout with
5073 something like this:
5075 @example
5076         output = StringIO("".join([c[1]
5077                                    for c in log.getChunks()
5078                                    if c[0] == LOG_CHANNEL_STDOUT]))
5079 @end example
5081 Of course if the build is run under a PTY, then stdout and stderr will
5082 be merged before the buildbot ever sees them, so such interleaving
5083 will be unavoidable.
5086 @node Interlocks, Build Factories, Build Steps, Build Process
5087 @section Interlocks
5089 @cindex locks
5090 @slindex buildbot.locks.MasterLock
5091 @slindex buildbot.locks.SlaveLock
5093 For various reasons, you may want to prevent certain Steps (or perhaps
5094 entire Builds) from running simultaneously. Limited CPU speed or
5095 network bandwidth to the VC server, problems with simultaneous access
5096 to a database server used by unit tests, or multiple Builds which
5097 access shared state may all require some kind of interlock to prevent
5098 corruption, confusion, or resource overload. These resources might
5099 require completely exclusive access, or it might be sufficient to
5100 establish a limit of two or three simultaneous builds.
5102 @code{Locks} are the mechanism used to express these kinds of
5103 constraints on when Builds or Steps can be run. There are two kinds of
5104 @code{Locks}, each with their own scope: @code{MasterLock} instances
5105 are scoped to the buildbot as a whole, while @code{SlaveLock}s are
5106 scoped to a single buildslave. This means that each buildslave has a
5107 separate copy of each @code{SlaveLock}, which could enforce a
5108 one-Build-at-a-time limit for each machine, but still allow as many
5109 simultaneous builds as there are machines.
5111 Each @code{Lock} is created with a unique name. Each lock gets a count
5112 of how many owners it may have: how many processes can claim it at ths
5113 same time. This limit defaults to one, and is controllable through the
5114 @code{maxCount} argument. On @code{SlaveLock}s you can set the owner
5115 count on a per-slave basis by providing a dictionary (that maps from
5116 slavename to maximum owner count) to its @code{maxCountForSlave}
5117 argument. Any buildslaves that aren't mentioned in
5118 @code{maxCountForSlave} get their owner count from @code{maxCount}.
5120 To use a lock, simply include it in the @code{locks=} argument of the
5121 @code{BuildStep} object that should obtain the lock before it runs.
5122 This argument accepts a list of @code{Lock} objects: the Step will
5123 acquire all of them before it runs.
5125 To claim a lock for the whole Build, add a @code{'locks'} key to the
5126 builder specification dictionary with the same list of @code{Lock}
5127 objects. (This is the dictionary that has the @code{'name'},
5128 @code{'slavename'}, @code{'builddir'}, and @code{'factory'} keys). The
5129 @code{Build} object also accepts a @code{locks=} argument, but unless
5130 you are writing your own @code{BuildFactory} subclass then it will be
5131 easier to set the locks in the builder dictionary.
5133 Note that there are no partial-acquire or partial-release semantics:
5134 this prevents deadlocks caused by two Steps each waiting for a lock
5135 held by the other@footnote{Also note that a clever buildmaster admin
5136 could still create the opportunity for deadlock: Build A obtains Lock
5137 1, inside which Step A.two tries to acquire Lock 2 at the Step level.
5138 Meanwhile Build B obtains Lock 2, and has a Step B.two which wants to
5139 acquire Lock 1 at the Step level. Don't Do That.}. This also means
5140 that waiting to acquire a @code{Lock} can take an arbitrarily long
5141 time: if the buildmaster is very busy, a Step or Build which requires
5142 only one @code{Lock} may starve another that is waiting for that
5143 @code{Lock} plus some others.
5146 In the following example, we run the same build on three different
5147 platforms. The unit-test steps of these builds all use a common
5148 database server, and would interfere with each other if allowed to run
5149 simultaneously. The @code{Lock} prevents more than one of these builds
5150 from happening at the same time.
5152 @example
5153 from buildbot import locks
5154 from buildbot.steps import source, shell
5155 from buildbot.process import factory
5157 db_lock = locks.MasterLock("database")
5158 f = factory.BuildFactory()
5159 f.addStep(source.SVN(svnurl="http://example.org/svn/Trunk"))
5160 f.addStep(shell.ShellCommand(command="make all"))
5161 f.addStep(shell.ShellCommand(command="make test", locks=[db_lock]))
5162 b1 = @{'name': 'full1', 'slavename': 'bot-1', builddir='f1', 'factory': f@}
5163 b2 = @{'name': 'full2', 'slavename': 'bot-2', builddir='f2', 'factory': f@}
5164 b3 = @{'name': 'full3', 'slavename': 'bot-3', builddir='f3', 'factory': f@}
5165 c['builders'] = [b1, b2, b3]
5166 @end example
5168 In the next example, we have one buildslave hosting three separate
5169 Builders (each running tests against a different version of Python).
5170 The machine which hosts this buildslave is not particularly fast, so
5171 we want to prevent all three builds from all happening at the same
5172 time. (Assume we've experimentally determined that one build leaves
5173 unused CPU capacity, three builds causes a lot of disk thrashing, but
5174 two builds at a time is Just Right). We use a @code{SlaveLock} because
5175 the builds happening on this one slow slave should not affect builds
5176 running on other slaves, and we use the lock on the build as a whole
5177 because the slave is so slow that even multiple simultaneous SVN
5178 checkouts would be too taxing. We set @code{maxCount=2} to achieve our
5179 goal of two simultaneous builds per slave.
5181 @example
5182 from buildbot import locks
5183 from buildbot.steps import source
5184 from buildbot.process import s, factory
5186 slow_lock = locks.SlaveLock("cpu", maxCount=2)
5187 source = s(source.SVN, svnurl="http://example.org/svn/Trunk")
5188 f22 = factory.Trial(source, trialpython=["python2.2"])
5189 f23 = factory.Trial(source, trialpython=["python2.3"])
5190 f24 = factory.Trial(source, trialpython=["python2.4"])
5191 b1 = @{'name': 'p22', 'slavename': 'bot-1', builddir='p22', 'factory': f22,
5192       'locks': [slow_lock] @}
5193 b2 = @{'name': 'p23', 'slavename': 'bot-1', builddir='p23', 'factory': f23,
5194       'locks': [slow_lock] @}
5195 b3 = @{'name': 'p24', 'slavename': 'bot-1', builddir='p24', 'factory': f24,
5196       'locks': [slow_lock] @}
5197 c['builders'] = [b1, b2, b3]
5198 @end example
5200 In the last example, we use two Locks at the same time. In this case,
5201 we're concerned about both of the previous constraints, but we'll say
5202 that only the tests are computationally intensive, and that they have
5203 been split into those which use the database and those which do not.
5204 In addition, two of the Builds run on a fast machine which does not
5205 need to worry about the cpu lock, but which still must be prevented
5206 from simultaneous database access. We use @code{maxCountForSlave} to
5207 limit the slow machine to one simultanous build, but allow practically
5208 unlimited concurrent builds on the fast machine.
5210 @example
5211 from buildbot import locks
5212 from buildbot.steps import source, shell
5213 from buildbot.process import factory
5215 db_lock = locks.MasterLock("database")
5216 slavecounts = @{"bot-slow": 1, "bot-fast": 100@}
5217 cpu_lock = locks.SlaveLock("cpu", maxCountForSlave=slavecounts)
5218 f = factory.BuildFactory()
5219 f.addStep(source.SVN(svnurl="http://example.org/svn/Trunk"))
5220 f.addStep(shell.ShellCommand(command="make all", locks=[cpu_lock]))
5221 f.addStep(shell.ShellCommand(command="make test", locks=[cpu_lock]))
5222 f.addStep(shell.ShellCommand(command="make db-test", locks=[db_lock, cpu_lock]))
5224 b1 = @{'name': 'full1', 'slavename': 'bot-slow', builddir='full1',
5225       'factory': f@}
5226 b2 = @{'name': 'full2', 'slavename': 'bot-slow', builddir='full2',
5227       'factory': f@}
5228 b3 = @{'name': 'full3', 'slavename': 'bot-fast', builddir='full3',
5229       'factory': f@}
5230 b4 = @{'name': 'full4', 'slavename': 'bot-fast', builddir='full4',
5231       'factory': f@}
5232 c['builders'] = [b1, b2, b3, b4]
5233 @end example
5235 As a final note, remember that a unit test system which breaks when
5236 multiple people run it at the same time is fragile and should be
5237 fixed. Asking your human developers to serialize themselves when
5238 running unit tests will just discourage them from running the unit
5239 tests at all. Find a way to fix this: change the database tests to
5240 create a new (uniquely-named) user or table for each test run, don't
5241 use fixed listening TCP ports for network tests (instead listen on
5242 port 0 to let the kernel choose a port for you and then query the
5243 socket to find out what port was allocated). @code{MasterLock}s can be
5244 used to accomodate broken test systems like this, but are really
5245 intended for other purposes: build processes that store or retrieve
5246 products in shared directories, or which do things that human
5247 developers would not (or which might slow down or break in ways that
5248 require human attention to deal with).
5250 @code{SlaveLocks}s can be used to keep automated performance tests
5251 from interfering with each other, when there are multiple Builders all
5252 using the same buildslave. But they can't prevent other users from
5253 running CPU-intensive jobs on that host while the tests are running.
5255 @node Build Factories,  , Interlocks, Build Process
5256 @section Build Factories
5259 Each Builder is equipped with a ``build factory'', which is
5260 responsible for producing the actual @code{Build} objects that perform
5261 each build. This factory is created in the configuration file, and
5262 attached to a Builder through the @code{factory} element of its
5263 dictionary.
5265 The standard @code{BuildFactory} object creates @code{Build} objects
5266 by default. These Builds will each execute a collection of BuildSteps
5267 in a fixed sequence. Each step can affect the results of the build,
5268 but in general there is little intelligence to tie the different steps
5269 together. You can create subclasses of @code{Build} to implement more
5270 sophisticated build processes, and then use a subclass of
5271 @code{BuildFactory} (or simply set the @code{buildClass} attribute) to
5272 create instances of your new Build subclass.
5275 @menu
5276 * BuildStep Objects::           
5277 * BuildFactory::                
5278 * Process-Specific build factories::  
5279 @end menu
5281 @node BuildStep Objects, BuildFactory, Build Factories, Build Factories
5282 @subsection BuildStep Objects
5284 The steps used by these builds are all subclasses of @code{BuildStep}.
5285 The standard ones provided with Buildbot are documented later,
5286 @xref{Build Steps}. You can also write your own subclasses to use in
5287 builds.
5289 The basic behavior for a @code{BuildStep} is to:
5291 @itemize @bullet
5292 @item
5293 run for a while, then stop
5294 @item
5295 possibly invoke some RemoteCommands on the attached build slave
5296 @item
5297 possibly produce a set of log files
5298 @item
5299 finish with a status described by one of four values defined in
5300 buildbot.status.builder: SUCCESS, WARNINGS, FAILURE, SKIPPED
5301 @item
5302 provide a list of short strings to describe the step
5303 @item
5304 define a color (generally green, orange, or red) with which the
5305 step should be displayed
5306 @end itemize
5309 More sophisticated steps may produce additional information and
5310 provide it to later build steps, or store it in the factory to provide
5311 to later builds.
5314 @menu
5315 * BuildFactory Attributes::     
5316 * Quick builds::                
5317 @end menu
5319 @node BuildFactory, Process-Specific build factories, BuildStep Objects, Build Factories
5320 @subsection BuildFactory
5322 @bfindex buildbot.process.factory.BuildFactory
5323 @bfindex buildbot.process.factory.BasicBuildFactory
5324 @c TODO: what is BasicSVN anyway?
5325 @bfindex buildbot.process.factory.BasicSVN
5327 The default @code{BuildFactory}, provided in the
5328 @code{buildbot.process.factory} module, contains an internal list of
5329 ``BuildStep specifications'': a list of @code{(step_class, kwargs)}
5330 tuples for each. These specification tuples are constructed when the
5331 config file is read, by asking the instances passed to @code{addStep}
5332 for their subclass and arguments.
5334 When asked to create a Build, the @code{BuildFactory} puts a copy of
5335 the list of step specifications into the new Build object. When the
5336 Build is actually started, these step specifications are used to
5337 create the actual set of BuildSteps, which are then executed one at a
5338 time. This serves to give each Build an independent copy of each step.
5339 For example, a build which consists of a CVS checkout followed by a
5340 @code{make build} would be constructed as follows:
5342 @example
5343 from buildbot.steps import source, shell
5344 from buildbot.process import factory
5346 f = factory.BuildFactory()
5347 f.addStep(source.CVS(cvsroot=CVSROOT, cvsmodule="project", mode="update"))
5348 f.addStep(shell.Compile(command=["make", "build"]))
5349 @end example
5351 (To support config files from buildbot-0.7.5 and earlier,
5352 @code{addStep} also accepts the @code{f.addStep(shell.Compile,
5353 command=["make","build"])} form, although its use is discouraged
5354 because then the @code{Compile} step doesn't get to validate or
5355 complain about its arguments until build time. The modern
5356 pass-by-instance approach allows this validation to occur while the
5357 config file is being loaded, where the admin has a better chance of
5358 noticing problems).
5360 It is also possible to pass a list of steps into the
5361 @code{BuildFactory} when it is created. Using @code{addStep} is
5362 usually simpler, but there are cases where is is more convenient to
5363 create the list of steps ahead of time.:
5365 @example
5366 from buildbot.steps import source, shell
5367 from buildbot.process import factory
5369 all_steps = [source.CVS(cvsroot=CVSROOT, cvsmodule="project", mode="update"),
5370              shell.Compile(command=["make", "build"]),
5371             ]
5372 f = factory.BuildFactory(all_steps)
5373 @end example
5376 Each step can affect the build process in the following ways:
5378 @itemize @bullet
5379 @item
5380 If the step's @code{haltOnFailure} attribute is True, then a failure
5381 in the step (i.e. if it completes with a result of FAILURE) will cause
5382 the whole build to be terminated immediately: no further steps will be
5383 executed. This is useful for setup steps upon which the rest of the
5384 build depends: if the CVS checkout or @code{./configure} process
5385 fails, there is no point in trying to compile or test the resulting
5386 tree.
5388 @item
5389 If the @code{flunkOnFailure} or @code{flunkOnWarnings} flag is set,
5390 then a result of FAILURE or WARNINGS will mark the build as a whole as
5391 FAILED. However, the remaining steps will still be executed. This is
5392 appropriate for things like multiple testing steps: a failure in any
5393 one of them will indicate that the build has failed, however it is
5394 still useful to run them all to completion.
5396 @item
5397 Similarly, if the @code{warnOnFailure} or @code{warnOnWarnings} flag
5398 is set, then a result of FAILURE or WARNINGS will mark the build as
5399 having WARNINGS, and the remaining steps will still be executed. This
5400 may be appropriate for certain kinds of optional build or test steps.
5401 For example, a failure experienced while building documentation files
5402 should be made visible with a WARNINGS result but not be serious
5403 enough to warrant marking the whole build with a FAILURE.
5405 @end itemize
5407 In addition, each Step produces its own results, may create logfiles,
5408 etc. However only the flags described above have any effect on the
5409 build as a whole.
5411 The pre-defined BuildSteps like @code{CVS} and @code{Compile} have
5412 reasonably appropriate flags set on them already. For example, without
5413 a source tree there is no point in continuing the build, so the
5414 @code{CVS} class has the @code{haltOnFailure} flag set to True. Look
5415 in @file{buildbot/steps/*.py} to see how the other Steps are
5416 marked.
5418 Each Step is created with an additional @code{workdir} argument that
5419 indicates where its actions should take place. This is specified as a
5420 subdirectory of the slave builder's base directory, with a default
5421 value of @code{build}. This is only implemented as a step argument (as
5422 opposed to simply being a part of the base directory) because the
5423 CVS/SVN steps need to perform their checkouts from the parent
5424 directory.
5426 @menu
5427 * BuildFactory Attributes::     
5428 * Quick builds::                
5429 @end menu
5431 @node BuildFactory Attributes, Quick builds, BuildFactory, BuildFactory
5432 @subsubsection BuildFactory Attributes
5434 Some attributes from the BuildFactory are copied into each Build.
5436 @cindex treeStableTimer
5438 @table @code
5439 @item useProgress
5440 (defaults to True): if True, the buildmaster keeps track of how long
5441 each step takes, so it can provide estimates of how long future builds
5442 will take. If builds are not expected to take a consistent amount of
5443 time (such as incremental builds in which a random set of files are
5444 recompiled or tested each time), this should be set to False to
5445 inhibit progress-tracking.
5447 @end table
5450 @node Quick builds,  , BuildFactory Attributes, BuildFactory
5451 @subsubsection Quick builds
5453 @bfindex buildbot.process.factory.QuickBuildFactory
5455 The difference between a ``full build'' and a ``quick build'' is that
5456 quick builds are generally done incrementally, starting with the tree
5457 where the previous build was performed. That simply means that the
5458 source-checkout step should be given a @code{mode='update'} flag, to
5459 do the source update in-place.
5461 In addition to that, the @code{useProgress} flag should be set to
5462 False. Incremental builds will (or at least the ought to) compile as
5463 few files as necessary, so they will take an unpredictable amount of
5464 time to run. Therefore it would be misleading to claim to predict how
5465 long the build will take.
5468 @node Process-Specific build factories,  , BuildFactory, Build Factories
5469 @subsection Process-Specific build factories
5471 Many projects use one of a few popular build frameworks to simplify
5472 the creation and maintenance of Makefiles or other compilation
5473 structures. Buildbot provides several pre-configured BuildFactory
5474 subclasses which let you build these projects with a minimum of fuss.
5476 @menu
5477 * GNUAutoconf::                 
5478 * CPAN::                        
5479 * Python distutils::            
5480 * Python/Twisted/trial projects::  
5481 @end menu
5483 @node GNUAutoconf, CPAN, Process-Specific build factories, Process-Specific build factories
5484 @subsubsection GNUAutoconf
5486 @bfindex buildbot.process.factory.GNUAutoconf
5488 @uref{http://www.gnu.org/software/autoconf/, GNU Autoconf} is a
5489 software portability tool, intended to make it possible to write
5490 programs in C (and other languages) which will run on a variety of
5491 UNIX-like systems. Most GNU software is built using autoconf. It is
5492 frequently used in combination with GNU automake. These tools both
5493 encourage a build process which usually looks like this:
5495 @example
5496 % CONFIG_ENV=foo ./configure --with-flags
5497 % make all
5498 % make check
5499 # make install
5500 @end example
5502 (except of course the Buildbot always skips the @code{make install}
5503 part).
5505 The Buildbot's @code{buildbot.process.factory.GNUAutoconf} factory is
5506 designed to build projects which use GNU autoconf and/or automake. The
5507 configuration environment variables, the configure flags, and command
5508 lines used for the compile and test are all configurable, in general
5509 the default values will be suitable.
5511 Example:
5513 @example
5514 # use the s() convenience function defined earlier
5515 f = factory.GNUAutoconf(source=s(step.SVN, svnurl=URL, mode="copy"),
5516                         flags=["--disable-nls"])
5517 @end example
5519 Required Arguments:
5521 @table @code
5522 @item source
5523 This argument must be a step specification tuple that provides a
5524 BuildStep to generate the source tree.
5525 @end table
5527 Optional Arguments:
5529 @table @code
5530 @item configure
5531 The command used to configure the tree. Defaults to
5532 @code{./configure}. Accepts either a string or a list of shell argv
5533 elements.
5535 @item configureEnv
5536 The environment used for the initial configuration step. This accepts
5537 a dictionary which will be merged into the buildslave's normal
5538 environment. This is commonly used to provide things like
5539 @code{CFLAGS="-O2 -g"} (to turn off debug symbols during the compile).
5540 Defaults to an empty dictionary.
5542 @item configureFlags
5543 A list of flags to be appended to the argument list of the configure
5544 command. This is commonly used to enable or disable specific features
5545 of the autoconf-controlled package, like @code{["--without-x"]} to
5546 disable windowing support. Defaults to an empty list.
5548 @item compile
5549 this is a shell command or list of argv values which is used to
5550 actually compile the tree. It defaults to @code{make all}. If set to
5551 None, the compile step is skipped.
5553 @item test
5554 this is a shell command or list of argv values which is used to run
5555 the tree's self-tests. It defaults to @code{make check}. If set to
5556 None, the test step is skipped.
5558 @end table
5561 @node CPAN, Python distutils, GNUAutoconf, Process-Specific build factories
5562 @subsubsection CPAN
5564 @bfindex buildbot.process.factory.CPAN
5566 Most Perl modules available from the @uref{http://www.cpan.org/, CPAN}
5567 archive use the @code{MakeMaker} module to provide configuration,
5568 build, and test services. The standard build routine for these modules
5569 looks like:
5571 @example
5572 % perl Makefile.PL
5573 % make
5574 % make test
5575 # make install
5576 @end example
5578 (except again Buildbot skips the install step)
5580 Buildbot provides a @code{CPAN} factory to compile and test these
5581 projects.
5584 Arguments:
5585 @table @code
5586 @item source
5587 (required): A step specification tuple, that that used by GNUAutoconf.
5589 @item perl
5590 A string which specifies the @code{perl} executable to use. Defaults
5591 to just @code{perl}.
5593 @end table
5596 @node Python distutils, Python/Twisted/trial projects, CPAN, Process-Specific build factories
5597 @subsubsection Python distutils
5599 @bfindex buildbot.process.factory.Distutils
5601 Most Python modules use the @code{distutils} package to provide
5602 configuration and build services. The standard build process looks
5603 like:
5605 @example
5606 % python ./setup.py build
5607 % python ./setup.py install
5608 @end example
5610 Unfortunately, although Python provides a standard unit-test framework
5611 named @code{unittest}, to the best of my knowledge @code{distutils}
5612 does not provide a standardized target to run such unit tests. (please
5613 let me know if I'm wrong, and I will update this factory).
5615 The @code{Distutils} factory provides support for running the build
5616 part of this process. It accepts the same @code{source=} parameter as
5617 the other build factories.
5620 Arguments:
5621 @table @code
5622 @item source
5623 (required): A step specification tuple, that that used by GNUAutoconf.
5624   
5625 @item python
5626 A string which specifies the @code{python} executable to use. Defaults
5627 to just @code{python}.
5629 @item test
5630 Provides a shell command which runs unit tests. This accepts either a
5631 string or a list. The default value is None, which disables the test
5632 step (since there is no common default command to run unit tests in
5633 distutils modules).
5635 @end table
5638 @node Python/Twisted/trial projects,  , Python distutils, Process-Specific build factories
5639 @subsubsection Python/Twisted/trial projects
5641 @bfindex buildbot.process.factory.Trial
5642 @c TODO: document these steps better
5643 @bsindex buildbot.steps.python_twisted.HLint
5644 @bsindex buildbot.steps.python_twisted.Trial
5645 @bsindex buildbot.steps.python_twisted.ProcessDocs
5646 @bsindex buildbot.steps.python_twisted.BuildDebs
5647 @bsindex buildbot.steps.python_twisted.RemovePYCs
5649 Twisted provides a unit test tool named @code{trial} which provides a
5650 few improvements over Python's built-in @code{unittest} module. Many
5651 python projects which use Twisted for their networking or application
5652 services also use trial for their unit tests. These modules are
5653 usually built and tested with something like the following:
5655 @example
5656 % python ./setup.py build
5657 % PYTHONPATH=build/lib.linux-i686-2.3 trial -v PROJECTNAME.test
5658 % python ./setup.py install
5659 @end example
5661 Unfortunately, the @file{build/lib} directory into which the
5662 built/copied .py files are placed is actually architecture-dependent,
5663 and I do not yet know of a simple way to calculate its value. For many
5664 projects it is sufficient to import their libraries ``in place'' from
5665 the tree's base directory (@code{PYTHONPATH=.}).
5667 In addition, the @var{PROJECTNAME} value where the test files are
5668 located is project-dependent: it is usually just the project's
5669 top-level library directory, as common practice suggests the unit test
5670 files are put in the @code{test} sub-module. This value cannot be
5671 guessed, the @code{Trial} class must be told where to find the test
5672 files.
5674 The @code{Trial} class provides support for building and testing
5675 projects which use distutils and trial. If the test module name is
5676 specified, trial will be invoked. The library path used for testing
5677 can also be set.
5679 One advantage of trial is that the Buildbot happens to know how to
5680 parse trial output, letting it identify which tests passed and which
5681 ones failed. The Buildbot can then provide fine-grained reports about
5682 how many tests have failed, when individual tests fail when they had
5683 been passing previously, etc.
5685 Another feature of trial is that you can give it a series of source
5686 .py files, and it will search them for special @code{test-case-name}
5687 tags that indicate which test cases provide coverage for that file.
5688 Trial can then run just the appropriate tests. This is useful for
5689 quick builds, where you want to only run the test cases that cover the
5690 changed functionality.
5692 Arguments:
5693 @table @code
5694 @item source
5695 (required): A step specification tuple, like that used by GNUAutoconf.
5697 @item buildpython
5698 A list (argv array) of strings which specifies the @code{python}
5699 executable to use when building the package. Defaults to just
5700 @code{['python']}. It may be useful to add flags here, to supress
5701 warnings during compilation of extension modules. This list is
5702 extended with @code{['./setup.py', 'build']} and then executed in a
5703 ShellCommand.
5705 @item testpath
5706 Provides a directory to add to @code{PYTHONPATH} when running the unit
5707 tests, if tests are being run. Defaults to @code{.} to include the
5708 project files in-place. The generated build library is frequently
5709 architecture-dependent, but may simply be @file{build/lib} for
5710 pure-python modules.
5712 @item trialpython
5713 Another list of strings used to build the command that actually runs
5714 trial. This is prepended to the contents of the @code{trial} argument
5715 below. It may be useful to add @code{-W} flags here to supress
5716 warnings that occur while tests are being run. Defaults to an empty
5717 list, meaning @code{trial} will be run without an explicit
5718 interpreter, which is generally what you want if you're using
5719 @file{/usr/bin/trial} instead of, say, the @file{./bin/trial} that
5720 lives in the Twisted source tree.
5722 @item trial
5723 provides the name of the @code{trial} command. It is occasionally
5724 useful to use an alternate executable, such as @code{trial2.2} which
5725 might run the tests under an older version of Python. Defaults to
5726 @code{trial}.
5728 @item tests
5729 Provides a module name or names which contain the unit tests for this
5730 project. Accepts a string, typically @code{PROJECTNAME.test}, or a
5731 list of strings. Defaults to None, indicating that no tests should be
5732 run. You must either set this or @code{useTestCaseNames} to do anyting
5733 useful with the Trial factory.
5735 @item useTestCaseNames
5736 Tells the Step to provide the names of all changed .py files to trial,
5737 so it can look for test-case-name tags and run just the matching test
5738 cases. Suitable for use in quick builds. Defaults to False.
5740 @item randomly
5741 If @code{True}, tells Trial (with the @code{--random=0} argument) to
5742 run the test cases in random order, which sometimes catches subtle
5743 inter-test dependency bugs. Defaults to @code{False}.
5745 @item recurse
5746 If @code{True}, tells Trial (with the @code{--recurse} argument) to
5747 look in all subdirectories for additional test cases. It isn't clear
5748 to me how this works, but it may be useful to deal with the
5749 unknown-PROJECTNAME problem described above, and is currently used in
5750 the Twisted buildbot to accomodate the fact that test cases are now
5751 distributed through multiple twisted.SUBPROJECT.test directories.
5753 @end table  
5755 Unless one of @code{trialModule} or @code{useTestCaseNames}
5756 are set, no tests will be run.
5758 Some quick examples follow. Most of these examples assume that the
5759 target python code (the ``code under test'') can be reached directly
5760 from the root of the target tree, rather than being in a @file{lib/}
5761 subdirectory.
5763 @example
5764 #  Trial(source, tests="toplevel.test") does:
5765 #   python ./setup.py build
5766 #   PYTHONPATH=. trial -to toplevel.test
5768 #  Trial(source, tests=["toplevel.test", "other.test"]) does:
5769 #   python ./setup.py build
5770 #   PYTHONPATH=. trial -to toplevel.test other.test
5772 #  Trial(source, useTestCaseNames=True) does:
5773 #   python ./setup.py build
5774 #   PYTHONPATH=. trial -to --testmodule=foo/bar.py..  (from Changes)
5776 #  Trial(source, buildpython=["python2.3", "-Wall"], tests="foo.tests"):
5777 #   python2.3 -Wall ./setup.py build
5778 #   PYTHONPATH=. trial -to foo.tests
5780 #  Trial(source, trialpython="python2.3", trial="/usr/bin/trial",
5781 #        tests="foo.tests") does:
5782 #   python2.3 -Wall ./setup.py build
5783 #   PYTHONPATH=. python2.3 /usr/bin/trial -to foo.tests
5785 # For running trial out of the tree being tested (only useful when the
5786 # tree being built is Twisted itself):
5787 #  Trial(source, trialpython=["python2.3", "-Wall"], trial="./bin/trial",
5788 #        tests="foo.tests") does:
5789 #   python2.3 -Wall ./setup.py build
5790 #   PYTHONPATH=. python2.3 -Wall ./bin/trial -to foo.tests
5791 @end example
5793 If the output directory of @code{./setup.py build} is known, you can
5794 pull the python code from the built location instead of the source
5795 directories. This should be able to handle variations in where the
5796 source comes from, as well as accomodating binary extension modules:
5798 @example
5799 # Trial(source,tests="toplevel.test",testpath='build/lib.linux-i686-2.3')
5800 # does:
5801 #  python ./setup.py build
5802 #  PYTHONPATH=build/lib.linux-i686-2.3 trial -to toplevel.test
5803 @end example
5806 @node Status Delivery, Command-line tool, Build Process, Top
5807 @chapter Status Delivery
5809 More details are available in the docstrings for each class, use
5810 @code{pydoc buildbot.status.html.Waterfall} to see them. Most status
5811 delivery objects take a @code{categories=} argument, which can contain
5812 a list of ``category'' names: in this case, it will only show status
5813 for Builders that are in one of the named categories.
5815 (implementor's note: each of these objects should be a
5816 service.MultiService which will be attached to the BuildMaster object
5817 when the configuration is processed. They should use
5818 @code{self.parent.getStatus()} to get access to the top-level IStatus
5819 object, either inside @code{startService} or later. They may call
5820 @code{status.subscribe()} in @code{startService} to receive
5821 notifications of builder events, in which case they must define
5822 @code{builderAdded} and related methods. See the docstrings in
5823 @file{buildbot/interfaces.py} for full details.)
5825 @menu
5826 * HTML Waterfall::              
5827 * WebStatus::                   
5828 * IRC Bot::                     
5829 * PBListener::                  
5830 * Writing New Status Plugins::  
5831 @end menu
5833 @c @node Email Delivery,  , Status Delivery, Status Delivery
5834 @c @subsection Email Delivery
5836 @c DOCUMENT THIS
5838 @node HTML Waterfall, WebStatus, Status Delivery, Status Delivery
5839 @section HTML Waterfall
5841 @cindex Waterfall
5842 @stindex buildbot.status.html.Waterfall
5845 @example
5846 from buildbot.status import html
5847 w = html.Waterfall(http_port=8080)
5848 c['status'].append(w)
5849 @end example
5851 The @code{buildbot.status.html.Waterfall} status target creates an
5852 HTML ``waterfall display'', which shows a time-based chart of events.
5853 This display provides detailed information about all steps of all
5854 recent builds, and provides hyperlinks to look at individual build
5855 logs and source changes. If the @code{http_port} argument is provided,
5856 it provides a strports specification for the port that the web server
5857 should listen on. This can be a simple port number, or a string like
5858 @code{tcp:8080:interface=127.0.0.1} (to limit connections to the
5859 loopback interface, and therefore to clients running on the same
5860 host)@footnote{It may even be possible to provide SSL access by using
5861 a specification like
5862 @code{"ssl:12345:privateKey=mykey.pen:certKey=cert.pem"}, but this is
5863 completely untested}.
5865 If instead (or in addition) you provide the @code{distrib_port}
5866 argument, a twisted.web distributed server will be started either on a
5867 TCP port (if @code{distrib_port} is like @code{"tcp:12345"}) or more
5868 likely on a UNIX socket (if @code{distrib_port} is like
5869 @code{"unix:/path/to/socket"}).
5871 The @code{distrib_port} option means that, on a host with a
5872 suitably-configured twisted-web server, you do not need to consume a
5873 separate TCP port for the buildmaster's status web page. When the web
5874 server is constructed with @code{mktap web --user}, URLs that point to
5875 @code{http://host/~username/} are dispatched to a sub-server that is
5876 listening on a UNIX socket at @code{~username/.twisted-web-pb}. On
5877 such a system, it is convenient to create a dedicated @code{buildbot}
5878 user, then set @code{distrib_port} to
5879 @code{"unix:"+os.path.expanduser("~/.twistd-web-pb")}. This
5880 configuration will make the HTML status page available at
5881 @code{http://host/~buildbot/} . Suitable URL remapping can make it
5882 appear at @code{http://host/buildbot/}, and the right virtual host
5883 setup can even place it at @code{http://buildbot.host/} .
5885 Other arguments:
5887 @table @code
5888 @item allowForce
5889 If set to True (the default), then the web page will provide a ``Force
5890 Build'' button that allows visitors to manually trigger builds. This
5891 is useful for developers to re-run builds that have failed because of
5892 intermittent problems in the test suite, or because of libraries that
5893 were not installed at the time of the previous build. You may not wish
5894 to allow strangers to cause a build to run: in that case, set this to
5895 False to remove these buttons.
5897 @item favicon
5898 If set to a string, this will be interpreted as a filename containing
5899 a ``favicon'': a small image that contains an icon for the web site.
5900 This is returned to browsers that request the @code{favicon.ico} file,
5901 and should point to a .png or .ico image file. The default value uses
5902 the buildbot/buildbot.png image (a small hex nut) contained in the
5903 buildbot distribution. You can set this to None to avoid using a
5904 favicon at all.
5906 @item robots_txt
5907 If set to a string, this will be interpreted as a filename containing
5908 the contents of ``robots.txt''. Many search engine spiders request
5909 this file before indexing the site. Setting it to a file which
5910 contains:
5911 @example
5912 User-agent: *
5913 Disallow: /
5914 @end example
5915 will prevent most search engines from trawling the (voluminous)
5916 generated status pages.
5918 @end table
5921 @node WebStatus, IRC Bot, HTML Waterfall, Status Delivery
5922 @section WebStatus
5924 @cindex WebStatus
5925 @stindex buildbot.status.web.baseweb.WebStatus
5927 The Waterfall object is actually a subset of the views available with
5928 the more generalized @code{WebStatus} target. When you use
5929 @code{WebStatus}, you can put HTML files, CSS stylesheets, robots.txt,
5930 and other resources in a @file{public_html/} directory for use by the
5931 built-in webserver.
5933 When the buildmaster is created, a subdirectory named
5934 @file{public_html/} is created in its base directory. @code{WebStatus}
5935 will serve files from this directory: for example, when a user points
5936 their browser at the buildbot's @code{WebStatus} URL, they will see
5937 the contents of the @file{public_html/index.html} file. Likewise,
5938 @file{public_html/robots.txt} and @file{public_html/buildbot.css} are
5939 useful things to create.
5941 Certain URL prefixes are handled specially by code within the
5942 buildbot. The pages available in these spaces provide various views into
5943 the buildbot status, each with a different focus. These pages can be
5944 configured further by adding query arguments, for example to restrict
5945 the page to only display certain Builders, or limit it to builds of a
5946 specific branch.
5948 In addition, if you are familiar with twisted.web @emph{Resource
5949 Trees}, you can write code to add additional pages at places inside
5950 this web space. Just use @code{webstatus.putChild} to place these
5951 resources.
5953 The following section describes the special URLs and the status views
5954 they provide.
5957 @menu
5958 * Buildbot Web Resources::      
5959 * XMLRPC server::               
5960 @end menu
5962 @node Buildbot Web Resources, XMLRPC server, WebStatus, WebStatus
5963 @subsection Buildbot Web Resources
5965 Certain URLs are ``magic'', and the pages they serve are created by
5966 various classes in the @file{buildbot.status.web} package instead of
5967 being read from disk. The most common way to access these pages is for
5968 the buildmaster admin to write or modify the @file{index.html} page to
5969 contain links to them. Of course other project web pages can contain
5970 links to these buildbot pages as well.
5972 Many pages can be modified by adding query arguments to the URL. For
5973 example, a page which shows the results of the most recent build
5974 normally does this for all builders at once. But by appending
5975 ``?builder=i386'' to the end of the URL, the page will show only the
5976 results for the ``i386'' builder. When used in this way, you can add
5977 multiple ``builder='' arguments to see multiple builders. Remembering
5978 that URL query arguments are separated @emph{from each other} with
5979 ampersands, a URL that ends in ``?builder=i386&builder=ppc'' would
5980 show builds for just those two Builders.
5982 The @code{branch=} query argument can be used on some pages. This
5983 filters the information displayed by that page down to only the builds
5984 or changes which involved the given branch. Multiple @code{branch=}
5985 arguments can be used to examine multiple branches at once (so
5986 appending @code{?branch=foo&branch=bar} to the URL will show builds
5987 involving either branch). No @code{branch=} arguments means to show
5988 builds and changes for all branches.
5990 Note that branch-handling still needs to be cleaned up: in particular
5991 there is currently no way to refer to the default (or ``trunk'')
5992 branch using @code{branch=} arguments. This will be improved in a
5993 future release.
5995 Some pages may include the Builder name or the build number in the
5996 main part of the URL itself. For example, a page that describes Build
5997 #7 of the ``i386'' builder would live at @file{/builders/i386/builds/7}.
5999 The table below lists all of the internal pages and the URLs that can
6000 be used to access them.
6002 NOTE: of the pages described here, only the @code{/waterfall} and
6003 @code{/builders} are implemented yet.
6005 @table @code
6007 @item /waterfall
6009 This provides a chronologically-oriented display of the activity of
6010 all builders. It is the same display used by the Waterfall display.
6012 By adding one or more ``builder='' query arguments, the Waterfall is
6013 restricted to only showing information about the given Builders. By
6014 adding one or more ``branch='' query arguments, the display is
6015 restricted to showing information about the given branches.
6017 A 'show_events=true' query argument causes the display to include
6018 non-Build events, like slaves attaching and detaching, as well as
6019 reconfiguration events. 'show_events=false' hides these events. The
6020 default is to show them.
6022 The Waterfall has references to resources in the @file{/builders}
6023 portion of the URL space to give access to individual builds.
6025 @item /builders/$BUILDERNAME/
6027 This describes the given Builder, and provides buttons to force a build.
6029 @item /builders/$BUILDERNAME/builds/$BUILDNUM/
6031 This describes a specific Build.
6033 @item /builders/$BUILDERNAME/builds/$BUILDNUM/steps/$STEPNAME
6035 This describes a specific BuildStep.
6037 @item /builders/$BUILDERNAME/builds/$BUILDNUM/steps/$STEPNAME/logs/$LOGNAME
6039 This provides an HTML representation of a specific logfile.
6041 @item /builders/$BUILDERNAME/builds/$BUILDNUM/steps/$STEPNAME/logs/$LOGNAME/text
6043 This returns the logfile as plain text, without any HTML coloring
6044 markup. It also removes the ``headers'', which are the lines that
6045 describe what command was run and what the environment variable
6046 settings were like. This maybe be useful for saving to disk and
6047 feeding to tools like 'grep'.
6050 @item /one_line_per_build
6052 This page shows one line of text for each build, merging information
6053 from all Builders@footnote{Apparently this is the same way
6054 http://buildd.debian.org displays build status}. Each line specifies
6055 the name of the Builder, the number of the Build, what revision it
6056 used, and a summary of the results. Successful builds are in green,
6057 while failing builds are in red. The date and time of the build are
6058 added to the right-hand edge of the line. The lines are ordered by
6059 build finish timestamp.
6061 One of more ``builder='' arguments can be used to restrict the list.
6062 In addition, a ``numbuilds='' argument will control how many lines are
6063 displayed (20 by default).
6065 @item /slave_status_timeline
6067 This provides a chronological display of configuration and operational
6068 events: master startup/shutdown, slave connect/disconnect, and
6069 config-file changes. When a config-file reload is abandoned because of
6070 an error in the config file, the error is displayed on this page.
6072 This page does not show any builds.
6075 @item /last_build
6077 This shows one box per Builder, showing the results of the most recent
6078 complete build. It does not show the individual steps, or the current
6079 status.
6081 There are some options to limit the boxes displayed:
6083 @itemize @bullet
6084 @item
6085 branches: only show builds of specific branches
6086 @item only show specific builders
6087 @end itemize
6090 @item /last_build/$BUILDERNAME/status.png
6092 This returns a PNG image that describes the results of the most recent
6093 build, which can be referenced in an IMG tag by other pages, perhaps
6094 from a completely different site. Use it as you would a webcounter.
6096 @end table
6098 There are also a set of web-status resources that are intended for use
6099 by other programs, rather than humans.
6101 @table @code
6103 @item /xmlrpc
6105 This runs an XML-RPC server which can be used to query status
6106 information about various builds. See @ref{XMLRPC server} for more
6107 details.
6109 @end table
6111 @node XMLRPC server,  , Buildbot Web Resources, WebStatus
6112 @subsection XMLRPC server
6114 When using WebStatus, the buildbot runs an XML-RPC server at
6115 @file{/xmlrpc} that can be used by other programs to query build
6116 status. The following table lists the methods that can be invoked
6117 using this interface.
6119 @table @code
6121 @end table
6124 @node IRC Bot, PBListener, WebStatus, Status Delivery
6125 @section IRC Bot
6127 @cindex IRC
6128 @stindex buildbot.status.words.IRC
6131 The @code{buildbot.status.words.IRC} status target creates an IRC bot
6132 which will attach to certain channels and be available for status
6133 queries. It can also be asked to announce builds as they occur, or be
6134 told to shut up.
6136 @example
6137 from twisted.status import words
6138 irc = words.IRC("irc.example.org", "botnickname", 
6139                 channels=["channel1", "channel2"],
6140                 password="mysecretpassword")
6141 c['status'].append(irc)
6142 @end example
6144 Take a look at the docstring for @code{words.IRC} for more details on
6145 configuring this service. The @code{password} argument, if provided,
6146 will be sent to Nickserv to claim the nickname: some IRC servers will
6147 not allow clients to send private messages until they have logged in
6148 with a password.
6150 To use the service, you address messages at the buildbot, either
6151 normally (@code{botnickname: status}) or with private messages
6152 (@code{/msg botnickname status}). The buildbot will respond in kind.
6154 Some of the commands currently available:
6156 @table @code
6158 @item list builders
6159 Emit a list of all configured builders
6160 @item status BUILDER
6161 Announce the status of a specific Builder: what it is doing right now.
6162 @item status all
6163 Announce the status of all Builders
6164 @item watch BUILDER
6165 If the given Builder is currently running, wait until the Build is
6166 finished and then announce the results.
6167 @item last BUILDER
6168 Return the results of the last build to run on the given Builder.
6170 @item help COMMAND
6171 Describe a command. Use @code{help commands} to get a list of known
6172 commands.
6173 @item source
6174 Announce the URL of the Buildbot's home page.
6175 @item version
6176 Announce the version of this Buildbot.
6177 @end table
6179 If the @code{allowForce=True} option was used, some addtional commands
6180 will be available:
6182 @table @code
6183 @item force build BUILDER REASON
6184 Tell the given Builder to start a build of the latest code. The user
6185 requesting the build and REASON are recorded in the Build status. The
6186 buildbot will announce the build's status when it finishes.
6188 @item stop build BUILDER REASON
6189 Terminate any running build in the given Builder. REASON will be added
6190 to the build status to explain why it was stopped. You might use this
6191 if you committed a bug, corrected it right away, and don't want to
6192 wait for the first build (which is destined to fail) to complete
6193 before starting the second (hopefully fixed) build.
6194 @end table
6196 @node PBListener, Writing New Status Plugins, IRC Bot, Status Delivery
6197 @section PBListener
6199 @cindex PBListener
6200 @stindex buildbot.status.client.PBListener
6203 @example
6204 import buildbot.status.client
6205 pbl = buildbot.status.client.PBListener(port=int, user=str,
6206                                         passwd=str)
6207 c['status'].append(pbl)
6208 @end example
6210 This sets up a PB listener on the given TCP port, to which a PB-based
6211 status client can connect and retrieve status information.
6212 @code{buildbot statusgui} (@pxref{statusgui}) is an example of such a
6213 status client. The @code{port} argument can also be a strports
6214 specification string.
6216 @node Writing New Status Plugins,  , PBListener, Status Delivery
6217 @section Writing New Status Plugins
6219 TODO: this needs a lot more examples
6221 Each status plugin is an object which provides the
6222 @code{twisted.application.service.IService} interface, which creates a
6223 tree of Services with the buildmaster at the top [not strictly true].
6224 The status plugins are all children of an object which implements
6225 @code{buildbot.interfaces.IStatus}, the main status object. From this
6226 object, the plugin can retrieve anything it wants about current and
6227 past builds. It can also subscribe to hear about new and upcoming
6228 builds.
6230 Status plugins which only react to human queries (like the Waterfall
6231 display) never need to subscribe to anything: they are idle until
6232 someone asks a question, then wake up and extract the information they
6233 need to answer it, then they go back to sleep. Plugins which need to
6234 act spontaneously when builds complete (like the Mail plugin) need to
6235 subscribe to hear about new builds.
6237 If the status plugin needs to run network services (like the HTTP
6238 server used by the Waterfall plugin), they can be attached as Service
6239 children of the plugin itself, using the @code{IServiceCollection}
6240 interface.
6244 @node Command-line tool, Resources, Status Delivery, Top
6245 @chapter Command-line tool
6247 The @command{buildbot} command-line tool can be used to start or stop a
6248 buildmaster or buildbot, and to interact with a running buildmaster.
6249 Some of its subcommands are intended for buildmaster admins, while
6250 some are for developers who are editing the code that the buildbot is
6251 monitoring.
6253 @menu
6254 * Administrator Tools::         
6255 * Developer Tools::             
6256 * Other Tools::                 
6257 * .buildbot config directory::  
6258 @end menu
6260 @node Administrator Tools, Developer Tools, Command-line tool, Command-line tool
6261 @section Administrator Tools
6263 The following @command{buildbot} sub-commands are intended for
6264 buildmaster administrators:
6266 @heading create-master
6268 This creates a new directory and populates it with files that allow it
6269 to be used as a buildmaster's base directory.
6271 @example
6272 buildbot create-master BASEDIR
6273 @end example
6275 @heading create-slave
6277 This creates a new directory and populates it with files that let it
6278 be used as a buildslave's base directory. You must provide several
6279 arguments, which are used to create the initial @file{buildbot.tac}
6280 file.
6282 @example
6283 buildbot create-slave @var{BASEDIR} @var{MASTERHOST}:@var{PORT} @var{SLAVENAME} @var{PASSWORD}
6284 @end example
6286 @heading start
6288 This starts a buildmaster or buildslave which was already created in
6289 the given base directory. The daemon is launched in the background,
6290 with events logged to a file named @file{twistd.log}.
6292 @example
6293 buildbot start BASEDIR
6294 @end example
6296 @heading stop
6298 This terminates the daemon (either buildmaster or buildslave) running
6299 in the given directory.
6301 @example
6302 buildbot stop BASEDIR
6303 @end example
6305 @heading sighup
6307 This sends a SIGHUP to the buildmaster running in the given directory,
6308 which causes it to re-read its @file{master.cfg} file.
6310 @example
6311 buildbot sighup BASEDIR
6312 @end example
6314 @node Developer Tools, Other Tools, Administrator Tools, Command-line tool
6315 @section Developer Tools
6317 These tools are provided for use by the developers who are working on
6318 the code that the buildbot is monitoring.
6320 @menu
6321 * statuslog::                   
6322 * statusgui::                   
6323 * try::                         
6324 @end menu
6326 @node statuslog, statusgui, Developer Tools, Developer Tools
6327 @subsection statuslog
6329 @example
6330 buildbot statuslog --master @var{MASTERHOST}:@var{PORT}
6331 @end example
6333 This command starts a simple text-based status client, one which just
6334 prints out a new line each time an event occurs on the buildmaster.
6336 The @option{--master} option provides the location of the
6337 @code{buildbot.status.client.PBListener} status port, used to deliver
6338 build information to realtime status clients. The option is always in
6339 the form of a string, with hostname and port number separated by a
6340 colon (@code{HOSTNAME:PORTNUM}). Note that this port is @emph{not} the
6341 same as the slaveport (although a future version may allow the same
6342 port number to be used for both purposes). If you get an error message
6343 to the effect of ``Failure: twisted.cred.error.UnauthorizedLogin:'',
6344 this may indicate that you are connecting to the slaveport rather than
6345 a @code{PBListener} port.
6347 The @option{--master} option can also be provided by the
6348 @code{masterstatus} name in @file{.buildbot/options} (@pxref{.buildbot
6349 config directory}).
6351 @node statusgui, try, statuslog, Developer Tools
6352 @subsection statusgui
6354 @cindex statusgui
6356 If you have set up a PBListener (@pxref{PBListener}), you will be able
6357 to monitor your Buildbot using a simple Gtk+ application invoked with
6358 the @code{buildbot statusgui} command:
6360 @example
6361 buildbot statusgui --master @var{MASTERHOST}:@var{PORT}
6362 @end example
6364 This command starts a simple Gtk+-based status client, which contains
6365 a few boxes for each Builder that change color as events occur. It
6366 uses the same @option{--master} argument as the @command{buildbot
6367 statuslog} command (@pxref{statuslog}).
6369 @node try,  , statusgui, Developer Tools
6370 @subsection try
6372 This lets a developer to ask the question ``What would happen if I
6373 committed this patch right now?''. It runs the unit test suite (across
6374 multiple build platforms) on the developer's current code, allowing
6375 them to make sure they will not break the tree when they finally
6376 commit their changes.
6378 The @command{buildbot try} command is meant to be run from within a
6379 developer's local tree, and starts by figuring out the base revision
6380 of that tree (what revision was current the last time the tree was
6381 updated), and a patch that can be applied to that revision of the tree
6382 to make it match the developer's copy. This (revision, patch) pair is
6383 then sent to the buildmaster, which runs a build with that
6384 SourceStamp. If you want, the tool will emit status messages as the
6385 builds run, and will not terminate until the first failure has been
6386 detected (or the last success).
6388 There is an alternate form which accepts a pre-made patch file
6389 (typically the output of a command like 'svn diff'). This ``--diff''
6390 form does not require a local tree to run from. See @xref{try --diff}.
6392 For this command to work, several pieces must be in place:
6395 @heading TryScheduler
6397 @slindex buildbot.scheduler.Try_Jobdir
6398 @slindex buildbot.scheduler.Try_Userpass
6400 The buildmaster must have a @code{scheduler.Try} instance in
6401 the config file's @code{c['schedulers']} list. This lets the
6402 administrator control who may initiate these ``trial'' builds, which
6403 branches are eligible for trial builds, and which Builders should be
6404 used for them.
6406 The @code{TryScheduler} has various means to accept build requests:
6407 all of them enforce more security than the usual buildmaster ports do.
6408 Any source code being built can be used to compromise the buildslave
6409 accounts, but in general that code must be checked out from the VC
6410 repository first, so only people with commit privileges can get
6411 control of the buildslaves. The usual force-build control channels can
6412 waste buildslave time but do not allow arbitrary commands to be
6413 executed by people who don't have those commit privileges. However,
6414 the source code patch that is provided with the trial build does not
6415 have to go through the VC system first, so it is important to make
6416 sure these builds cannot be abused by a non-committer to acquire as
6417 much control over the buildslaves as a committer has. Ideally, only
6418 developers who have commit access to the VC repository would be able
6419 to start trial builds, but unfortunately the buildmaster does not, in
6420 general, have access to VC system's user list.
6422 As a result, the @code{TryScheduler} requires a bit more
6423 configuration. There are currently two ways to set this up:
6425 @table @strong
6426 @item jobdir (ssh)
6428 This approach creates a command queue directory, called the
6429 ``jobdir'', in the buildmaster's working directory. The buildmaster
6430 admin sets the ownership and permissions of this directory to only
6431 grant write access to the desired set of developers, all of whom must
6432 have accounts on the machine. The @code{buildbot try} command creates
6433 a special file containing the source stamp information and drops it in
6434 the jobdir, just like a standard maildir. When the buildmaster notices
6435 the new file, it unpacks the information inside and starts the builds.
6437 The config file entries used by 'buildbot try' either specify a local
6438 queuedir (for which write and mv are used) or a remote one (using scp
6439 and ssh).
6441 The advantage of this scheme is that it is quite secure, the
6442 disadvantage is that it requires fiddling outside the buildmaster
6443 config (to set the permissions on the jobdir correctly). If the
6444 buildmaster machine happens to also house the VC repository, then it
6445 can be fairly easy to keep the VC userlist in sync with the
6446 trial-build userlist. If they are on different machines, this will be
6447 much more of a hassle. It may also involve granting developer accounts
6448 on a machine that would not otherwise require them.
6450 To implement this, the buildslave invokes 'ssh -l username host
6451 buildbot tryserver ARGS', passing the patch contents over stdin. The
6452 arguments must include the inlet directory and the revision
6453 information.
6455 @item user+password (PB)
6457 In this approach, each developer gets a username/password pair, which
6458 are all listed in the buildmaster's configuration file. When the
6459 developer runs @code{buildbot try}, their machine connects to the
6460 buildmaster via PB and authenticates themselves using that username
6461 and password, then sends a PB command to start the trial build.
6463 The advantage of this scheme is that the entire configuration is
6464 performed inside the buildmaster's config file. The disadvantages are
6465 that it is less secure (while the ``cred'' authentication system does
6466 not expose the password in plaintext over the wire, it does not offer
6467 most of the other security properties that SSH does). In addition, the
6468 buildmaster admin is responsible for maintaining the username/password
6469 list, adding and deleting entries as developers come and go.
6471 @end table
6474 For example, to set up the ``jobdir'' style of trial build, using a
6475 command queue directory of @file{MASTERDIR/jobdir} (and assuming that
6476 all your project developers were members of the @code{developers} unix
6477 group), you would first create that directory (with @command{mkdir
6478 MASTERDIR/jobdir MASTERDIR/jobdir/new MASTERDIR/jobdir/cur
6479 MASTERDIR/jobdir/tmp; chgrp developers MASTERDIR/jobdir
6480 MASTERDIR/jobdir/*; chmod g+rwx,o-rwx MASTERDIR/jobdir
6481 MASTERDIR/jobdir/*}), and then use the following scheduler in the
6482 buildmaster's config file:
6484 @example
6485 from buildbot.scheduler import Try_Jobdir
6486 s = Try_Jobdir("try1", ["full-linux", "full-netbsd", "full-OSX"],
6487                jobdir="jobdir")
6488 c['schedulers'] = [s]
6489 @end example
6491 Note that you must create the jobdir before telling the buildmaster to
6492 use this configuration, otherwise you will get an error. Also remember
6493 that the buildmaster must be able to read and write to the jobdir as
6494 well. Be sure to watch the @file{twistd.log} file (@pxref{Logfiles})
6495 as you start using the jobdir, to make sure the buildmaster is happy
6496 with it.
6498 To use the username/password form of authentication, create a
6499 @code{Try_Userpass} instance instead. It takes the same
6500 @code{builderNames} argument as the @code{Try_Jobdir} form, but
6501 accepts an addtional @code{port} argument (to specify the TCP port to
6502 listen on) and a @code{userpass} list of username/password pairs to
6503 accept. Remember to use good passwords for this: the security of the
6504 buildslave accounts depends upon it:
6506 @example
6507 from buildbot.scheduler import Try_Userpass
6508 s = Try_Userpass("try2", ["full-linux", "full-netbsd", "full-OSX"],
6509                  port=8031, userpass=[("alice","pw1"), ("bob", "pw2")] )
6510 c['schedulers'] = [s]
6511 @end example
6513 Like most places in the buildbot, the @code{port} argument takes a
6514 strports specification. See @code{twisted.application.strports} for
6515 details.
6518 @heading locating the master
6520 The @command{try} command needs to be told how to connect to the
6521 @code{TryScheduler}, and must know which of the authentication
6522 approaches described above is in use by the buildmaster. You specify
6523 the approach by using @option{--connect=ssh} or @option{--connect=pb}
6524 (or @code{try_connect = 'ssh'} or @code{try_connect = 'pb'} in
6525 @file{.buildbot/options}).
6527 For the PB approach, the command must be given a @option{--master}
6528 argument (in the form HOST:PORT) that points to TCP port that you
6529 picked in the @code{Try_Userpass} scheduler. It also takes a
6530 @option{--username} and @option{--passwd} pair of arguments that match
6531 one of the entries in the buildmaster's @code{userpass} list. These
6532 arguments can also be provided as @code{try_master},
6533 @code{try_username}, and @code{try_password} entries in the
6534 @file{.buildbot/options} file.
6536 For the SSH approach, the command must be given @option{--tryhost},
6537 @option{--username}, and optionally @option{--password} (TODO:
6538 really?) to get to the buildmaster host. It must also be given
6539 @option{--trydir}, which points to the inlet directory configured
6540 above. The trydir can be relative to the user's home directory, but
6541 most of the time you will use an explicit path like
6542 @file{~buildbot/project/trydir}. These arguments can be provided in
6543 @file{.buildbot/options} as @code{try_host}, @code{try_username},
6544 @code{try_password}, and @code{try_dir}.
6546 In addition, the SSH approach needs to connect to a PBListener status
6547 port, so it can retrieve and report the results of the build (the PB
6548 approach uses the existing connection to retrieve status information,
6549 so this step is not necessary). This requires a @option{--master}
6550 argument, or a @code{masterstatus} entry in @file{.buildbot/options},
6551 in the form of a HOSTNAME:PORT string.
6554 @heading choosing the Builders
6556 A trial build is performed on multiple Builders at the same time, and
6557 the developer gets to choose which Builders are used (limited to a set
6558 selected by the buildmaster admin with the TryScheduler's
6559 @code{builderNames=} argument). The set you choose will depend upon
6560 what your goals are: if you are concerned about cross-platform
6561 compatibility, you should use multiple Builders, one from each
6562 platform of interest. You might use just one builder if that platform
6563 has libraries or other facilities that allow better test coverage than
6564 what you can accomplish on your own machine, or faster test runs.
6566 The set of Builders to use can be specified with multiple
6567 @option{--builder} arguments on the command line. It can also be
6568 specified with a single @code{try_builders} option in
6569 @file{.buildbot/options} that uses a list of strings to specify all
6570 the Builder names:
6572 @example
6573 try_builders = ["full-OSX", "full-win32", "full-linux"]
6574 @end example
6576 @heading specifying the VC system
6578 The @command{try} command also needs to know how to take the
6579 developer's current tree and extract the (revision, patch)
6580 source-stamp pair. Each VC system uses a different process, so you
6581 start by telling the @command{try} command which VC system you are
6582 using, with an argument like @option{--vc=cvs} or @option{--vc=tla}.
6583 This can also be provided as @code{try_vc} in
6584 @file{.buildbot/options}.
6586 The following names are recognized: @code{cvs} @code{svn} @code{baz}
6587 @code{tla} @code{hg} @code{darcs}
6590 @heading finding the top of the tree
6592 Some VC systems (notably CVS and SVN) track each directory
6593 more-or-less independently, which means the @command{try} command
6594 needs to move up to the top of the project tree before it will be able
6595 to construct a proper full-tree patch. To accomplish this, the
6596 @command{try} command will crawl up through the parent directories
6597 until it finds a marker file. The default name for this marker file is
6598 @file{.buildbot-top}, so when you are using CVS or SVN you should
6599 @code{touch .buildbot-top} from the top of your tree before running
6600 @command{buildbot try}. Alternatively, you can use a filename like
6601 @file{ChangeLog} or @file{README}, since many projects put one of
6602 these files in their top-most directory (and nowhere else). To set
6603 this filename, use @option{--try-topfile=ChangeLog}, or set it in the
6604 options file with @code{try_topfile = 'ChangeLog'}.
6606 You can also manually set the top of the tree with
6607 @option{--try-topdir=~/trees/mytree}, or @code{try_topdir =
6608 '~/trees/mytree'}. If you use @code{try_topdir}, in a
6609 @file{.buildbot/options} file, you will need a separate options file
6610 for each tree you use, so it may be more convenient to use the
6611 @code{try_topfile} approach instead.
6613 Other VC systems which work on full projects instead of individual
6614 directories (tla, baz, darcs, monotone, mercurial) do not require
6615 @command{try} to know the top directory, so the @option{--try-topfile}
6616 and @option{--try-topdir} arguments will be ignored.
6617 @c is this true? I think I currently require topdirs all the time.
6619 If the @command{try} command cannot find the top directory, it will
6620 abort with an error message.
6622 @heading determining the branch name
6624 Some VC systems record the branch information in a way that ``try''
6625 can locate it, in particular Arch (both @command{tla} and
6626 @command{baz}). For the others, if you are using something other than
6627 the default branch, you will have to tell the buildbot which branch
6628 your tree is using. You can do this with either the @option{--branch}
6629 argument, or a @option{try_branch} entry in the
6630 @file{.buildbot/options} file.
6632 @heading determining the revision and patch
6634 Each VC system has a separate approach for determining the tree's base
6635 revision and computing a patch.
6637 @table @code
6639 @item CVS
6641 @command{try} pretends that the tree is up to date. It converts the
6642 current time into a @code{-D} time specification, uses it as the base
6643 revision, and computes the diff between the upstream tree as of that
6644 point in time versus the current contents. This works, more or less,
6645 but requires that the local clock be in reasonably good sync with the
6646 repository.
6648 @item SVN
6649 @command{try} does a @code{svn status -u} to find the latest
6650 repository revision number (emitted on the last line in the ``Status
6651 against revision: NN'' message). It then performs an @code{svn diff
6652 -rNN} to find out how your tree differs from the repository version,
6653 and sends the resulting patch to the buildmaster. If your tree is not
6654 up to date, this will result in the ``try'' tree being created with
6655 the latest revision, then @emph{backwards} patches applied to bring it
6656 ``back'' to the version you actually checked out (plus your actual
6657 code changes), but this will still result in the correct tree being
6658 used for the build.
6660 @item baz
6661 @command{try} does a @code{baz tree-id} to determine the
6662 fully-qualified version and patch identifier for the tree
6663 (ARCHIVE/VERSION--patch-NN), and uses the VERSION--patch-NN component
6664 as the base revision. It then does a @code{baz diff} to obtain the
6665 patch.
6667 @item tla
6668 @command{try} does a @code{tla tree-version} to get the
6669 fully-qualified version identifier (ARCHIVE/VERSION), then takes the
6670 first line of @code{tla logs --reverse} to figure out the base
6671 revision. Then it does @code{tla changes --diffs} to obtain the patch.
6673 @item Darcs
6674 @code{darcs changes --context} emits a text file that contains a list
6675 of all patches back to and including the last tag was made. This text
6676 file (plus the location of a repository that contains all these
6677 patches) is sufficient to re-create the tree. Therefore the contents
6678 of this ``context'' file @emph{are} the revision stamp for a
6679 Darcs-controlled source tree.
6681 So @command{try} does a @code{darcs changes --context} to determine
6682 what your tree's base revision is, and then does a @code{darcs diff
6683 -u} to compute the patch relative to that revision.
6685 @item Mercurial
6686 @code{hg identify} emits a short revision ID (basically a truncated
6687 SHA1 hash of the current revision's contents), which is used as the
6688 base revision. @code{hg diff} then provides the patch relative to that
6689 revision. For @command{try} to work, your working directory must only
6690 have patches that are available from the same remotely-available
6691 repository that the build process' @code{step.Mercurial} will use.
6693 @c TODO: monotone, git
6694 @end table
6696 @heading waiting for results
6698 If you provide the @option{--wait} option (or @code{try_wait = True}
6699 in @file{.buildbot/options}), the @command{buildbot try} command will
6700 wait until your changes have either been proven good or bad before
6701 exiting. Unless you use the @option{--quiet} option (or
6702 @code{try_quiet=True}), it will emit a progress message every 60
6703 seconds until the builds have completed.
6705 @menu
6706 * try --diff::                  
6707 @end menu
6709 @node try --diff,  , try, try
6710 @subsubsection try --diff
6712 Sometimes you might have a patch from someone else that you want to
6713 submit to the buildbot. For example, a user may have created a patch
6714 to fix some specific bug and sent it to you by email. You've inspected
6715 the patch and suspect that it might do the job (and have at least
6716 confirmed that it doesn't do anything evil). Now you want to test it
6717 out.
6719 One approach would be to check out a new local tree, apply the patch,
6720 run your local tests, then use ``buildbot try'' to run the tests on
6721 other platforms. An alternate approach is to use the @command{buildbot
6722 try --diff} form to have the buildbot test the patch without using a
6723 local tree.
6725 This form takes a @option{--diff} argument which points to a file that
6726 contains the patch you want to apply. By default this patch will be
6727 applied to the TRUNK revision, but if you give the optional
6728 @option{--baserev} argument, a tree of the given revision will be used
6729 as a starting point instead of TRUNK.
6731 You can also use @command{buildbot try --diff=-} to read the patch
6732 from stdin.
6734 Each patch has a ``patchlevel'' associated with it. This indicates the
6735 number of slashes (and preceding pathnames) that should be stripped
6736 before applying the diff. This exactly corresponds to the @option{-p}
6737 or @option{--strip} argument to the @command{patch} utility. By
6738 default @command{buildbot try --diff} uses a patchlevel of 0, but you
6739 can override this with the @option{-p} argument.
6741 When you use @option{--diff}, you do not need to use any of the other
6742 options that relate to a local tree, specifically @option{--vc},
6743 @option{--try-topfile}, or @option{--try-topdir}. These options will
6744 be ignored. Of course you must still specify how to get to the
6745 buildmaster (with @option{--connect}, @option{--tryhost}, etc).
6748 @node Other Tools, .buildbot config directory, Developer Tools, Command-line tool
6749 @section Other Tools
6751 These tools are generally used by buildmaster administrators.
6753 @menu
6754 * sendchange::                  
6755 * debugclient::                 
6756 @end menu
6758 @node sendchange, debugclient, Other Tools, Other Tools
6759 @subsection sendchange
6761 This command is used to tell the buildmaster about source changes. It
6762 is intended to be used from within a commit script, installed on the
6763 VC server. It requires that you have a PBChangeSource
6764 (@pxref{PBChangeSource}) running in the buildmaster (by being set in
6765 @code{c['change_source']}).
6768 @example
6769 buildbot sendchange --master @var{MASTERHOST}:@var{PORT} --username @var{USER} @var{FILENAMES..}
6770 @end example
6772 There are other (optional) arguments which can influence the
6773 @code{Change} that gets submitted:
6775 @table @code
6776 @item --branch
6777 This provides the (string) branch specifier. If omitted, it defaults
6778 to None, indicating the ``default branch''. All files included in this
6779 Change must be on the same branch.
6781 @item --revision_number
6782 This provides a (numeric) revision number for the change, used for VC systems
6783 that use numeric transaction numbers (like Subversion).
6785 @item --revision
6786 This provides a (string) revision specifier, for VC systems that use
6787 strings (Arch would use something like patch-42 etc).
6789 @item --revision_file
6790 This provides a filename which will be opened and the contents used as
6791 the revision specifier. This is specifically for Darcs, which uses the
6792 output of @command{darcs changes --context} as a revision specifier.
6793 This context file can be a couple of kilobytes long, spanning a couple
6794 lines per patch, and would be a hassle to pass as a command-line
6795 argument.
6797 @item --comments
6798 This provides the change comments as a single argument. You may want
6799 to use @option{--logfile} instead.
6801 @item --logfile
6802 This instructs the tool to read the change comments from the given
6803 file. If you use @code{-} as the filename, the tool will read the
6804 change comments from stdin.
6805 @end table
6808 @node debugclient,  , sendchange, Other Tools
6809 @subsection debugclient
6811 @example
6812 buildbot debugclient --master @var{MASTERHOST}:@var{PORT} --passwd @var{DEBUGPW}
6813 @end example
6815 This launches a small Gtk+/Glade-based debug tool, connecting to the
6816 buildmaster's ``debug port''. This debug port shares the same port
6817 number as the slaveport (@pxref{Setting the slaveport}), but the
6818 @code{debugPort} is only enabled if you set a debug password in the
6819 buildmaster's config file (@pxref{Debug options}). The
6820 @option{--passwd} option must match the @code{c['debugPassword']}
6821 value.
6823 @option{--master} can also be provided in @file{.debug/options} by the
6824 @code{master} key. @option{--passwd} can be provided by the
6825 @code{debugPassword} key.
6827 The @code{Connect} button must be pressed before any of the other
6828 buttons will be active. This establishes the connection to the
6829 buildmaster. The other sections of the tool are as follows:
6831 @table @code
6832 @item Reload .cfg
6833 Forces the buildmaster to reload its @file{master.cfg} file. This is
6834 equivalent to sending a SIGHUP to the buildmaster, but can be done
6835 remotely through the debug port. Note that it is a good idea to be
6836 watching the buildmaster's @file{twistd.log} as you reload the config
6837 file, as any errors which are detected in the config file will be
6838 announced there.
6840 @item Rebuild .py
6841 (not yet implemented). The idea here is to use Twisted's ``rebuild''
6842 facilities to replace the buildmaster's running code with a new
6843 version. Even if this worked, it would only be used by buildbot
6844 developers.
6846 @item poke IRC
6847 This locates a @code{words.IRC} status target and causes it to emit a
6848 message on all the channels to which it is currently connected. This
6849 was used to debug a problem in which the buildmaster lost the
6850 connection to the IRC server and did not attempt to reconnect.
6852 @item Commit
6853 This allows you to inject a Change, just as if a real one had been
6854 delivered by whatever VC hook you are using. You can set the name of
6855 the committed file and the name of the user who is doing the commit.
6856 Optionally, you can also set a revision for the change. If the
6857 revision you provide looks like a number, it will be sent as an
6858 integer, otherwise it will be sent as a string.
6860 @item Force Build
6861 This lets you force a Builder (selected by name) to start a build of
6862 the current source tree.
6864 @item Currently
6865 (obsolete). This was used to manually set the status of the given
6866 Builder, but the status-assignment code was changed in an incompatible
6867 way and these buttons are no longer meaningful.
6869 @end table
6872 @node .buildbot config directory,  , Other Tools, Command-line tool
6873 @section .buildbot config directory
6875 Many of the @command{buildbot} tools must be told how to contact the
6876 buildmaster that they interact with. This specification can be
6877 provided as a command-line argument, but most of the time it will be
6878 easier to set them in an ``options'' file. The @command{buildbot}
6879 command will look for a special directory named @file{.buildbot},
6880 starting from the current directory (where the command was run) and
6881 crawling upwards, eventually looking in the user's home directory. It
6882 will look for a file named @file{options} in this directory, and will
6883 evaluate it as a python script, looking for certain names to be set.
6884 You can just put simple @code{name = 'value'} pairs in this file to
6885 set the options.
6887 For a description of the names used in this file, please see the
6888 documentation for the individual @command{buildbot} sub-commands. The
6889 following is a brief sample of what this file's contents could be.
6891 @example
6892 # for status-reading tools
6893 masterstatus = 'buildbot.example.org:12345'
6894 # for 'sendchange' or the debug port
6895 master = 'buildbot.example.org:18990'
6896 debugPassword = 'eiv7Po'
6897 @end example
6899 @table @code
6900 @item masterstatus
6901 Location of the @code{client.PBListener} status port, used by
6902 @command{statuslog} and @command{statusgui}.
6904 @item master
6905 Location of the @code{debugPort} (for @command{debugclient}). Also the
6906 location of the @code{pb.PBChangeSource} (for @command{sendchange}).
6907 Usually shares the slaveport, but a future version may make it
6908 possible to have these listen on a separate port number.
6910 @item debugPassword
6911 Must match the value of @code{c['debugPassword']}, used to protect the
6912 debug port, for the @command{debugclient} command.
6914 @item username
6915 Provides a default username for the @command{sendchange} command.
6917 @end table
6920 The following options are used by the @code{buildbot try} command
6921 (@pxref{try}):
6923 @table @code
6924 @item try_connect
6925 This specifies how the ``try'' command should deliver its request to
6926 the buildmaster. The currently accepted values are ``ssh'' and ``pb''.
6927 @item try_builders
6928 Which builders should be used for the ``try'' build.
6929 @item try_vc
6930 This specifies the version control system being used.
6931 @item try_branch
6932 This indicates that the current tree is on a non-trunk branch.
6933 @item try_topdir
6934 @item try_topfile
6935 Use @code{try_topdir} to explicitly indicate the top of your working
6936 tree, or @code{try_topfile} to name a file that will only be found in
6937 that top-most directory.
6939 @item try_host
6940 @item try_username
6941 @item try_dir
6942 When try_connect is ``ssh'', the command will pay attention to
6943 @code{try_host}, @code{try_username}, and @code{try_dir}.
6945 @item try_username
6946 @item try_password
6947 @item try_master
6948 Instead, when @code{try_connect} is ``pb'', the command will pay
6949 attention to @code{try_username}, @code{try_password}, and
6950 @code{try_master}.
6952 @item try_wait
6953 @item masterstatus
6954 @code{try_wait} and @code{masterstatus} are used to ask the ``try''
6955 command to wait for the requested build to complete.
6957 @end table
6961 @node Resources, Developer's Appendix, Command-line tool, Top
6962 @chapter Resources
6964 The Buildbot's home page is at @uref{http://buildbot.sourceforge.net/}
6966 For configuration questions and general discussion, please use the
6967 @code{buildbot-devel} mailing list. The subscription instructions and
6968 archives are available at
6969 @uref{http://lists.sourceforge.net/lists/listinfo/buildbot-devel}
6971 @node Developer's Appendix, Index of Useful Classes, Resources, Top
6972 @unnumbered Developer's Appendix
6974 This appendix contains random notes about the implementation of the
6975 Buildbot, and is likely to only be of use to people intending to
6976 extend the Buildbot's internals.
6978 The buildmaster consists of a tree of Service objects, which is shaped
6979 as follows:
6981 @example
6982 BuildMaster
6983  ChangeMaster  (in .change_svc)
6984   [IChangeSource instances]
6985  [IScheduler instances]  (in .schedulers)
6986  BotMaster  (in .botmaster)
6987  [IStatusTarget instances]  (in .statusTargets)
6988 @end example
6990 The BotMaster has a collection of Builder objects as values of its
6991 @code{.builders} dictionary.
6994 @node Index of Useful Classes, Index of master.cfg keys, Developer's Appendix, Top
6995 @unnumbered Index of Useful Classes
6997 This is a list of all user-visible classes. There are the ones that
6998 are useful in @file{master.cfg}, the buildmaster's configuration file.
6999 Classes that are not listed here are generally internal things that
7000 admins are unlikely to have much use for.
7003 @heading Change Sources
7004 @printindex cs
7006 @heading Schedulers and Locks
7007 @printindex sl
7009 @heading Build Factories
7010 @printindex bf
7012 @heading Build Steps
7013 @printindex bs
7015 @c undocumented steps
7016 @bsindex buildbot.steps.source.Git
7017 @bsindex buildbot.steps.maxq.MaxQ
7020 @heading Status Targets
7021 @printindex st
7023 @c TODO: undocumented targets
7024 @stindex buildbot.status.mail.MailNotifier
7026 @node Index of master.cfg keys, Index, Index of Useful Classes, Top
7027 @unnumbered Index of master.cfg keys
7029 This is a list of all of the significant keys in master.cfg . Recall
7030 that master.cfg is effectively a small python program with exactly one
7031 responsibility: create a dictionary named @code{BuildmasterConfig}.
7032 The keys of this dictionary are listed here. The beginning of the
7033 master.cfg file typically starts with something like:
7035 @example
7036 BuildmasterConfig = c = @{@}
7037 @end example
7039 Therefore a config key of @code{change_source} will usually appear in
7040 master.cfg as @code{c['change_source']}.
7042 @printindex bc
7045 @node Index,  , Index of master.cfg keys, Top
7046 @unnumbered Index
7048 @printindex cp
7051 @bye