summaryrefslogtreecommitdiff
path: root/buildbot/buildbot-source/docs/buildbot.texinfo
blob: 07787d968b32dc9a203d64fe0b7830bf805bf2f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename buildbot.info
@settitle BuildBot Manual 0.7.3
@c %**end of header

@copying
This is the BuildBot manual.

Copyright (C) 2005,2006 Brian Warner

Copying and distribution of this file, with or without
modification, are permitted in any medium without royalty
provided the copyright notice and this notice are preserved.

@end copying

@titlepage
@title BuildBot
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage

@c Output the table of the contents at the beginning.
@contents

@ifnottex
@node Top, Introduction, (dir), (dir)
@top BuildBot

@insertcopying
@end ifnottex

@menu
* Introduction::                What the BuildBot does.
* Installation::                Creating a buildmaster and buildslaves,
                                running them.
* Concepts::                    What goes on in the buildbot's little mind.
* Configuration::               Controlling the buildbot.
* Getting Source Code Changes::  Discovering when to run a build.
* Build Process::               Controlling how each build is run.
* Status Delivery::             Telling the world about the build's results.
* Command-line tool::           
* Resources::                   Getting help.
* Developer's Appendix::        
* Index::                       Complete index.

@detailmenu
 --- The Detailed Node Listing ---

Introduction

* History and Philosophy::      
* System Architecture::         
* Control Flow::                

Installation

* Requirements::                
* Installing the code::         
* Creating a buildmaster::      
* Creating a buildslave::       
* Launching the daemons::       
* Logfiles::                    
* Shutdown::                    
* Maintenance::                 
* Troubleshooting::             

Creating a buildslave

* Buildslave Options::          

Troubleshooting

* Starting the buildslave::     
* Connecting to the buildmaster::  
* Forcing Builds::              

Concepts

* Version Control Systems::     
* Schedulers::                  
* BuildSet::                    
* BuildRequest::                
* Builder::                     
* Users::                       

Version Control Systems

* Generalizing VC Systems::     
* Source Tree Specifications::  
* How Different VC Systems Specify Sources::  
* Attributes of Changes::       

Users

* Doing Things With Users::     
* Email Addresses::             
* IRC Nicknames::               
* Live Status Clients::         

Configuration

* Config File Format::          
* Loading the Config File::     
* Defining the Project::        
* Listing Change Sources and Schedulers::  
* Setting the slaveport::       
* Buildslave Specifiers::       
* Defining Builders::           
* Defining Status Targets::     
* Debug options::               

Listing Change Sources and Schedulers

* Scheduler Types::             
* Build Dependencies::          

Getting Source Code Changes

* Change Sources::              

Change Sources

* Choosing ChangeSources::      
* CVSToys - PBService::         
* CVSToys - mail notification::  
* Other mail notification ChangeSources::  
* PBChangeSource::              

Build Process

* Build Steps::                 
* Interlocks::                  
* Build Factories::             

Build Steps

* Common Parameters::           
* Source Checkout::             
* ShellCommand::                
* Simple ShellCommand Subclasses::  

Source Checkout

* CVS::                         
* SVN::                         
* Darcs::                       
* Mercurial::                   
* Arch::                        
* Bazaar::                      
* P4Sync::                      

Simple ShellCommand Subclasses

* Configure::                   
* Compile::                     
* Test::                        
* Writing New BuildSteps::      
* Build Properties::            

Build Factories

* BuildStep Objects::           
* BuildFactory::                
* Process-Specific build factories::  

BuildFactory

* BuildFactory Attributes::     
* Quick builds::                

Process-Specific build factories

* GNUAutoconf::                 
* CPAN::                        
* Python distutils::            
* Python/Twisted/trial projects::  

Status Delivery

* HTML Waterfall::              
* IRC Bot::                     
* PBListener::                  

Command-line tool

* Administrator Tools::         
* Developer Tools::             
* Other Tools::                 
* .buildbot config directory::  

Developer Tools

* statuslog::                   
* statusgui::                   
* try::                         

Other Tools

* sendchange::                  
* debugclient::                 

@end detailmenu
@end menu

@node Introduction, Installation, Top, Top
@chapter Introduction

@cindex introduction

The BuildBot is a system to automate the compile/test cycle required by most
software projects to validate code changes. By automatically rebuilding and
testing the tree each time something has changed, build problems are
pinpointed quickly, before other developers are inconvenienced by the
failure. The guilty developer can be identified and harassed without human
intervention. By running the builds on a variety of platforms, developers
who do not have the facilities to test their changes everywhere before
checkin will at least know shortly afterwards whether they have broken the
build or not. Warning counts, lint checks, image size, compile time, and
other build parameters can be tracked over time, are more visible, and
are therefore easier to improve.

The overall goal is to reduce tree breakage and provide a platform to
run tests or code-quality checks that are too annoying or pedantic for
any human to waste their time with. Developers get immediate (and
potentially public) feedback about their changes, encouraging them to
be more careful about testing before checkin.

Features:

@itemize @bullet
@item
run builds on a variety of slave platforms
@item
arbitrary build process: handles projects using C, Python, whatever
@item
minimal host requirements: python and Twisted
@item
slaves can be behind a firewall if they can still do checkout
@item
status delivery through web page, email, IRC, other protocols
@item
track builds in progress, provide estimated completion time
@item
flexible configuration by subclassing generic build process classes
@item
debug tools to force a new build, submit fake Changes, query slave status
@item
released under the GPL
@end itemize

@menu
* History and Philosophy::      
* System Architecture::         
* Control Flow::                
@end menu


@node History and Philosophy, System Architecture, Introduction, Introduction
@section History and Philosophy

@cindex Philosophy of operation

The Buildbot was inspired by a similar project built for a development
team writing a cross-platform embedded system. The various components
of the project were supposed to compile and run on several flavors of
unix (linux, solaris, BSD), but individual developers had their own
preferences and tended to stick to a single platform. From time to
time, incompatibilities would sneak in (some unix platforms want to
use @code{string.h}, some prefer @code{strings.h}), and then the tree
would compile for some developers but not others. The buildbot was
written to automate the human process of walking into the office,
updating a tree, compiling (and discovering the breakage), finding the
developer at fault, and complaining to them about the problem they had
introduced. With multiple platforms it was difficult for developers to
do the right thing (compile their potential change on all platforms);
the buildbot offered a way to help.

Another problem was when programmers would change the behavior of a
library without warning its users, or change internal aspects that
other code was (unfortunately) depending upon. Adding unit tests to
the codebase helps here: if an application's unit tests pass despite
changes in the libraries it uses, you can have more confidence that
the library changes haven't broken anything. Many developers
complained that the unit tests were inconvenient or took too long to
run: having the buildbot run them reduces the developer's workload to
a minimum.

In general, having more visibility into the project is always good,
and automation makes it easier for developers to do the right thing.
When everyone can see the status of the project, developers are
encouraged to keep the tree in good working order. Unit tests that
aren't run on a regular basis tend to suffer from bitrot just like
code does: exercising them on a regular basis helps to keep them
functioning and useful.

The current version of the Buildbot is additionally targeted at
distributed free-software projects, where resources and platforms are
only available when provided by interested volunteers. The buildslaves
are designed to require an absolute minimum of configuration, reducing
the effort a potential volunteer needs to expend to be able to
contribute a new test environment to the project. The goal is for
anyone who wishes that a given project would run on their favorite
platform should be able to offer that project a buildslave, running on
that platform, where they can verify that their portability code
works, and keeps working.

@node System Architecture, Control Flow, History and Philosophy, Introduction
@comment  node-name,  next,  previous,  up
@section System Architecture

The Buildbot consists of a single @code{buildmaster} and one or more
@code{buildslaves}, connected in a star topology. The buildmaster
makes all decisions about what and when to build. It sends commands to
be run on the build slaves, which simply execute the commands and
return the results. (certain steps involve more local decision making,
where the overhead of sending a lot of commands back and forth would
be inappropriate, but in general the buildmaster is responsible for
everything).

The buildmaster is usually fed @code{Changes} by some sort of version
control system @xref{Change Sources}, which may cause builds to be
run. As the builds are performed, various status messages are
produced, which are then sent to any registered Status Targets
@xref{Status Delivery}.

@ifinfo
@smallexample
@group
 TODO: picture of change sources, master, slaves, status targets
 should look like docs/PyCon-2003/sources/overview.svg
@end group
@end smallexample
@end ifinfo
@ifnotinfo
@c @image{images/overview}
@end ifnotinfo

The buildmaster is configured and maintained by the ``buildmaster
admin'', who is generally the project team member responsible for
build process issues. Each buildslave is maintained by a ``buildslave
admin'', who do not need to be quite as involved. Generally slaves are
run by anyone who has an interest in seeing the project work well on
their platform.


@node Control Flow,  , System Architecture, Introduction
@comment  node-name,  next,  previous,  up
@section Control Flow

A day in the life of the buildbot:

@itemize @bullet

@item
A developer commits some source code changes to the repository. A hook
script or commit trigger of some sort sends information about this
change to the buildmaster through one of its configured Change
Sources. This notification might arrive via email, or over a network
connection (either initiated by the buildmaster as it ``subscribes''
to changes, or by the commit trigger as it pushes Changes towards the
buildmaster). The Change contains information about who made the
change, what files were modified, which revision contains the change,
and any checkin comments.

@item
The buildmaster distributes this change to all of its configured
Schedulers. Any ``important'' changes cause the ``tree-stable-timer''
to be started, and the Change is added to a list of those that will go
into a new Build. When the timer expires, a Build is started on each
of a set of configured Builders, all compiling/testing the same source
code. Unless configured otherwise, all Builds run in parallel on the
various buildslaves.

@item
The Build consists of a series of Steps. Each Step causes some number
of commands to be invoked on the remote buildslave associated with
that Builder. The first step is almost always to perform a checkout of
the appropriate revision from the same VC system that produced the
Change. The rest generally perform a compile and run unit tests. As
each Step runs, the buildslave reports back command output and return
status to the buildmaster.

@item
As the Build runs, status messages like ``Build Started'', ``Step
Started'', ``Build Finished'', etc, are published to a collection of
Status Targets. One of these targets is usually the HTML ``Waterfall''
display, which shows a chronological list of events, and summarizes
the results of the most recent build at the top of each column.
Developers can periodically check this page to see how their changes
have fared. If they see red, they know that they've made a mistake and
need to fix it. If they see green, they know that they've done their
duty and don't need to worry about their change breaking anything.

@item
If a MailNotifier status target is active, the completion of a build
will cause email to be sent to any developers whose Changes were
incorporated into this Build. The MailNotifier can be configured to
only send mail upon failing builds, or for builds which have just
transitioned from passing to failing. Other status targets can provide
similar real-time notification via different communication channels,
like IRC.

@end itemize


@node Installation, Concepts, Introduction, Top
@chapter Installation

@menu
* Requirements::                
* Installing the code::         
* Creating a buildmaster::      
* Creating a buildslave::       
* Launching the daemons::       
* Logfiles::                    
* Shutdown::                    
* Maintenance::                 
* Troubleshooting::             
@end menu

@node Requirements, Installing the code, Installation, Installation
@section Requirements

At a bare minimum, you'll need the following (for both the buildmaster
and a buildslave):

@itemize @bullet
@item
Python: http://www.python.org

Buildbot requires python-2.2 or later, and is primarily developed
against python-2.3. The buildmaster uses generators, a feature which
is not available in python-2.1, and both master and slave require a
version of Twisted which only works with python-2.2 or later. Certain
features (like the inclusion of build logs in status emails) require
python-2.2.2 or later. The IRC ``force build'' command requires
python-2.3 (for the shlex.split function).

@item
Twisted: http://twistedmatrix.com

Both the buildmaster and the buildslaves require Twisted-1.3.0 or
later. It has been mainly developed against Twisted-2.0.1, but has
been tested against Twisted-2.1.0 (the most recent as of this
writing), and might even work on versions as old as Twisted-1.1.0, but
as always the most recent version is recommended.

Twisted-1.3.0 and earlier were released as a single monolithic
package. When you run Buildbot against Twisted-2.0.0 or later (which
are split into a number of smaller subpackages), you'll need at least
"Twisted" (the core package), and you'll also want TwistedMail,
TwistedWeb, and TwistedWords (for sending email, serving a web status
page, and delivering build status via IRC, respectively).
@end itemize

Certain other packages may be useful on the system running the
buildmaster:

@itemize @bullet
@item
CVSToys: http://purl.net/net/CVSToys

If your buildmaster uses FreshCVSSource to receive change notification
from a cvstoys daemon, it will require CVSToys be installed (tested
with CVSToys-1.0.10). If the it doesn't use that source (i.e. if you
only use a mail-parsing change source, or the SVN notification
script), you will not need CVSToys.

@end itemize

And of course, your project's build process will impose additional
requirements on the buildslaves. These hosts must have all the tools
necessary to compile and test your project's source code.


@node Installing the code, Creating a buildmaster, Requirements, Installation
@section Installing the code

@cindex installation

The Buildbot is installed using the standard python @code{distutils}
module. After unpacking the tarball, the process is:

@example
python setup.py build
python setup.py install
@end example

where the install step may need to be done as root. This will put the
bulk of the code in somewhere like
/usr/lib/python2.3/site-packages/buildbot . It will also install the
@code{buildbot} command-line tool in /usr/bin/buildbot.

To test this, shift to a different directory (like /tmp), and run:

@example
buildbot --version
@end example

If it shows you the versions of Buildbot and Twisted, the install went
ok. If it says @code{no such command} or it gets an @code{ImportError}
when it tries to load the libaries, then something went wrong.
@code{pydoc buildbot} is another useful diagnostic tool.

Windows users will find these files in other places. You will need to
make sure that python can find the libraries, and will probably find
it convenient to have @code{buildbot} on your PATH.

If you wish, you can run the buildbot unit test suite like this:

@example
PYTHONPATH=. trial buildbot.test
@end example

This should run up to 192 tests, depending upon what VC tools you have
installed. On my desktop machine it takes about five minutes to
complete. Nothing should fail, a few might be skipped. If any of the
tests fail, you should stop and investigate the cause before
continuing the installation process, as it will probably be easier to
track down the bug early.

If you cannot or do not wish to install the buildbot into a site-wide
location like @file{/usr} or @file{/usr/local}, you can also install
it into the account's home directory. Do the install command like
this:

@example
python setup.py install --home=~
@end example

That will populate @file{~/lib/python} and create
@file{~/bin/buildbot}. Make sure this lib directory is on your
@code{PYTHONPATH}.


@node Creating a buildmaster, Creating a buildslave, Installing the code, Installation
@section Creating a buildmaster

As you learned earlier (@pxref{System Architecture}), the buildmaster
runs on a central host (usually one that is publically visible, so
everybody can check on the status of the project), and controls all
aspects of the buildbot system. Let us call this host
@code{buildbot.example.org}.

You may wish to create a separate user account for the buildmaster,
perhaps named @code{buildmaster}. This can help keep your personal
configuration distinct from that of the buildmaster and is useful if
you have to use a mail-based notification system (@pxref{Change
Sources}). However, the Buildbot will work just fine with your regular
user account.

You need to choose a directory for the buildmaster, called the
@code{basedir}. This directory will be owned by the buildmaster, which
will use configuration files therein, and create status files as it
runs. @file{~/Buildbot} is a likely value. If you run multiple
buildmasters in the same account, or if you run both masters and
slaves, you may want a more distinctive name like
@file{~/Buildbot/master/gnomovision} or
@file{~/Buildmasters/fooproject}. If you are using a separate user
account, this might just be @file{~buildmaster/masters/fooprojects}.

Once you've picked a directory, use the @command{buildbot master}
command to create the directory and populate it with startup files:

@example
buildbot master @var{basedir}
@end example

You will need to create a configuration file (@pxref{Configuration})
before starting the buildmaster. Most of the rest of this manual is
dedicated to explaining how to do this. A sample configuration file is
placed in the working directory, named @file{master.cfg.sample}, which
can be copied to @file{master.cfg} and edited to suit your purposes.

(Internal details: This command creates a file named
@file{buildbot.tac} that contains all the state necessary to create
the buildmaster. Twisted has a tool called @code{twistd} which can use
this .tac file to create and launch a buildmaster instance. twistd
takes care of logging and daemonization (running the program in the
background). @file{/usr/bin/buildbot} is a front end which runs twistd
for you.)

In addition to @file{buildbot.tac}, a small @file{Makefile.sample} is
installed. This can be used as the basis for customized daemon startup,
@xref{Launching the daemons}.


@node Creating a buildslave, Launching the daemons, Creating a buildmaster, Installation
@section Creating a buildslave

Typically, you will be adding a buildslave to an existing buildmaster,
to provide additional architecture coverage. The buildbot
administrator will give you several pieces of information necessary to
connect to the buildmaster. You should also be somewhat familiar with
the project being tested, so you can troubleshoot build problems
locally.

The buildbot exists to make sure that the project's stated ``how to
build it'' process actually works. To this end, the buildslave should
run in an environment just like that of your regular developers.
Typically the project build process is documented somewhere
(@file{README}, @file{INSTALL}, etc), in a document that should
mention all library dependencies and contain a basic set of build
instructions. This document will be useful as you configure the host
and account in which the buildslave runs.

Here's a good checklist for setting up a buildslave:

@enumerate
@item
Set up the account

It is recommended (although not mandatory) to set up a separate user
account for the buildslave. This account is frequently named
@code{buildbot} or @code{buildslave}. This serves to isolate your
personal working environment from that of the slave's, and helps to
minimize the security threat posed by letting possibly-unknown
contributors run arbitrary code on your system. The account should
have a minimum of fancy init scripts.

@item
Install the buildbot code

Follow the instructions given earlier (@pxref{Installing the code}).
If you use a separate buildslave account, and you didn't install the
buildbot code to a shared location, then you will need to install it
with @code{--home=~} for each account that needs it.

@item
Set up the host

Make sure the host can actually reach the buildmaster. Usually the
buildmaster is running a status webserver on the same machine, so
simply point your web browser at it and see if you can get there.
Install whatever additional packages or libraries the project's
INSTALL document advises. (or not: if your buildslave is supposed to
make sure that building without optional libraries still works, then
don't install those libraries).

Again, these libraries don't necessarily have to be installed to a
site-wide shared location, but they must be available to your build
process. Accomplishing this is usually very specific to the build
process, so installing them to @file{/usr} or @file{/usr/local} is
usually the best approach.

@item
Test the build process

Follow the instructions in the INSTALL document, in the buildslave's
account. Perform a full CVS (or whatever) checkout, configure, make,
run tests, etc. Confirm that the build works without manual fussing.
If it doesn't work when you do it by hand, it will be unlikely to work
when the buildbot attempts to do it in an automated fashion.

@item
Choose a base directory

This should be somewhere in the buildslave's account, typically named
after the project which is being tested. The buildslave will not touch
any file outside of this directory. Something like @file{~/Buildbot}
or @file{~/Buildslaves/fooproject} is appropriate.

@item
Get the buildmaster host/port, botname, and password

When the buildbot admin configures the buildmaster to accept and use
your buildslave, they will provide you with the following pieces of
information:

@itemize @bullet
@item
your buildslave's name
@item
the password assigned to your buildslave
@item
the hostname and port number of the buildmaster, i.e. buildbot.example.org:8007
@end itemize

@item
Create the buildslave

Now run the 'buildbot' command as follows:

@example
buildbot slave @var{BASEDIR} @var{MASTERHOST}:@var{PORT} @var{SLAVENAME} @var{PASSWORD}
@end example

This will create the base directory and a collection of files inside,
including the @file{buildbot.tac} file that contains all the
information you passed to the @code{buildbot} command.

@item
Fill in the hostinfo files

When it first connects, the buildslave will send a few files up to the
buildmaster which describe the host that it is running on. These files
are presented on the web status display so that developers have more
information to reproduce any test failures that are witnessed by the
buildbot. There are sample files in the @file{info} subdirectory of
the buildbot's base directory. You should edit these to correctly
describe you and your host.

@file{BASEDIR/info/admin} should contain your name and email address.
This is the ``buildslave admin address'', and will be visible from the
build status page (so you may wish to munge it a bit if
address-harvesting spambots are a concern).

@file{BASEDIR/info/host} should be filled with a brief description of
the host: OS, version, memory size, CPU speed, versions of relevant
libraries installed, and finally the version of the buildbot code
which is running the buildslave.

If you run many buildslaves, you may want to create a single
@file{~buildslave/info} file and share it among all the buildslaves
with symlinks.

@end enumerate

@menu
* Buildslave Options::          
@end menu

@node Buildslave Options,  , Creating a buildslave, Creating a buildslave
@subsection Buildslave Options

There are a handful of options you might want to use when creating the
buildslave with the @command{buildbot slave <options> DIR <params>}
command. You can type @command{buildbot slave --help} for a summary.
To use these, just include them on the @command{buildbot slave}
command line, like this:

@example
buildbot slave --umask=022 ~/buildslave buildmaster.example.org:42012 myslavename mypasswd
@end example

@table @code
@item --usepty
This is a boolean flag that tells the buildslave whether to launch
child processes in a PTY (the default) or with regular pipes. The
advantage of using a PTY is that ``grandchild'' processes are more
likely to be cleaned up if the build is interrupted or times out
(since it enables the use of a ``process group'' in which all child
processes will be placed). The disadvantages: some forms of Unix have
problems with PTYs, some of your unit tests may behave differently
when run under a PTY (generally those which check to see if they are
being run interactively), and PTYs will merge the stdout and stderr
streams into a single output stream (which means the red-vs-black
coloring in the logfiles will be lost). If you encounter problems, you
can add @code{--usepty=0} to disable the use of PTYs. Note that
windows buildslaves never use PTYs.

@item --umask
This is a string (generally an octal representation of an integer)
which will cause the buildslave process' ``umask'' value to be set
shortly after initialization. The ``twistd'' daemonization utility
forces the umask to 077 at startup (which means that all files created
by the buildslave or its child processes will be unreadable by any
user other than the buildslave account). If you want build products to
be readable by other accounts, you can add @code{--umask=022} to tell
the buildslave to fix the umask after twistd clobbers it. If you want
build products to be @emph{writable} by other accounts too, use
@code{--umask=000}, but this is likely to be a security problem.

@item --keepalive
This is a number that indicates how frequently ``keepalive'' messages
should be sent from the buildslave to the buildmaster, expressed in
seconds. The default (600) causes a message to be sent to the
buildmaster at least once every 10 minutes. To set this to a lower
value, use e.g. @code{--keepalive=120}.

If the buildslave is behind a NAT box or stateful firewall, these
messages may help to keep the connection alive: some NAT boxes tend to
forget about a connection if it has not been used in a while. When
this happens, the buildmaster will think that the buildslave has
disappeared, and builds will time out. Meanwhile the buildslave will
not realize than anything is wrong.

@end table


@node Launching the daemons, Logfiles, Creating a buildslave, Installation
@section Launching the daemons

Both the buildmaster and the buildslave run as daemon programs. To
launch them, pass the working directory to the @code{buildbot}
command:

@example
buildbot start @var{BASEDIR}
@end example

This command will start the daemon and then return, so normally it
will not produce any output. To verify that the programs are indeed
running, look for a pair of files named @file{twistd.log} and
@file{twistd.pid} that should be created in the working directory.
@file{twistd.pid} contains the process ID of the newly-spawned daemon.

When the buildslave connects to the buildmaster, new directories will
start appearing in its base directory. The buildmaster tells the slave
to create a directory for each Builder which will be using that slave.
All build operations are performed within these directories: CVS
checkouts, compiles, and tests.

Once you get everything running, you will want to arrange for the
buildbot daemons to be started at boot time. One way is to use
@code{cron}, by putting them in a @@reboot crontab entry@footnote{this
@@reboot syntax is understood by Vixie cron, which is the flavor
usually provided with linux systems. Other unices may have a cron that
doesn't understand @@reboot}:

@example
@@reboot buildbot start @var{BASEDIR}
@end example

When you run @command{crontab} to set this up, remember to do it as
the buildmaster or buildslave account! If you add this to your crontab
when running as your regular account (or worse yet, root), then the
daemon will run as the wrong user, quite possibly as one with more
authority than you intended to provide.

It is important to remember that the environment provided to cron jobs
and init scripts can be quite different that your normal runtime.
There may be fewer environment variables specified, and the PATH may
be shorter than usual. It is a good idea to test out this method of
launching the buildslave by using a cron job with a time in the near
future, with the same command, and then check @file{twistd.log} to
make sure the slave actually started correctly. Common problems here
are for @file{/usr/local} or @file{~/bin} to not be on your
@code{PATH}, or for @code{PYTHONPATH} to not be set correctly.
Sometimes @code{HOME} is messed up too.

To modify the way the daemons are started (perhaps you want to set
some environment variables first, or perform some cleanup each time),
you can create a file named @file{Makefile.buildbot} in the base
directory. When the @file{buildbot} front-end tool is told to
@command{start} the daemon, and it sees this file (and
@file{/usr/bin/make} exists), it will do @command{make -f
Makefile.buildbot start} instead of its usual action (which involves
running @command{twistd}). When the buildmaster or buildslave is
installed, a @file{Makefile.sample} is created which implements the
same behavior as the the @file{buildbot} tool uses, so if you want to
customize the process, just copy @file{Makefile.sample} to
@file{Makefile.buildbot} and edit it as necessary.

@node Logfiles, Shutdown, Launching the daemons, Installation
@section Logfiles

@cindex logfiles

While a buildbot daemon runs, it emits text to a logfile, named
@file{twistd.log}. A command like @code{tail -f twistd.log} is useful
to watch the command output as it runs.

The buildmaster will announce any errors with its configuration file
in the logfile, so it is a good idea to look at the log at startup
time to check for any problems. Most buildmaster activities will cause
lines to be added to the log.

@node Shutdown, Maintenance, Logfiles, Installation
@section Shutdown

To stop a buildmaster or buildslave manually, use:

@example
buildbot stop @var{BASEDIR}
@end example

This simply looks for the @file{twistd.pid} file and kills whatever
process is identified within.

At system shutdown, all processes are sent a @code{SIGKILL}. The
buildmaster and buildslave will respond to this by shutting down
normally.

The buildmaster will respond to a @code{SIGHUP} by re-reading its
config file. The following shortcut is available:

@example
buildbot sighup @var{BASEDIR}
@end example

When you update the Buildbot code to a new release, you will need to
restart the buildmaster and/or buildslave before it can take advantage
of the new code. You can do a @code{buildbot stop @var{BASEDIR}} and
@code{buildbot start @var{BASEDIR}} in quick succession, or you can
use the @code{restart} shortcut, which does both steps for you:

@example
buildbot restart @var{BASEDIR}
@end example


@node Maintenance, Troubleshooting, Shutdown, Installation
@section Maintenance

It is a good idea to check the buildmaster's status page every once in
a while, to see if your buildslave is still online. Eventually the
buildbot will probably be enhanced to send you email (via the
@file{info/admin} email address) when the slave has been offline for
more than a few hours.

If you find you can no longer provide a buildslave to the project, please
let the project admins know, so they can put out a call for a
replacement.

The Buildbot records status and logs output continually, each time a
build is performed. The status tends to be small, but the build logs
can become quite large. Each build and log are recorded in a separate
file, arranged hierarchically under the buildmaster's base directory.
To prevent these files from growing without bound, you should
periodically delete old build logs. A simple cron job to delete
anything older than, say, two weeks should do the job. The only trick
is to leave the @file{buildbot.tac} and other support files alone, for
which find's @code{-mindepth} argument helps skip everything in the
top directory. You can use something like the following:

@example
@@weekly cd BASEDIR && find . -mindepth 2 -type f -mtime +14 -exec rm @{@} \;
@@weekly cd BASEDIR && find twistd.log* -mtime +14 -exec rm @{@} \;
@end example

@node Troubleshooting,  , Maintenance, Installation
@section Troubleshooting

Here are a few hints on diagnosing common problems.

@menu
* Starting the buildslave::     
* Connecting to the buildmaster::  
* Forcing Builds::              
@end menu

@node Starting the buildslave, Connecting to the buildmaster, Troubleshooting, Troubleshooting
@subsection Starting the buildslave

Cron jobs are typically run with a minimal shell (@file{/bin/sh}, not
@file{/bin/bash}), and tilde expansion is not always performed in such
commands. You may want to use explicit paths, because the @code{PATH}
is usually quite short and doesn't include anything set by your
shell's startup scripts (@file{.profile}, @file{.bashrc}, etc). If
you've installed buildbot (or other python libraries) to an unusual
location, you may need to add a @code{PYTHONPATH} specification (note
that python will do tilde-expansion on @code{PYTHONPATH} elements by
itself). Sometimes it is safer to fully-specify everything:

@example
@@reboot PYTHONPATH=~/lib/python /usr/local/bin/buildbot start /usr/home/buildbot/basedir
@end example

Take the time to get the @@reboot job set up. Otherwise, things will work
fine for a while, but the first power outage or system reboot you have will
stop the buildslave with nothing but the cries of sorrowful developers to
remind you that it has gone away.

@node Connecting to the buildmaster, Forcing Builds, Starting the buildslave, Troubleshooting
@subsection Connecting to the buildmaster

If the buildslave cannot connect to the buildmaster, the reason should
be described in the @file{twistd.log} logfile. Some common problems
are an incorrect master hostname or port number, or a mistyped bot
name or password. If the buildslave loses the connection to the
master, it is supposed to attempt to reconnect with an
exponentially-increasing backoff. Each attempt (and the time of the
next attempt) will be logged. If you get impatient, just manually stop
and re-start the buildslave.

When the buildmaster is restarted, all slaves will be disconnected,
and will attempt to reconnect as usual. The reconnect time will depend
upon how long the buildmaster is offline (i.e. how far up the
exponential backoff curve the slaves have travelled). Again,
@code{buildbot stop @var{BASEDIR}; buildbot start @var{BASEDIR}} will
speed up the process.

@node Forcing Builds,  , Connecting to the buildmaster, Troubleshooting
@subsection Forcing Builds

From the buildmaster's main status web page, you can force a build to
be run on your build slave. Figure out which column is for a builder
that runs on your slave, click on that builder's name, and the page
that comes up will have a ``Force Build'' button. Fill in the form,
hit the button, and a moment later you should see your slave's
@file{twistd.log} filling with commands being run. Using @code{pstree}
or @code{top} should also reveal the cvs/make/gcc/etc processes being
run by the buildslave. Note that the same web page should also show
the @file{admin} and @file{host} information files that you configured
earlier.

@node Concepts, Configuration, Installation, Top
@chapter Concepts

This chapter defines some of the basic concepts that the Buildbot
uses. You'll need to understand how the Buildbot sees the world to
configure it properly.

@menu
* Version Control Systems::     
* Schedulers::                  
* BuildSet::                    
* BuildRequest::                
* Builder::                     
* Users::                       
@end menu

@node Version Control Systems, Schedulers, Concepts, Concepts
@section Version Control Systems

@cindex Version Control

These source trees come from a Version Control System of some kind.
CVS and Subversion are two popular ones, but the Buildbot supports
others. All VC systems have some notion of an upstream
@code{repository} which acts as a server@footnote{except Darcs, but
since the Buildbot never modifies its local source tree we can ignore
the fact that Darcs uses a less centralized model}, from which clients
can obtain source trees according to various parameters. The VC
repository provides source trees of various projects, for different
branches, and from various points in time. The first thing we have to
do is to specify which source tree we want to get.

@menu
* Generalizing VC Systems::     
* Source Tree Specifications::  
* How Different VC Systems Specify Sources::  
* Attributes of Changes::       
@end menu

@node Generalizing VC Systems, Source Tree Specifications, Version Control Systems, Version Control Systems
@subsection Generalizing VC Systems

For the purposes of the Buildbot, we will try to generalize all VC
systems as having repositories that each provide sources for a variety
of projects. Each project is defined as a directory tree with source
files. The individual files may each have revisions, but we ignore
that and treat the project as a whole as having a set of revisions.
Each time someone commits a change to the project, a new revision
becomes available. These revisions can be described by a tuple with
two items: the first is a branch tag, and the second is some kind of
timestamp or revision stamp. Complex projects may have multiple branch
tags, but there is always a default branch. The timestamp may be an
actual timestamp (such as the -D option to CVS), or it may be a
monotonically-increasing transaction number (such as the change number
used by SVN and P4, or the revision number used by Arch, or a labeled
tag used in CVS)@footnote{many VC systems provide more complexity than
this: in particular the local views that P4 and ClearCase can assemble
out of various source directories are more complex than we're prepared
to take advantage of here}. The SHA1 revision ID used by Monotone and
Mercurial is also a kind of revision stamp, in that it specifies a
unique copy of the source tree, as does a Darcs ``context'' file.

When we aren't intending to make any changes to the sources we check out
(at least not any that need to be committed back upstream), there are two
basic ways to use a VC system:

@itemize @bullet
@item
Retrieve a specific set of source revisions: some tag or key is used
to index this set, which is fixed and cannot be changed by subsequent
developers committing new changes to the tree. Releases are built from
tagged revisions like this, so that they can be rebuilt again later
(probably with controlled modifications).
@item
Retrieve the latest sources along a specific branch: some tag is used
to indicate which branch is to be used, but within that constraint we want
to get the latest revisions.
@end itemize

Build personnel or CM staff typically use the first approach: the
build that results is (ideally) completely specified by the two
parameters given to the VC system: repository and revision tag. This
gives QA and end-users something concrete to point at when reporting
bugs. Release engineers are also reportedly fond of shipping code that
can be traced back to a concise revision tag of some sort.

Developers are more likely to use the second approach: each morning
the developer does an update to pull in the changes committed by the
team over the last day. These builds are not easy to fully specify: it
depends upon exactly when you did a checkout, and upon what local
changes the developer has in their tree. Developers do not normally
tag each build they produce, because there is usually significant
overhead involved in creating these tags. Recreating the trees used by
one of these builds can be a challenge. Some VC systems may provide
implicit tags (like a revision number), while others may allow the use
of timestamps to mean ``the state of the tree at time X'' as opposed
to a tree-state that has been explicitly marked.

The Buildbot is designed to help developers, so it usually works in
terms of @emph{the latest} sources as opposed to specific tagged
revisions. However, it would really prefer to build from reproducible
source trees, so implicit revisions are used whenever possible.

@node Source Tree Specifications, How Different VC Systems Specify Sources, Generalizing VC Systems, Version Control Systems
@subsection Source Tree Specifications

So for the Buildbot's purposes we treat each VC system as a server
which can take a list of specifications as input and produce a source
tree as output. Some of these specifications are static: they are
attributes of the builder and do not change over time. Others are more
variable: each build will have a different value. The repository is
changed over time by a sequence of Changes, each of which represents a
single developer making changes to some set of files. These Changes
are cumulative@footnote{Monotone's @emph{multiple heads} feature
violates this assumption of cumulative Changes, but in most situations
the changes don't occur frequently enough for this to be a significant
problem}.

For normal builds, the Buildbot wants to get well-defined source trees
that contain specific Changes, and exclude other Changes that may have
occurred after the desired ones. We assume that the Changes arrive at
the buildbot (through one of the mechanisms described in @pxref{Change
Sources}) in the same order in which they are committed to the
repository. The Buildbot waits for the tree to become ``stable''
before initiating a build, for two reasons. The first is that
developers frequently make multiple related commits in quick
succession, even when the VC system provides ways to make atomic
transactions involving multiple files at the same time. Running a
build in the middle of these sets of changes would use an inconsistent
set of source files, and is likely to fail (and is certain to be less
useful than a build which uses the full set of changes). The
tree-stable-timer is intended to avoid these useless builds that
include some of the developer's changes but not all. The second reason
is that some VC systems (i.e. CVS) do not provide repository-wide
transaction numbers, so that timestamps are the only way to refer to
a specific repository state. These timestamps may be somewhat
ambiguous, due to processing and notification delays. By waiting until
the tree has been stable for, say, 10 minutes, we can choose a
timestamp from the middle of that period to use for our source
checkout, and then be reasonably sure that any clock-skew errors will
not cause the build to be performed on an inconsistent set of source
files.

The Schedulers always use the tree-stable-timer, with a timeout that
is configured to reflect a reasonable tradeoff between build latency
and change frequency. When the VC system provides coherent
repository-wide revision markers (such as Subversion's revision
numbers, or in fact anything other than CVS's timestamps), the
resulting Build is simply performed against a source tree defined by
that revision marker. When the VC system does not provide this, a
timestamp from the middle of the tree-stable period is used to
generate the source tree@footnote{this @code{checkoutDelay} defaults
to half the tree-stable timer, but it can be overridden with an
argument to the Source Step}.

@node How Different VC Systems Specify Sources, Attributes of Changes, Source Tree Specifications, Version Control Systems
@subsection How Different VC Systems Specify Sources

For CVS, the static specifications are @code{repository} and
@code{module}. In addition to those, each build uses a timestamp (or
omits the timestamp to mean @code{the latest}) and @code{branch tag}
(which defaults to HEAD). These parameters collectively specify a set
of sources from which a build may be performed.

@uref{http://subversion.tigris.org, Subversion} combines the
repository, module, and branch into a single @code{Subversion URL}
parameter. Within that scope, source checkouts can be specified by a
numeric @code{revision number} (a repository-wide
monotonically-increasing marker, such that each transaction that
changes the repository is indexed by a different revision number), or
a revision timestamp. When branches are used, the repository and
module form a static @code{baseURL}, while each build has a
@code{revision number} and a @code{branch} (which defaults to a
statically-specified @code{defaultBranch}). The @code{baseURL} and
@code{branch} are simply concatenated together to derive the
@code{svnurl} to use for the checkout.

@uref{http://wiki.gnuarch.org/, Arch} and
@uref{http://bazaar.canonical.com/, Bazaar} specify a repository by
URL, as well as a @code{version} which is kind of like a branch name.
Arch uses the word @code{archive} to represent the repository. Arch
lets you push changes from one archive to another, removing the strict
centralization required by CVS and SVN. It retains the distinction
between repository and working directory that most other VC systems
use. For complex multi-module directory structures, Arch has a
built-in @code{build config} layer with which the checkout process has
two steps. First, an initial bootstrap checkout is performed to
retrieve a set of build-config files. Second, one of these files is
used to figure out which archives/modules should be used to populate
subdirectories of the initial checkout.

Builders which use Arch and Bazaar therefore have a static archive
@code{url}, and a default ``branch'' (which is a string that specifies
a complete category--branch--version triple). Each build can have its
own branch (the category--branch--version string) to override the
default, as well as a revision number (which is turned into a
--patch-NN suffix when performing the checkout).

@uref{http://abridgegame.org/darcs/, Darcs} doesn't really have the
notion of a single master repository. Nor does it really have
branches. In Darcs, each working directory is also a repository, and
there are operations to push and pull patches from one of these
@code{repositories} to another. For the Buildbot's purposes, all you
need to do is specify the URL of a repository that you want to build
from. The build slave will then pull the latest patches from that
repository and build them. Multiple branches are implemented by using
multiple repositories (possibly living on the same server).

Builders which use Darcs therefore have a static @code{repourl} which
specifies the location of the repository. If branches are being used,
the source Step is instead configured with a @code{baseURL} and a
@code{defaultBranch}, and the two strings are simply concatenated
together to obtain the repository's URL. Each build then has a
specific branch which replaces @code{defaultBranch}, or just uses the
default one. Instead of a revision number, each build can have a
``context'', which is a string that records all the patches that are
present in a given tree (this is the output of @command{darcs changes
--context}, and is considerably less concise than, e.g. Subversion's
revision number, but the patch-reordering flexibility of Darcs makes
it impossible to provide a shorter useful specification).

@uref{http://selenic.com/mercurial, Mercurial} is like Darcs, in that
each branch is stored in a separate repository. The @code{repourl},
@code{baseURL}, and @code{defaultBranch} arguments are all handled the
same way as with Darcs. The ``revision'', however, is the hash
identifier returned by @command{hg identify}.


@node Attributes of Changes,  , How Different VC Systems Specify Sources, Version Control Systems
@subsection Attributes of Changes

@heading Who

Each Change has a @code{who} attribute, which specifies which
developer is responsible for the change. This is a string which comes
from a namespace controlled by the VC repository. Frequently this
means it is a username on the host which runs the repository, but not
all VC systems require this (Arch, for example, uses a fully-qualified
@code{Arch ID}, which looks like an email address, as does Darcs).
Each StatusNotifier will map the @code{who} attribute into something
appropriate for their particular means of communication: an email
address, an IRC handle, etc.

@heading Files

It also has a list of @code{files}, which are just the tree-relative
filenames of any files that were added, deleted, or modified for this
Change. These filenames are used by the @code{isFileImportant}
function (in the Scheduler) to decide whether it is worth triggering a
new build or not, e.g. the function could use
@code{filename.endswith(".c")} to only run a build if a C file were
checked in. Certain BuildSteps can also use the list of changed files
to run a more targeted series of tests, e.g. the
@code{step_twisted.Trial} step can run just the unit tests that
provide coverage for the modified .py files instead of running the
full test suite.

@heading Comments

The Change also has a @code{comments} attribute, which is a string
containing any checkin comments.

@heading Revision

Each Change can have a @code{revision} attribute, which describes how
to get a tree with a specific state: a tree which includes this Change
(and all that came before it) but none that come after it. If this
information is unavailable, the @code{.revision} attribute will be
@code{None}. These revisions are provided by the ChangeSource, and
consumed by the @code{computeSourceRevision} method in the appropriate
@code{step.Source} class.

@table @samp
@item CVS
@code{revision} is an int, seconds since the epoch
@item SVN
@code{revision} is an int, a transation number (r%d)
@item Darcs
@code{revision} is a large string, the output of @code{darcs changes --context}
@item Mercurial
@code{revision} is a short string (a hash ID), the output of @code{hg identify}
@item Arch/Bazaar
@code{revision} is the full revision ID (ending in --patch-%d)
@item P4
@code{revision} is an int, the transaction number
@end table

@heading Branches

The Change might also have a @code{branch} attribute. This indicates
that all of the Change's files are in the same named branch. The
Schedulers get to decide whether the branch should be built or not.

For VC systems like CVS, Arch, and Monotone, the @code{branch} name is
unrelated to the filename. (that is, the branch name and the filename
inhabit unrelated namespaces). For SVN, branches are expressed as
subdirectories of the repository, so the file's ``svnurl'' is a
combination of some base URL, the branch name, and the filename within
the branch. (In a sense, the branch name and the filename inhabit the
same namespace). Darcs branches are subdirectories of a base URL just
like SVN. Mercurial branches are the same as Darcs.

@table @samp
@item CVS
branch='warner-newfeature', files=['src/foo.c']
@item SVN
branch='branches/warner-newfeature', files=['src/foo.c']
@item Darcs
branch='warner-newfeature', files=['src/foo.c']
@item Mercurial
branch='warner-newfeature', files=['src/foo.c']
@item Arch/Bazaar
branch='buildbot--usebranches--0', files=['buildbot/master.py']
@end table

@heading Links

@c TODO: who is using 'links'? how is it being used?

Finally, the Change might have a @code{links} list, which is intended
to provide a list of URLs to a @emph{viewcvs}-style web page that
provides more detail for this Change, perhaps including the full file
diffs.


@node Schedulers, BuildSet, Version Control Systems, Concepts
@section Schedulers

@cindex Scheduler

Each Buildmaster has a set of @code{Scheduler} objects, each of which
gets a copy of every incoming Change. The Schedulers are responsible
for deciding when Builds should be run. Some Buildbot installations
might have a single Scheduler, while others may have several, each for
a different purpose.

For example, a ``quick'' scheduler might exist to give immediate
feedback to developers, hoping to catch obvious problems in the code
that can be detected quickly. These typically do not run the full test
suite, nor do they run on a wide variety of platforms. They also
usually do a VC update rather than performing a brand-new checkout
each time. You could have a ``quick'' scheduler which used a 30 second
timeout, and feeds a single ``quick'' Builder that uses a VC
@code{mode='update'} setting.

A separate ``full'' scheduler would run more comprehensive tests a
little while later, to catch more subtle problems. This scheduler
would have a longer tree-stable-timer, maybe 30 minutes, and would
feed multiple Builders (with a @code{mode=} of @code{'copy'},
@code{'clobber'}, or @code{'export'}).

The @code{tree-stable-timer} and @code{isFileImportant} decisions are
made by the Scheduler. Dependencies are also implemented here.
Periodic builds (those which are run every N seconds rather than after
new Changes arrive) are triggered by a special @code{Periodic}
Scheduler subclass. The default Scheduler class can also be told to
watch for specific branches, ignoring Changes on other branches. This
may be useful if you have a trunk and a few release branches which
should be tracked, but when you don't want to have the Buildbot pay
attention to several dozen private user branches.

Some Schedulers may trigger builds for other reasons, other than
recent Changes. For example, a Scheduler subclass could connect to a
remote buildmaster and watch for builds of a library to succeed before
triggering a local build that uses that library.

Each Scheduler creates and submits @code{BuildSet} objects to the
@code{BuildMaster}, which is then responsible for making sure the
individual @code{BuildRequests} are delivered to the target
@code{Builders}.

@code{Scheduler} instances are activated by placing them in the
@code{c['schedulers']} list in the buildmaster config file. Each
Scheduler has a unique name.


@node BuildSet, BuildRequest, Schedulers, Concepts
@section BuildSet

@cindex BuildSet

A @code{BuildSet} is the name given to a set of Builds that all
compile/test the same version of the tree on multiple Builders. In
general, all these component Builds will perform the same sequence of
Steps, using the same source code, but on different platforms or
against a different set of libraries.

The @code{BuildSet} is tracked as a single unit, which fails if any of
the component Builds have failed, and therefore can succeed only if
@emph{all} of the component Builds have succeeded. There are two kinds
of status notification messages that can be emitted for a BuildSet:
the @code{firstFailure} type (which fires as soon as we know the
BuildSet will fail), and the @code{Finished} type (which fires once
the BuildSet has completely finished, regardless of whether the
overall set passed or failed).

A @code{BuildSet} is created with a @emph{source stamp} tuple of
(branch, revision, changes, patch), some of which may be None, and a
list of Builders on which it is to be run. They are then given to the
BuildMaster, which is responsible for creating a separate
@code{BuildRequest} for each Builder.

There are a couple of different likely values for the
@code{SourceStamp}:

@table @code
@item (revision=None, changes=[CHANGES], patch=None)
This is a @code{SourceStamp} used when a series of Changes have
triggered a build. The VC step will attempt to check out a tree that
contains CHANGES (and any changes that occurred before CHANGES, but
not any that occurred after them).

@item (revision=None, changes=None, patch=None)
This builds the most recent code on the default branch. This is the
sort of @code{SourceStamp} that would be used on a Build that was
triggered by a user request, or a Periodic scheduler. It is also
possible to configure the VC Source Step to always check out the
latest sources rather than paying attention to the Changes in the
SourceStamp, which will result in same behavior as this.

@item (branch=BRANCH, revision=None, changes=None, patch=None)
This builds the most recent code on the given BRANCH. Again, this is
generally triggered by a user request or Periodic build.

@item (revision=REV, changes=None, patch=(LEVEL, DIFF))
This checks out the tree at the given revision REV, then applies a
patch (using @code{diff -pLEVEL <DIFF}). The @ref{try} feature uses
this kind of @code{SourceStamp}. If @code{patch} is None, the patching
step is bypassed.

@end table

The buildmaster is responsible for turning the @code{BuildSet} into a
set of @code{BuildRequest} objects and queueing them on the
appropriate Builders.


@node BuildRequest, Builder, BuildSet, Concepts
@section BuildRequest

@cindex BuildRequest

A @code{BuildRequest} is a request to build a specific set of sources
on a single specific Builder. Each Builder runs the
@code{BuildRequest} as soon as it can (i.e. when an associated
buildslave becomes free).

The @code{BuildRequest} contains the @code{SourceStamp} specification.
The actual process of running the build (the series of Steps that will
be executed) is implemented by the @code{Build} object. In this future
this might be changed, to have the @code{Build} define @emph{what}
gets built, and a separate @code{BuildProcess} (provided by the
Builder) to define @emph{how} it gets built.

The @code{BuildRequest} may be mergeable with other compatible
@code{BuildRequest}s. Builds that are triggered by incoming Changes
will generally be mergeable. Builds that are triggered by user
requests are generally not, unless they are multiple requests to build
the @emph{latest sources} of the same branch.

@node Builder, Users, BuildRequest, Concepts
@section Builder

@cindex Builder

The @code{Builder} is a long-lived object which controls all Builds of
a given type. Each one is created when the config file is first
parsed, and lives forever (or rather until it is removed from the
config file). It mediates the connections to the buildslaves that do
all the work, and is responsible for creating the @code{Build} objects
that decide @emph{how} a build is performed (i.e., which steps are
executed in what order).

Each @code{Builder} gets a unique name, and the path name of a
directory where it gets to do all its work (there is a
buildmaster-side directory for keeping status information, as well as
a buildslave-side directory where the actual checkout/compile/test
commands are executed). It also gets a @code{BuildFactory}, which is
responsible for creating new @code{Build} instances: because the
@code{Build} instance is what actually performs each build, choosing
the @code{BuildFactory} is the way to specify what happens each time a
build is done.

Each @code{Builder} is associated with one of more @code{BuildSlaves}.
A @code{Builder} which is used to perform OS-X builds (as opposed to
Linux or Solaris builds) should naturally be associated with an
OS-X-based buildslave.


@node Users,  , Builder, Concepts
@section Users

@cindex Users

Buildbot has a somewhat limited awareness of @emph{users}. It assumes
the world consists of a set of developers, each of whom can be
described by a couple of simple attributes. These developers make
changes to the source code, causing builds which may succeed or fail.

Each developer is primarily known through the source control system. Each
Change object that arrives is tagged with a @code{who} field that
typically gives the account name (on the repository machine) of the user
responsible for that change. This string is the primary key by which the
User is known, and is displayed on the HTML status pages and in each Build's
``blamelist''.

To do more with the User than just refer to them, this username needs to
be mapped into an address of some sort. The responsibility for this mapping
is left up to the status module which needs the address. The core code knows
nothing about email addresses or IRC nicknames, just user names.

@menu
* Doing Things With Users::     
* Email Addresses::             
* IRC Nicknames::               
* Live Status Clients::         
@end menu

@node Doing Things With Users, Email Addresses, Users, Users
@subsection Doing Things With Users

Each Change has a single User who is responsible for that Change. Most
Builds have a set of Changes: the Build represents the first time these
Changes have been built and tested by the Buildbot. The build has a
``blamelist'' that consists of a simple union of the Users responsible
for all the Build's Changes.

The Build provides (through the IBuildStatus interface) a list of Users
who are ``involved'' in the build. For now this is equal to the
blamelist, but in the future it will be expanded to include a ``build
sheriff'' (a person who is ``on duty'' at that time and responsible for
watching over all builds that occur during their shift), as well as
per-module owners who simply want to keep watch over their domain (chosen by
subdirectory or a regexp matched against the filenames pulled out of the
Changes). The Involved Users are those who probably have an interest in the
results of any given build.

In the future, Buildbot will acquire the concept of ``Problems'',
which last longer than builds and have beginnings and ends. For example, a
test case which passed in one build and then failed in the next is a
Problem. The Problem lasts until the test case starts passing again, at
which point the Problem is said to be ``resolved''.

If there appears to be a code change that went into the tree at the
same time as the test started failing, that Change is marked as being
resposible for the Problem, and the user who made the change is added
to the Problem's ``Guilty'' list. In addition to this user, there may
be others who share responsibility for the Problem (module owners,
sponsoring developers). In addition to the Responsible Users, there
may be a set of Interested Users, who take an interest in the fate of
the Problem.

Problems therefore have sets of Users who may want to be kept aware of
the condition of the problem as it changes over time. If configured, the
Buildbot can pester everyone on the Responsible list with increasing
harshness until the problem is resolved, with the most harshness reserved
for the Guilty parties themselves. The Interested Users may merely be told
when the problem starts and stops, as they are not actually responsible for
fixing anything.

@node Email Addresses, IRC Nicknames, Doing Things With Users, Users
@subsection Email Addresses

The @code{buildbot.status.mail.MailNotifier} class provides a
status target which can send email about the results of each build. It
accepts a static list of email addresses to which each message should be
delivered, but it can also be configured to send mail to the Build's
Interested Users. To do this, it needs a way to convert User names into
email addresses.

For many VC systems, the User Name is actually an account name on the
system which hosts the repository. As such, turning the name into an
email address is a simple matter of appending
``@@repositoryhost.com''. Some projects use other kinds of mappings
(for example the preferred email address may be at ``project.org''
despite the repository host being named ``cvs.project.org''), and some
VC systems have full separation between the concept of a user and that
of an account on the repository host (like Perforce). Some systems
(like Arch) put a full contact email address in every change.

To convert these names to addresses, the MailNotifier uses an EmailLookup
object. This provides a .getAddress method which accepts a name and
(eventually) returns an address. The default @code{MailNotifier}
module provides an EmailLookup which simply appends a static string,
configurable when the notifier is created. To create more complex behaviors
(perhaps using an LDAP lookup, or using ``finger'' on a central host to
determine a preferred address for the developer), provide a different object
as the @code{lookup} argument.

In the future, when the Problem mechanism has been set up, the Buildbot
will need to send mail to arbitrary Users. It will do this by locating a
MailNotifier-like object among all the buildmaster's status targets, and
asking it to send messages to various Users. This means the User-to-address
mapping only has to be set up once, in your MailNotifier, and every email
message the buildbot emits will take advantage of it.

@node IRC Nicknames, Live Status Clients, Email Addresses, Users
@subsection IRC Nicknames

Like MailNotifier, the @code{buildbot.status.words.IRC} class
provides a status target which can announce the results of each build. It
also provides an interactive interface by responding to online queries
posted in the channel or sent as private messages.

In the future, the buildbot can be configured map User names to IRC
nicknames, to watch for the recent presence of these nicknames, and to
deliver build status messages to the interested parties. Like
@code{MailNotifier} does for email addresses, the @code{IRC} object
will have an @code{IRCLookup} which is responsible for nicknames. The
mapping can be set up statically, or it can be updated by online users
themselves (by claiming a username with some kind of ``buildbot: i am
user warner'' commands).

Once the mapping is established, the rest of the buildbot can ask the
@code{IRC} object to send messages to various users. It can report on
the likelihood that the user saw the given message (based upon how long the
user has been inactive on the channel), which might prompt the Problem
Hassler logic to send them an email message instead.

@node Live Status Clients,  , IRC Nicknames, Users
@subsection Live Status Clients

The Buildbot also offers a PB-based status client interface which can
display real-time build status in a GUI panel on the developer's desktop.
This interface is normally anonymous, but it could be configured to let the
buildmaster know @emph{which} developer is using the status client. The
status client could then be used as a message-delivery service, providing an
alternative way to deliver low-latency high-interruption messages to the
developer (like ``hey, you broke the build'').


@node Configuration, Getting Source Code Changes, Concepts, Top
@chapter Configuration

@cindex Configuration

The buildbot's behavior is defined by the ``config file'', which
normally lives in the @file{master.cfg} file in the buildmaster's base
directory (but this can be changed with an option to the
@code{buildbot master} command). This file completely specifies which
Builders are to be run, which slaves they should use, how Changes
should be tracked, and where the status information is to be sent. The
buildmaster's @file{buildbot.tac} file names the base directory;
everything else comes from the config file.

A sample config file was installed for you when you created the
buildmaster, but you will need to edit it before your buildbot will do
anything useful.

This chapter gives an overview of the format of this file and the
various sections in it. You will need to read the later chapters to
understand how to fill in each section properly.

@menu
* Config File Format::          
* Loading the Config File::     
* Defining the Project::        
* Listing Change Sources and Schedulers::  
* Setting the slaveport::       
* Buildslave Specifiers::       
* Defining Builders::           
* Defining Status Targets::     
* Debug options::               
@end menu

@node Config File Format, Loading the Config File, Configuration, Configuration
@section Config File Format

The config file is, fundamentally, just a piece of Python code which
defines a dictionary named @code{BuildmasterConfig}, with a number of
keys that are treated specially. You don't need to know Python to do
basic configuration, though, you can just copy the syntax of the
sample file. If you @emph{are} comfortable writing Python code,
however, you can use all the power of a full programming language to
achieve more complicated configurations.

The @code{BuildmasterConfig} name is the only one which matters: all
other names defined during the execution of the file are discarded.
When parsing the config file, the Buildmaster generally compares the
old configuration with the new one and performs the minimum set of
actions necessary to bring the buildbot up to date: Builders which are
not changed are left untouched, and Builders which are modified get to
keep their old event history.

Basic Python syntax: comments start with a hash character (``#''),
tuples are defined with @code{(parenthesis, pairs)}, arrays are
defined with @code{[square, brackets]}, tuples and arrays are mostly
interchangeable. Dictionaries (data structures which map ``keys'' to
``values'') are defined with curly braces: @code{@{'key1': 'value1',
'key2': 'value2'@} }. Function calls (and object instantiation) can use
named parameters, like @code{w = html.Waterfall(http_port=8010)}.

The config file starts with a series of @code{import} statements,
which make various kinds of Steps and Status targets available for
later use. The main @code{BuildmasterConfig} dictionary is created,
then it is populated with a variety of keys. These keys are broken
roughly into the following sections, each of which is documented in
the rest of this chapter:

@itemize @bullet
@item
Project Definitions
@item
Change Sources / Schedulers
@item
Slaveport
@item
Buildslave Configuration
@item
Builders / Interlocks
@item
Status Targets
@item
Debug options
@end itemize

The config file can use a few names which are placed into its namespace:

@table @code
@item basedir
the base directory for the buildmaster. This string has not been
expanded, so it may start with a tilde. It needs to be expanded before
use. The config file is located in
@code{os.path.expanduser(os.path.join(basedir, 'master.cfg'))}

@end table


@node Loading the Config File, Defining the Project, Config File Format, Configuration
@section Loading the Config File

The config file is only read at specific points in time. It is first
read when the buildmaster is launched. Once it is running, there are
various ways to ask it to reload the config file. If you are on the
system hosting the buildmaster, you can send a @code{SIGHUP} signal to
it: the @command{buildbot} tool has a shortcut for this:

@example
buildbot sighup @var{BASEDIR}
@end example

The debug tool (@code{buildbot debugclient --master HOST:PORT}) has a
``Reload .cfg'' button which will also trigger a reload. In the
future, there will be other ways to accomplish this step (probably a
password-protected button on the web page, as well as a privileged IRC
command).


@node Defining the Project, Listing Change Sources and Schedulers, Loading the Config File, Configuration
@section Defining the Project

There are a couple of basic settings that you use to tell the buildbot
what project it is working on. This information is used by status
reporters to let users find out more about the codebase being
exercised by this particular Buildbot installation.

@example
c['projectName'] = "Buildbot"
c['projectURL'] = "http://buildbot.sourceforge.net/"
c['buildbotURL'] = "http://localhost:8010/"
@end example

@cindex c['projectName']
@code{projectName} is a short string will be used to describe the
project that this buildbot is working on. For example, it is used as
the title of the waterfall HTML page. 

@cindex c['projectURL']
@code{projectURL} is a string that gives a URL for the project as a
whole. HTML status displays will show @code{projectName} as a link to
@code{projectURL}, to provide a link from buildbot HTML pages to your
project's home page.

@cindex c['buildbotURL']
The @code{buildbotURL} string should point to the location where the
buildbot's internal web server (usually the @code{html.Waterfall}
page) is visible. This typically uses the port number set when you
create the @code{Waterfall} object: the buildbot needs your help to
figure out a suitable externally-visible host name.

When status notices are sent to users (either by email or over IRC),
@code{buildbotURL} will be used to create a URL to the specific build
or problem that they are being notified about. It will also be made
available to queriers (over IRC) who want to find out where to get
more information about this buildbot.


@node Listing Change Sources and Schedulers, Setting the slaveport, Defining the Project, Configuration
@section Listing Change Sources and Schedulers

@cindex c['sources']
The @code{c['sources']} key is a list of ChangeSource
instances@footnote{To be precise, it is a list of objects which all
implement the @code{buildbot.interfaces.IChangeSource} Interface}.
This defines how the buildmaster learns about source code changes.
More information about what goes here is available in @xref{Getting
Source Code Changes}.

@example
import buildbot.changes.pb
c['sources'] = [buildbot.changes.pb.PBChangeSource()]
@end example

@cindex c['schedulers']
@code{c['schedulers']} is a list of Scheduler instances, each of which
causes builds to be started on a particular set of Builders. The two
basic Scheduler classes you are likely to start with are
@code{Scheduler} and @code{Periodic}, but you can write a customized
subclass to implement more complicated build scheduling.

The docstring for @code{buildbot.scheduler.Scheduler} is the best
place to see all the options that can be used. Type @code{pydoc
buildbot.scheduler.Scheduler} to see it, or look in
@file{buildbot/scheduler.py} directly.

The basic Scheduler takes four arguments:

@table @code
@item name
Each Scheduler must have a unique name. This is only used in status
displays.

@item branch
This Scheduler will pay attention to a single branch, ignoring Changes
that occur on other branches. Setting @code{branch} equal to the
special value of @code{None} means it should only pay attention to the
default branch. Note that @code{None} is a keyword, not a string, so
you want to use @code{None} and not @code{"None"}.

@item treeStableTimer
The Scheduler will wait for this many seconds before starting the
build. If new changes are made during this interval, the timer will be
restarted, so really the build will be started after a change and then
after this many seconds of inactivity.

@item builderNames
When the tree-stable-timer finally expires, builds will be started on
these Builders. Each Builder gets a unique name: these strings must
match.

@end table

@example
from buildbot import scheduler
quick = scheduler.Scheduler("quick", None, 60,
                            ["quick-linux", "quick-netbsd"])
full = scheduler.Scheduler("full", None, 5*60,
                           ["full-linux", "full-netbsd", "full-OSX"])
nightly = scheduler.Periodic("nightly", ["full-solaris"], 24*60*60)
c['schedulers'] = [quick, full, nightly]
@end example

In this example, the two ``quick'' builds are triggered 60 seconds
after the tree has been changed. The ``full'' builds do not run quite
so quickly (they wait 5 minutes), so hopefully if the quick builds
fail due to a missing file or really simple typo, the developer can
discover and fix the problem before the full builds are started. Both
Schedulers only pay attention to the default branch: any changes on
other branches are ignored by these Schedulers. Each Scheduler
triggers a different set of Builders, referenced by name.

The third Scheduler in this example just runs the full solaris build
once per day. (note that this Scheduler only lets you control the time
between builds, not the absolute time-of-day of each Build, so this
could easily wind up a ``daily'' or ``every afternoon'' scheduler
depending upon when it was first activated).

@menu
* Scheduler Types::             
* Build Dependencies::          
@end menu

@node Scheduler Types, Build Dependencies, Listing Change Sources and Schedulers, Listing Change Sources and Schedulers
@subsection Scheduler Types

Here is a brief catalog of the available Scheduler types. All these
Schedulers are classes in @code{buildbot.scheduler}, and the
docstrings there are the best source of documentation on the arguments
taken by each one.

@table @code
@item Scheduler
This is the default Scheduler class. It follows exactly one branch,
and starts a configurable tree-stable-timer after each change on that
branch. When the timer expires, it starts a build on some set of
Builders. The Scheduler accepts a @code{fileIsImportant} function
which can be used to ignore some Changes if they do not affect any
``important'' files.

@item AnyBranchScheduler
This scheduler uses a tree-stable-timer like the default one, but
follows multiple branches at once. Each branch gets a separate timer.

@item Dependent
This scheduler watches an ``upstream'' Builder. When that Builder
successfully builds a particular set of Changes, it triggers builds of
the same code on a configured set of ``downstream'' builders. The next
section (@pxref{Build Dependencies}) describes this scheduler in more
detail.

@item Periodic
This simple scheduler just triggers a build every N seconds.

@item Nightly
This is highly configurable periodic build scheduler, which triggers a
build at particular times of day, week, month, or year. The
configuration syntax is very similar to the well-known @code{crontab}
format, in which you provide values for minute, hour, day, and month
(some of which can be wildcards), and a build is triggered whenever
the current time matches the given constraints. This can run a build
every night, every morning, every weekend, alternate Thursdays, on
your boss's birthday, etc.

@item Try_Jobdir / Try_Userpass
This scheduler allows developers to use the @code{buildbot try}
command to trigger builds of code they have not yet committed. See
@ref{try} for complete details.

@end table

@node Build Dependencies,  , Scheduler Types, Listing Change Sources and Schedulers
@subsection Build Dependencies

@cindex Dependent
@cindex Dependencies

It is common to wind up with one kind of build which should only be
performed if the same source code was successfully handled by some
other kind of build first. An example might be a packaging step: you
might only want to produce .deb or RPM packages from a tree that was
known to compile successfully and pass all unit tests. You could put
the packaging step in the same Build as the compile and testing steps,
but there might be other reasons to not do this (in particular you
might have several Builders worth of compiles/tests, but only wish to
do the packaging once). Another example is if you want to skip the
``full'' builds after a failing ``quick'' build of the same source
code. Or, if one Build creates a product (like a compiled library)
that is used by some other Builder, you'd want to make sure the
consuming Build is run @emph{after} the producing one.

You can use @code{Dependencies} to express this relationship to the
Buildbot. There is a special kind of Scheduler named
@code{scheduler.Dependent} that will watch an ``upstream'' Scheduler
for builds to complete successfully (on all of its Builders). Each
time that happens, the same source code (i.e. the same
@code{SourceStamp}) will be used to start a new set of builds, on a
different set of Builders. This ``downstream'' scheduler doesn't pay
attention to Changes at all, it only pays attention to the upstream
scheduler.

If the SourceStamp fails on any of the Builders in the upstream set,
the downstream builds will not fire.

@example
from buildbot import scheduler
tests = scheduler.Scheduler("tests", None, 5*60,
                            ["full-linux", "full-netbsd", "full-OSX"])
package = scheduler.Dependent("package",
                              tests, # upstream scheduler
                              ["make-tarball", "make-deb", "make-rpm"])
c['schedulers'] = [tests, package]
@end example

Note that @code{Dependent}'s upstream scheduler argument is given as a
@code{Scheduler} @emph{instance}, not a name. This makes it impossible
to create circular dependencies in the config file.


@node Setting the slaveport, Buildslave Specifiers, Listing Change Sources and Schedulers, Configuration
@section Setting the slaveport

@cindex c['slavePortnum']

The buildmaster will listen on a TCP port of your choosing for
connections from buildslaves. It can also use this port for
connections from remote Change Sources, status clients, and debug
tools. This port should be visible to the outside world, and you'll
need to tell your buildslave admins about your choice.

It does not matter which port you pick, as long it is externally
visible, however you should probably use something larger than 1024,
since most operating systems don't allow non-root processes to bind to
low-numbered ports. If your buildmaster is behind a firewall or a NAT
box of some sort, you may have to configure your firewall to permit
inbound connections to this port.

@example
c['slavePortnum'] = 10000
@end example

@code{c['slavePortnum']} is a @emph{strports} specification string,
defined in the @code{twisted.application.strports} module (try
@command{pydoc twisted.application.strports} to get documentation on
the format). This means that you can have the buildmaster listen on a
localhost-only port by doing:

@example
c['slavePortnum'] = "tcp:10000:interface=127.0.0.1"
@end example

This might be useful if you only run buildslaves on the same machine,
and they are all configured to contact the buildmaster at
@code{localhost:10000}.


@node Buildslave Specifiers, Defining Builders, Setting the slaveport, Configuration
@section Buildslave Specifiers

@cindex c['bots']

The @code{c['bots']} key is a list of known buildslaves. Each
buildslave is defined by a tuple of (slavename, slavepassword). These
are the same two values that need to be provided to the buildslave
administrator when they create the buildslave.

@example
c['bots'] = [('bot-solaris', 'solarispasswd'),
             ('bot-bsd', 'bsdpasswd'),
            ]
@end example

The slavenames must be unique, of course. The password exists to
prevent evildoers from interfering with the buildbot by inserting
their own (broken) buildslaves into the system and thus displacing the
real ones.

Buildslaves with an unrecognized slavename or a non-matching password
will be rejected when they attempt to connect, and a message
describing the problem will be put in the log file (see @ref{Logfiles}).


@node Defining Builders, Defining Status Targets, Buildslave Specifiers, Configuration
@section Defining Builders

@cindex c['builders']

The @code{c['builders']} key is a list of dictionaries which specify
the Builders. The Buildmaster runs a collection of Builders, each of
which handles a single type of build (e.g. full versus quick), on a
single build slave. A Buildbot which makes sure that the latest code
(``HEAD'') compiles correctly across four separate architecture will
have four Builders, each performing the same build but on different
slaves (one per platform).

Each Builder gets a separate column in the waterfall display. In
general, each Builder runs independently (although various kinds of
interlocks can cause one Builder to have an effect on another).

Each Builder specification dictionary has several required keys:

@table @code
@item name
This specifies the Builder's name, which is used in status
reports.

@item slavename
This specifies which buildslave will be used by this Builder.
@code{slavename} must appear in the @code{c['bots']} list. Each
buildslave can accomodate multiple Builders.

@item slavenames
If you provide @code{slavenames} instead of @code{slavename}, you can
give a list of buildslaves which are capable of running this Builder.
If multiple buildslaves are available for any given Builder, you will
have some measure of redundancy: in case one slave goes offline, the
others can still keep the Builder working. In addition, multiple
buildslaves will allow multiple simultaneous builds for the same
Builder, which might be useful if you have a lot of forced or ``try''
builds taking place.

If you use this feature, it is important to make sure that the
buildslaves are all, in fact, capable of running the given build. The
slave hosts should be configured similarly, otherwise you will spend a
lot of time trying (unsuccessfully) to reproduce a failure that only
occurs on some of the buildslaves and not the others. Different
platforms, operating systems, versions of major programs or libraries,
all these things mean you should use separate Builders.

@item builddir
This specifies the name of a subdirectory (under the base directory)
in which everything related to this builder will be placed. On the
buildmaster, this holds build status information. On the buildslave,
this is where checkouts, compiles, and tests are run.

@item factory
This is a @code{buildbot.process.factory.BuildFactory} instance which
controls how the build is performed. Full details appear in their own
chapter, @xref{Build Process}. Parameters like the location of the CVS
repository and the compile-time options used for the build are
generally provided as arguments to the factory's constructor.

@end table

Other optional keys may be set on each Builder:

@table @code

@item category
If provided, this is a string that identifies a category for the
builder to be a part of. Status clients can limit themselves to a
subset of the available categories. A common use for this is to add
new builders to your setup (for a new module, or for a new buildslave)
that do not work correctly yet and allow you to integrate them with
the active builders. You can put these new builders in a test
category, make your main status clients ignore them, and have only
private status clients pick them up. As soon as they work, you can
move them over to the active category.

@end table


@node Defining Status Targets, Debug options, Defining Builders, Configuration
@section Defining Status Targets

The Buildmaster has a variety of ways to present build status to
various users. Each such delivery method is a ``Status Target'' object
in the configuration's @code{status} list. To add status targets, you
just append more objects to this list:

@cindex c['status']

@example
c['status'] = []

from buildbot.status import html
c['status'].append(html.Waterfall(http_port=8010))

from buildbot.status import mail
m = mail.MailNotifier(fromaddr="buildbot@@localhost",
                      extraRecipients=["builds@@lists.example.com"],
                      sendToInterestedUsers=False)
c['status'].append(m)

from buildbot.status import words
c['status'].append(words.IRC(host="irc.example.com", nick="bb",
                             channels=["#example"]))
@end example

Status delivery has its own chapter, @xref{Status Delivery}, in which
all the built-in status targets are documented.


@node Debug options,  , Defining Status Targets, Configuration
@section Debug options


@cindex c['debugPassword']
If you set @code{c['debugPassword']}, then you can connect to the
buildmaster with the diagnostic tool launched by @code{buildbot
debugclient MASTER:PORT}. From this tool, you can reload the config
file, manually force builds, and inject changes, which may be useful
for testing your buildmaster without actually commiting changes to
your repository (or before you have the Change Sources set up). The
debug tool uses the same port number as the slaves do:
@code{c['slavePortnum']}, and is authenticated with this password.

@example
c['debugPassword'] = "debugpassword"
@end example

@cindex c['manhole']
If you set @code{c['manhole']} to an instance of the
@code{buildbot.master.Manhole} class, you can telnet into the
buildmaster and get an interactive Python shell, which may be useful
for debugging buildbot internals. It is probably only useful for
buildbot developers. It exposes full access to the buildmaster's
account (including the ability to modify and delete files), so it
should not be enabled with a weak or easily guessable password.

The @code{Manhole} instance can be configured to listen on a specific
port. You may wish to have this listening port bind to the loopback
interface (sometimes known as ``lo0'', ``localhost'', or 127.0.0.1) to
restrict access to clients which are running on the same host.

@example
from buildbot.master import Manhole
c['manhole'] = Manhole("tcp:9999:interface=127.0.0.1", "admin", "password")
@end example

To have the @code{Manhole} listen on all interfaces, use
@code{"tcp:9999"}. This port specification uses
@code{twisted.application.strports}, so you can make it listen on SSL
or even UNIX-domain sockets if you want.


@node Getting Source Code Changes, Build Process, Configuration, Top
@chapter Getting Source Code Changes

The most common way to use the Buildbot is centered around the idea of
@code{Source Trees}: a directory tree filled with source code of some form
which can be compiled and/or tested. Some projects use languages that don't
involve any compilation step: nevertheless there may be a @code{build} phase
where files are copied or rearranged into a form that is suitable for
installation. Some projects do not have unit tests, and the Buildbot is
merely helping to make sure that the sources can compile correctly. But in
all of these cases, the thing-being-tested is a single source tree.

A Version Control System mantains a source tree, and tells the
buildmaster when it changes. The first step of each Build is typically
to acquire a copy of some version of this tree.

This chapter describes how the Buildbot learns about what Changes have
occurred. For more information on VC systems and Changes, see
@ref{Version Control Systems}.


@menu
* Change Sources::              
@end menu



@node Change Sources,  , Getting Source Code Changes, Getting Source Code Changes
@section Change Sources

@c TODO: rework this, the one-buildmaster-one-tree thing isn't quite
@c so narrow-minded anymore

Each Buildmaster watches a single source tree. Changes can be provided
by a variety of ChangeSource types, however any given project will
typically have only a single ChangeSource active. This section
provides a description of all available ChangeSource types and
explains how to set up each of them.

There are a variety of ChangeSources available, some of which are
meant to be used in conjunction with other tools to deliver Change
events from the VC repository to the buildmaster.

@itemize @bullet

@item CVSToys
This ChangeSource opens a TCP connection from the buildmaster to a
waiting FreshCVS daemon that lives on the repository machine, and
subscribes to hear about Changes.

@item MaildirSource
This one watches a local maildir-format inbox for email sent out by
the repository when a change is made. When a message arrives, it is
parsed to create the Change object. A variety of parsing functions are
available to accomodate different email-sending tools.

@item PBChangeSource
This ChangeSource listens on a local TCP socket for inbound
connections from a separate tool. Usually, this tool would be run on
the VC repository machine in a commit hook. It is expected to connect
to the TCP socket and send a Change message over the network
connection. The @command{buildbot sendchange} command is one example
of a tool that knows how to send these messages, so you can write a
commit script for your VC system that calls it to deliver the Change.
There are other tools in the contrib/ directory that use the same
protocol.

@end itemize

As a quick guide, here is a list of VC systems and the ChangeSources
that might be useful with them. All of these ChangeSources are in the
@code{buildbot.changes} module.

@table @code
@item CVS

@itemize @bullet
@item freshcvs.FreshCVSSource (connected via TCP to the freshcvs daemon)
@item mail.FCMaildirSource (watching for email sent by a freshcvs daemon)
@item mail.BonsaiMaildirSource (watching for email sent by Bonsai)
@item mail.SyncmailMaildirSource (watching for email sent by syncmail)
@item pb.PBChangeSource (listening for connections from @code{buildbot
sendchange} run in a loginfo script)
@item pb.PBChangeSource (listening for connections from a long-running
@code{contrib/viewcvspoll.py} polling process which examines the ViewCVS
database directly
@end itemize

@item SVN
@itemize @bullet
@item pb.PBChangeSource (listening for connections from
@code{contrib/svn_buildbot.py} run in a postcommit script)
@item pb.PBChangeSource (listening for connections from a long-running
@code{contrib/svn_watcher.py} or @code{contrib/svnpoller.py} polling
process
@end itemize

@item Darcs
@itemize @bullet
@item pb.PBChangeSource (listening for connections from @code{buildbot
sendchange} in a commit script
@end itemize

@item Mercurial
@itemize @bullet
@item pb.PBChangeSource (listening for connections from
@code{contrib/hg_buildbot.py} run in an 'incoming' hook)
@end itemize

@item Arch/Bazaar
@itemize @bullet
@item pb.PBChangeSource (listening for connections from
@code{contrib/arch_buildbot.py} run in a commit hook)
@end itemize

@end table

All VC systems can be driven by a PBChangeSource and the
@code{buildbot sendchange} tool run from some form of commit script.
If you write an email parsing function, they can also all be driven by
a suitable @code{MaildirSource}.


@menu
* Choosing ChangeSources::      
* CVSToys - PBService::         
* CVSToys - mail notification::  
* Other mail notification ChangeSources::  
* PBChangeSource::              
@end menu

@node Choosing ChangeSources, CVSToys - PBService, Change Sources, Change Sources
@subsection Choosing ChangeSources

The @code{master.cfg} configuration file has a dictionary key named
@code{BuildmasterConfig['sources']}, which holds a list of
@code{IChangeSource} objects. The config file will typically create an
object from one of the classes described below and stuff it into the
list.

@example
s = FreshCVSSourceNewcred(host="host", port=4519,
                          user="alice", passwd="secret",
                          prefix="Twisted")
BuildmasterConfig['sources'] = [s]
@end example

Each source tree has a nominal @code{top}. Each Change has a list of
filenames, which are all relative to this top location. The
ChangeSource is responsible for doing whatever is necessary to
accomplish this. Most sources have a @code{prefix} argument: a partial
pathname which is stripped from the front of all filenames provided to
that @code{ChangeSource}. Files which are outside this sub-tree are
ignored by the changesource: it does not generate Changes for those
files.


@node CVSToys - PBService, CVSToys - mail notification, Choosing ChangeSources, Change Sources
@subsection CVSToys - PBService

The @uref{http://purl.net/net/CVSToys, CVSToys} package provides a
server which runs on the machine that hosts the CVS repository it
watches. It has a variety of ways to distribute commit notifications,
and offers a flexible regexp-based way to filter out uninteresting
changes. One of the notification options is named @code{PBService} and
works by listening on a TCP port for clients. These clients subscribe
to hear about commit notifications.

The buildmaster has a CVSToys-compatible @code{PBService} client built
in. There are two versions of it, one for old versions of CVSToys
(1.0.9 and earlier) which used the @code{oldcred} authentication
framework, and one for newer versions (1.0.10 and later) which use
@code{newcred}. Both are classes in the
@code{buildbot.changes.freshcvs} package.

@code{FreshCVSSourceNewcred} objects are created with the following
parameters:

@table @samp

@item @code{host} and @code{port}
these specify where the CVSToys server can be reached

@item @code{user} and @code{passwd}
these specify the login information for the CVSToys server
(@code{freshcvs}). These must match the server's values, which are
defined in the @code{freshCfg} configuration file (which lives in the
CVSROOT directory of the repository).

@item @code{prefix}
this is the prefix to be found and stripped from filenames delivered
by the CVSToys server. Most projects live in sub-directories of the
main repository, as siblings of the CVSROOT sub-directory, so
typically this prefix is set to that top sub-directory name.

@end table

@heading Example

To set up the freshCVS server, add a statement like the following to
your @file{freshCfg} file:

@example
pb = ConfigurationSet([
    (None, None, None, PBService(userpass=('foo', 'bar'), port=4519)),
    ])
@end example

This will announce all changes to a client which connects to port 4519
using a username of 'foo' and a password of 'bar'.

Then add a clause like this to your buildmaster's @file{master.cfg}:

@example
BuildmasterConfig['sources'] = [FreshCVSSource("cvs.example.com", 4519,
                                "foo", "bar",
                                prefix="glib/")]
@end example

where "cvs.example.com" is the host that is running the FreshCVS daemon, and
"glib" is the top-level directory (relative to the repository's root) where
all your source code lives. Most projects keep one or more projects in the
same repository (along with CVSROOT/ to hold admin files like loginfo and
freshCfg); the prefix= argument tells the buildmaster to ignore everything
outside that directory, and to strip that common prefix from all pathnames
it handles.



@node CVSToys - mail notification, Other mail notification ChangeSources, CVSToys - PBService, Change Sources
@subsection CVSToys - mail notification

CVSToys also provides a @code{MailNotification} action which will send
email to a list of recipients for each commit. This tends to work
better than using @code{/bin/mail} from within the CVSROOT/loginfo
file directly, as CVSToys will batch together all files changed during
the same CVS invocation, and can provide more information (like
creating a ViewCVS URL for each file changed).

The Buildbot's @code{FCMaildirSource} is a ChangeSource which knows
how to parse these CVSToys messages and turn them into Change objects.
It watches a Maildir for new messages. The usually installation
process looks like:

@enumerate
@item
Create a mailing list, @code{projectname-commits}.
@item
In CVSToys' freshCfg file, use a @code{MailNotification} action to
send commit mail to this mailing list.
@item
Subscribe the buildbot user to the mailing list.
@item
Configure your .qmail or .forward file to deliver these messages into
a maildir.
@item
In the Buildbot's master.cfg file, use a @code{FCMaildirSource} to
watch the maildir for commit messages.
@end enumerate

The @code{FCMaildirSource} is created with two parameters: the
directory name of the maildir root, and the prefix to strip.

@node Other mail notification ChangeSources, PBChangeSource, CVSToys - mail notification, Change Sources
@subsection Other mail notification ChangeSources

There are other types of maildir-watching ChangeSources, which only
differ in the function used to parse the message body.

@code{SyncmailMaildirSource} knows how to parse the message format
used in mail sent by Syncmail.

@code{BonsaiMaildirSource} parses messages sent out by Bonsai.

@node PBChangeSource,  , Other mail notification ChangeSources, Change Sources
@subsection PBChangeSource

The last kind of ChangeSource actually listens on a TCP port for
clients to connect and push change notices @emph{into} the
Buildmaster. This is used by the built-in @code{buildbot sendchange}
notification tool, as well as the VC-specific
@file{contrib/svn_buildbot.py} and @file{contrib/arch_buildbot.py}
tools. These tools are run by the repository (in a commit hook
script), and connect to the buildmaster directly each time a file is
comitted. This is also useful for creating new kinds of change sources
that work on a @code{push} model instead of some kind of subscription
scheme, for example a script which is run out of an email .forward
file.

This ChangeSource can be configured to listen on its own TCP port, or
it can share the port that the buildmaster is already using for the
buildslaves to connect. (This is possible because the
@code{PBChangeSource} uses the same protocol as the buildslaves, and
they can be distinguished by the @code{username} attribute used when
the initial connection is established). It might be useful to have it
listen on a different port if, for example, you wanted to establish
different firewall rules for that port. You could allow only the SVN
repository machine access to the @code{PBChangeSource} port, while
allowing only the buildslave machines access to the slave port. Or you
could just expose one port and run everything over it. @emph{Note:
this feature is not yet implemented, the PBChangeSource will always
share the slave port and will always have a @code{user} name of
@code{change}, and a passwd of @code{changepw}. These limitations will
be removed in the future.}.


The @code{PBChangeSource} is created with the following
arguments:

@table @samp
@item @code{port}
which port to listen on. If @code{None} (which is the default), it
shares the port used for buildslave connections. @emph{Not
Implemented, always set to @code{None}}.

@item @code{user} and @code{passwd}
the user/passwd account information that the client program must use
to connect. Defaults to @code{change} and @code{changepw}. @emph{Not
Implemented, @code{user} is currently always set to @code{change},
@code{passwd} is always set to @code{changepw}}.

@item @code{prefix}
the prefix to be found and stripped from filenames delivered over the
connection.
@end table


@node Build Process, Status Delivery, Getting Source Code Changes, Top
@chapter Build Process

A @code{Build} object is responsible for actually performing a build.
It gets access to a remote @code{SlaveBuilder} where it may run
commands, and a @code{BuildStatus} object where it must emit status
events. The @code{Build} is created by the Builder's
@code{BuildFactory}.

The default @code{Build} class is made up of a fixed sequence of
@code{BuildSteps}, executed one after another until all are complete
(or one of them indicates that the build should be halted early). The
default @code{BuildFactory} creates instances of this @code{Build}
class with a list of @code{BuildSteps}, so the basic way to configure
the build is to provide a list of @code{BuildSteps} to your
@code{BuildFactory}.

More complicated @code{Build} subclasses can make other decisions:
execute some steps only if certain files were changed, or if certain
previous steps passed or failed. The base class has been written to
allow users to express basic control flow without writing code, but
you can always subclass and customize to achieve more specialized
behavior.

@menu
* Build Steps::                 
* Interlocks::                  
* Build Factories::             
@end menu

@node Build Steps, Interlocks, Build Process, Build Process
@section Build Steps

@code{BuildStep}s are usually specified in the buildmaster's
configuration file, in a list of ``step specifications'' that is used
to create the @code{BuildFactory}. These ``step specifications'' are
not actual steps, but rather a tuple of the @code{BuildStep} subclass
to be created and a dictionary of arguments. (the actual
@code{BuildStep} instances are not created until the Build is started,
so that each Build gets an independent copy of each BuildStep). There
is a convenience function named ``@code{s}'' in the
@code{buildbot.process.factory} module for creating these
specification tuples. It allows you to create a
@code{BuildFactory}-ready list like this:

@example
from buildbot.process import step, factory
from buildbot.process.factory import s

steps = [s(step.SVN, svnurl="http://svn.example.org/Trunk/"),
         s(step.ShellCommand, command=["make", "all"]),
         s(step.ShellCommand, command=["make", "test"]),
        ]
f = factory.BuildFactory(steps)
@end example

The rest of this section lists all the standard BuildStep objects
available for use in a Build, and the parameters which can be used to
control each.

@menu
* Common Parameters::           
* Source Checkout::             
* ShellCommand::                
* Simple ShellCommand Subclasses::  
@end menu

@node Common Parameters, Source Checkout, Build Steps, Build Steps
@subsection Common Parameters

The standard @code{Build} runs a series of @code{BuildStep}s in order,
only stopping when it runs out of steps or if one of them requests
that the build be halted. It collects status information from each one
to create an overall build status (of SUCCESS, WARNINGS, or FAILURE).

All BuildSteps accept some common parameters. Some of these control
how their individual status affects the overall build. Others are used
to specify which @code{Locks} (see @pxref{Interlocks}) should be
acquired before allowing the step to run.

Arguments common to all @code{BuildStep} subclasses:


@table @code
@item name
the name used to describe the step on the status display. It is also
used to give a name to any LogFiles created by this step.

@item haltOnFailure
if True, a FAILURE of this build step will cause the build to halt
immediately with an overall result of FAILURE.

@item flunkOnWarnings
when True, a WARNINGS or FAILURE of this build step will mark the
overall build as FAILURE. The remaining steps will still be executed.

@item flunkOnFailure
when True, a FAILURE of this build step will mark the overall build as
a FAILURE. The remaining steps will still be executed.

@item warnOnWarnings
when True, a WARNINGS or FAILURE of this build step will mark the
overall build as having WARNINGS. The remaining steps will still be
executed.

@item warnOnFailure
when True, a FAILURE of this build step will mark the overall build as
having WARNINGS. The remaining steps will still be executed.

@item locks
a list of Locks (instances of @code{buildbot.locks.SlaveLock} or
@code{buildbot.locks.MasterLock}) that should be acquired before
starting this Step. The Locks will be released when the step is
complete. Note that this is a list of actual Lock instances, not
names. Also note that all Locks must have unique names.

@end table


@node Source Checkout, ShellCommand, Common Parameters, Build Steps
@subsection Source Checkout

The first step of any build is typically to acquire the source code
from which the build will be performed. There are several classes to
handle this, one for each of the different source control system that
Buildbot knows about. For a description of how Buildbot treats source
control in general, see @ref{Version Control Systems}.

All source checkout steps accept some common parameters to control how
they get the sources and where they should be placed. The remaining
per-VC-system parameters are mostly to specify where exactly the
sources are coming from.

@table @code
@item mode

a string describing the kind of VC operation that is desired. Defaults
to @code{update}.

@table @code
@item update
specifies that the CVS checkout/update should be performed directly
into the workdir. Each build is performed in the same directory,
allowing for incremental builds. This minimizes disk space, bandwidth,
and CPU time. However, it may encounter problems if the build process
does not handle dependencies properly (sometimes you must do a ``clean
build'' to make sure everything gets compiled), or if source files are
deleted but generated files can influence test behavior (e.g. python's
.pyc files), or when source directories are deleted but generated
files prevent CVS from removing them. Builds ought to be correct
regardless of whether they are done ``from scratch'' or incrementally,
but it is useful to test both kinds: this mode exercises the
incremental-build style.

@item copy
specifies that the CVS workspace should be maintained in a separate
directory (called the 'copydir'), using checkout or update as
necessary. For each build, a new workdir is created with a copy of the
source tree (rm -rf workdir; cp -r copydir workdir). This doubles the
disk space required, but keeps the bandwidth low (update instead of a
full checkout). A full 'clean' build is performed each time. This
avoids any generated-file build problems, but is still occasionally
vulnerable to CVS problems such as a repository being manually
rearranged, causing CVS errors on update which are not an issue with a
full checkout.

@c TODO: something is screwy about this, revisit. Is it the source
@c directory or the working directory that is deleted each time?

@item clobber
specifes that the working directory should be deleted each time,
necessitating a full checkout for each build. This insures a clean
build off a complete checkout, avoiding any of the problems described
above. This mode exercises the ``from-scratch'' build style.

@item export
this is like @code{clobber}, except that the 'cvs export' command is
used to create the working directory. This command removes all CVS
metadata files (the CVS/ directories) from the tree, which is
sometimes useful for creating source tarballs (to avoid including the
metadata in the tar file).
@end table

@item workdir
like all Steps, this indicates the directory where the build will take
place. Source Steps are special in that they perform some operations
outside of the workdir (like creating the workdir itself).

@item alwaysUseLatest
if True, bypass the usual ``update to the last Change'' behavior, and
always update to the latest changes instead.

@item retry
If set, this specifies a tuple of @code{(delay, repeats)} which means
that when a full VC checkout fails, it should be retried up to
@var{repeats} times, waiting @var{delay} seconds between attempts. If
you don't provide this, it defaults to @code{None}, which means VC
operations should not be retried. This is provided to make life easier
for buildslaves which are stuck behind poor network connections.

@end table


My habit as a developer is to do a @code{cvs update} and @code{make} each
morning. Problems can occur, either because of bad code being checked in, or
by incomplete dependencies causing a partial rebuild to fail where a
complete from-scratch build might succeed. A quick Builder which emulates
this incremental-build behavior would use the @code{mode='update'}
setting.

On the other hand, other kinds of dependency problems can cause a clean
build to fail where a partial build might succeed. This frequently results
from a link step that depends upon an object file that was removed from a
later version of the tree: in the partial tree, the object file is still
around (even though the Makefiles no longer know how to create it).

``official'' builds (traceable builds performed from a known set of
source revisions) are always done as clean builds, to make sure it is
not influenced by any uncontrolled factors (like leftover files from a
previous build). A ``full'' Builder which behaves this way would want
to use the @code{mode='clobber'} setting.

Each VC system has a corresponding source checkout class: their
arguments are described on the following pages.


@menu
* CVS::                         
* SVN::                         
* Darcs::                       
* Mercurial::                   
* Arch::                        
* Bazaar::                      
* P4Sync::                      
@end menu

@node CVS, SVN, Source Checkout, Source Checkout
@subsubsection CVS

@cindex CVS Checkout

The @code{CVS} build step performs a @uref{http://www.nongnu.org/cvs/,
CVS} checkout or update. It takes the following arguments:

@table @code
@item cvsroot
(required): specify the CVSROOT value, which points to a CVS
repository, probably on a remote machine. For example, the cvsroot
value you would use to get a copy of the Buildbot source code is
@code{:pserver:anonymous@@cvs.sourceforge.net:/cvsroot/buildbot}

@item cvsmodule
(required): specify the cvs @code{module}, which is generally a
subdirectory of the CVSROOT. The cvsmodule for the Buildbot source
code is @code{buildbot}.

@item branch
a string which will be used in a @code{-r} argument. This is most
useful for specifying a branch to work on. Defaults to @code{HEAD}.

@item global_options
a list of flags to be put before the verb in the CVS command.

@item checkoutDelay
if set, the number of seconds to put between the timestamp of the last
known Change and the value used for the @code{-D} option. Defaults to
half of the parent Build's treeStableTimer.

@end table


@node SVN, Darcs, CVS, Source Checkout
@subsubsection SVN

@cindex SVN Checkout

The @code{SVN} build step performs a
@uref{http://subversion.tigris.org, Subversion} checkout or update.
There are two basic ways of setting up the checkout step, depending
upon whether you are using multiple branches or not.

If all of your builds use the same branch, then you should create the
@code{SVN} step with the @code{svnurl} argument:

@table @code
@item svnurl
(required): this specifies the @code{URL} argument that will be given
to the @code{svn checkout} command. It dictates both where the
repository is located and which sub-tree should be extracted. In this
respect, it is like a combination of the CVS @code{cvsroot} and
@code{cvsmodule} arguments. For example, if you are using a remote
Subversion repository which is accessible through HTTP at a URL of
@code{http://svn.example.com/repos}, and you wanted to check out the
@code{trunk/calc} sub-tree, you would use
@code{svnurl="http://svn.example.com/repos/trunk/calc"} as an argument
to your @code{SVN} step.
@end table

If, on the other hand, you are building from multiple branches, then
you should create the @code{SVN} step with the @code{baseURL} and
@code{defaultBranch} arguments instead:

@table @code
@item baseURL
(required): this specifies the base repository URL, to which a branch
name will be appended. It should probably end in a slash.

@item defaultBranch
this specifies the name of the branch to use when a Build does not
provide one of its own. This will be appended to @code{baseURL} to
create the string that will be passed to the @code{svn checkout}
command.
@end table

If you are using branches, you must also make sure your
@code{ChangeSource} will report the correct branch names.

@heading branch example

Let's suppose that the ``MyProject'' repository uses branches for the
trunk, for various users' individual development efforts, and for
several new features that will require some amount of work (involving
multiple developers) before they are ready to merge onto the trunk.
Such a repository might be organized as follows:

@example
svn://svn.example.org/MyProject/trunk
svn://svn.example.org/MyProject/branches/User1/foo
svn://svn.example.org/MyProject/branches/User1/bar
svn://svn.example.org/MyProject/branches/User2/baz
svn://svn.example.org/MyProject/features/newthing
svn://svn.example.org/MyProject/features/otherthing
@end example

Further assume that we want the Buildbot to run tests against the
trunk and against all the feature branches (i.e., do a
checkout/compile/build of branch X when a file has been changed on
branch X, when X is in the set [trunk, features/newthing,
features/otherthing]). We do not want the Buildbot to automatically
build any of the user branches, but it should be willing to build a
user branch when explicitly requested (most likely by the user who
owns that branch).

There are three things that need to be set up to accomodate this
system. The first is a ChangeSource that is capable of identifying the
branch which owns any given file. This depends upon a user-supplied
function, in an external program that runs in the SVN commit hook and
connects to the buildmaster's @code{PBChangeSource} over a TCP
connection. (you can use the ``@code{buildbot sendchange}'' utility
for this purpose, but you will still need an external program to
decide what value should be passed to the @code{--branch=} argument).
For example, a change to a file with the SVN url of
``svn://svn.example.org/MyProject/features/newthing/src/foo.c'' should
be broken down into a Change instance with
@code{branch='features/newthing'} and @code{file='src/foo.c'}.

The second piece is an @code{AnyBranchScheduler} which will pay
attention to the desired branches. It will not pay attention to the
user branches, so it will not automatically start builds in response
to changes there. The AnyBranchScheduler class requires you to
explicitly list all the branches you want it to use, but it would not
be difficult to write a subclass which used
@code{branch.startswith('features/'} to remove the need for this
explicit list. Or, if you want to build user branches too, you can use
AnyBranchScheduler with @code{branches=None} to indicate that you want
it to pay attention to all branches.

The third piece is an @code{SVN} checkout step that is configured to
handle the branches correctly, with a @code{baseURL} value that
matches the way the ChangeSource splits each file's URL into base,
branch, and file.

@example
from buildbot.changes.pb import PBChangeSource
from buildbot.scheduler import AnyBranchScheduler
from buildbot.process import step, factory
from buildbot.process.factory import s

c['sources'] = [PBChangeSource()]
s1 = AnyBranchScheduler('main',
                        ['trunk', 'features/newthing', 'features/otherthing'],
                        10*60, ['test-i386', 'test-ppc'])
c['schedulers'] = [s1]
source = s(step.SVN, mode='update',
           baseURL='svn://svn.example.org/MyProject/',
           defaultBranch='trunk')
f = factory.BuildFactory([source,
                          s(step.Compile, command="make all"),
                          s(step.Test, command="make test")])
c['builders'] = [
  @{'name':'test-i386', 'slavename':'bot-i386', 'builddir':'test-i386',
                       'factory':f @},
  @{'name':'test-ppc', 'slavename':'bot-ppc', 'builddir':'test-ppc',
                      'factory':f @},
 ]
@end example

In this example, when a change arrives with a @code{branch} attribute
of ``trunk'', the resulting build will have an SVN step that
concatenates ``svn://svn.example.org/MyProject/'' (the baseURL) with
``trunk'' (the branch name) to get the correct svn command. If the
``newthing'' branch has a change to ``src/foo.c'', then the SVN step
will concatenate ``svn://svn.example.org/MyProject/'' with
``features/newthing'' to get the svnurl for checkout.

@node Darcs, Mercurial, SVN, Source Checkout
@subsubsection Darcs

@cindex Darcs Checkout

The @code{Darcs} build step performs a
@uref{http://abridgegame.org/darcs/, Darcs} checkout or update.

Like @xref{SVN}, this step can either be configured to always check
out a specific tree, or set up to pull from a particular branch that
gets specified separately for each build. Also like SVN, the
repository URL given to Darcs is created by concatenating a
@code{baseURL} with the branch name, and if no particular branch is
requested, it uses a @code{defaultBranch}. The only difference in
usage is that each potential Darcs repository URL must point to a
fully-fledged repository, whereas SVN URLs usually point to sub-trees
of the main Subversion repository. In other words, doing an SVN
checkout of @code{baseURL} is legal, but silly, since you'd probably
wind up with a copy of every single branch in the whole repository.
Doing a Darcs checkout of @code{baseURL} is just plain wrong, since
the parent directory of a collection of Darcs repositories is not
itself a valid repository.

The Darcs step takes the following arguments:

@table @code
@item repourl
(required unless @code{baseURL} is provided): the URL at which the
Darcs source repository is available.

@item baseURL
(required unless @code{repourl} is provided): the base repository URL,
to which a branch name will be appended. It should probably end in a
slash.

@item defaultBranch
(allowed if and only if @code{baseURL} is provided): this specifies
the name of the branch to use when a Build does not provide one of its
own. This will be appended to @code{baseURL} to create the string that
will be passed to the @code{darcs get} command.
@end table

@node Mercurial, Arch, Darcs, Source Checkout
@subsubsection Mercurial

@cindex Mercurial Checkout

The @code{Mercurial} build step performs a
@uref{http://selenic.com/mercurial, Mercurial} (aka ``hg'') checkout
or update.

Branches are handled just like @xref{Darcs}.

The Mercurial step takes the following arguments:

@table @code
@item repourl
(required unless @code{baseURL} is provided): the URL at which the
Mercurial source repository is available.

@item baseURL
(required unless @code{repourl} is provided): the base repository URL,
to which a branch name will be appended. It should probably end in a
slash.

@item defaultBranch
(allowed if and only if @code{baseURL} is provided): this specifies
the name of the branch to use when a Build does not provide one of its
own. This will be appended to @code{baseURL} to create the string that
will be passed to the @code{hg clone} command.
@end table


@node Arch, Bazaar, Mercurial, Source Checkout
@subsubsection Arch

@cindex Arch Checkout

The @code{Arch} build step performs an @uref{http://gnuarch.org/,
Arch} checkout or update using the @code{tla} client. It takes the
following arguments:

@table @code
@item url
(required): this specifies the URL at which the Arch source archive is
available.

@item version
(required): this specifies which ``development line'' (like a branch)
should be used. This provides the default branch name, but individual
builds may specify a different one.

@item archive
(optional): Each repository knows its own archive name. If this
parameter is provided, it must match the repository's archive name.
The parameter is accepted for compatibility with the @code{Bazaar}
step, below.

@end table

@node Bazaar, P4Sync, Arch, Source Checkout
@subsubsection Bazaar

@cindex Bazaar Checkout

@code{Bazaar} is an alternate implementation of the Arch VC system,
which uses a client named @code{baz}. The checkout semantics are just
different enough from @code{tla} that there is a separate BuildStep for
it.

It takes exactly the same arguments as @code{Arch}, except that the
@code{archive=} parameter is required. (baz does not emit the archive
name when you do @code{baz register-archive}, so we must provide it
ourselves).


@node P4Sync,  , Bazaar, Source Checkout
@subsubsection P4Sync

@cindex Perforce Update

The @code{P4Sync} build step performs a
@uref{http://www.perforce.com/, Perforce} update. It is a temporary
facility: a more complete P4 checkout step (named @code{P4}) will
eventually replace it. This step requires significant manual setup on
each build slave. It takes the following arguments.

@table @code
@item p4port
(required): the host:port string describing how to get to the P4 Depot
(repository), used as the P4PORT environment variable for all p4
commands
@end table

@node ShellCommand, Simple ShellCommand Subclasses, Source Checkout, Build Steps
@subsection ShellCommand

This is a useful base class for just about everything you might want
to do during a build (except for the initial source checkout). It runs
a single command in a child shell on the buildslave. All stdout/stderr
is recorded into a LogFile. The step finishes with a status of FAILURE
if the command's exit code is non-zero, otherwise it has a status of
SUCCESS.

The preferred way to specify the command is with a list of argv strings,
since this allows for spaces in filenames and avoids doing any fragile
shell-escaping. You can also specify the command with a single string, in
which case the string is given to '/bin/sh -c COMMAND' for parsing.

All ShellCommands are run by default in the ``workdir'', which
defaults to the ``@file{build}'' subdirectory of the slave builder's
base directory. The absolute path of the workdir will thus be the
slave's basedir (set as an option to @code{buildbot slave},
@pxref{Creating a buildslave}) plus the builder's basedir (set in the
builder's @code{c['builddir']} key in master.cfg) plus the workdir
itself (a class-level attribute of the BuildFactory, defaults to
``@file{build}'').

@code{ShellCommand} arguments:

@table @code
@item command
a list of strings (preferred) or single string (discouraged) which
specifies the command to be run

@item env
a dictionary of environment strings which will be added to the child
command's environment.

@item want_stdout
if False, stdout from the child process is discarded rather than being
sent to the buildmaster for inclusion in the step's LogFile.

@item want_stderr
like @code{want_stdout} but for stderr. Note that commands run through
a PTY do not have separate stdout/stderr streams: both are merged into
stdout.

@item timeout
if the command fails to produce any output for this many seconds, it
is assumed to be locked up and will be killed.

@item description
This will be used to describe the command (on the Waterfall display)
while the command is still running. It should be a single
imperfect-tense verb, like ``compiling'' or ``testing''.

@item descriptionDone
This will be used to describe the command once it has finished. A
simple noun like ``compile'' or ``tests'' should be used.

If neither @code{description} nor @code{descriptionDone} are set, the
actual command arguments will be used to construct the description.
This may be a bit too wide to fit comfortably on the Waterfall
display.

@end table

@node Simple ShellCommand Subclasses,  , ShellCommand, Build Steps
@subsection Simple ShellCommand Subclasses

Several subclasses of ShellCommand are provided as starting points for
common build steps. These are all very simple: they just override a few
parameters so you don't have to specify them yourself, making the master.cfg
file less verbose.

@menu
* Configure::                   
* Compile::                     
* Test::                        
* Writing New BuildSteps::      
* Build Properties::            
@end menu

@node Configure, Compile, Simple ShellCommand Subclasses, Simple ShellCommand Subclasses
@subsubsection Configure

This is intended to handle the @code{./configure} step from
autoconf-style projects, or the @code{perl Makefile.PL} step from perl
MakeMaker.pm-style modules. The default command is @code{./configure}
but you can change this by providing a @code{command=} parameter.

@node Compile, Test, Configure, Simple ShellCommand Subclasses
@subsubsection Compile

This is meant to handle compiling or building a project written in C. The
default command is @code{make all}. When the compile is finished, the
log file is scanned for GCC error/warning messages and a summary log is
created with any problems that were seen (TODO: the summary is not yet
created).

@node Test, Writing New BuildSteps, Compile, Simple ShellCommand Subclasses
@subsubsection Test

This is meant to handle unit tests. The default command is @code{make
test}, and the @code{warnOnFailure} flag is set.





@node Writing New BuildSteps, Build Properties, Test, Simple ShellCommand Subclasses
@subsubsection Writing New BuildSteps

While it is a good idea to keep your build process self-contained in
the source code tree, sometimes it is convenient to put more
intelligence into your Buildbot configuration. One was to do this is
to write a custom BuildStep. Once written, this Step can be used in
the @file{master.cfg} file.

The best reason for writing a custom BuildStep is to better parse the
results of the command being run. For example, a BuildStep that knows
about JUnit could look at the logfiles to determine which tests had
been run, how many passed and how many failed, and then report more
detailed information than a simple @code{rc==0} -based ``good/bad''
decision.

TODO: add more description of BuildSteps.


@node Build Properties,  , Writing New BuildSteps, Simple ShellCommand Subclasses
@subsubsection Build Properties

@cindex build properties

Each build has a set of ``Build Properties'', which can be used by its
BuildStep to modify their actions. For example, the SVN revision
number of the source code being built is available as a build
property, and a ShellCommand step could incorporate this number into a
command which create a numbered release tarball.

Some build properties are set when the build starts, such as the
SourceStamp information. Other properties can be set by BuildSteps as
they run, for example the various Source steps will set the
@code{got_revision} property to the source revision that was actually
checked out (which can be useful when the SourceStamp in use merely
requested the ``latest revision'': @code{got_revision} will tell you
what was actually built).

In custom BuildSteps, you can get and set the build properties with
the @code{getProperty}/@code{setProperty} methods. Each takes a string
for the name of the property, and returns or accepts an
arbitrary@footnote{Build properties are serialized along with the
build results, so they must be serializable. For this reason, the
value of any build property should be simple inert data: strings,
numbers, lists, tuples, and dictionaries. They should not contain
class instances.} object. For example:

@example
class MakeTarball(step.ShellCommand):
    def start(self):
        self.setCommand(["tar", "czf",
                         "build-%s.tar.gz" % self.getProperty("revision"),
                         "source"])
        step.ShellCommand.start(self)
@end example

@cindex WithProperties

You can use build properties in ShellCommands by using the
@code{WithProperties} wrapper when setting the arguments of the
ShellCommand. This interpolates the named build properties into the
generated shell command.

@example
from buildbot.process.step import ShellCommand, WithProperties

s(ShellCommand,
  command=["tar", "czf",
           WithProperties("build-%s.tar.gz", "revision"),
           "source"],
 )
@end example

If this BuildStep were used in a tree obtained from Subversion, it
would create a tarball with a name like @file{build-1234.tar.gz}.

The @code{WithProperties} function does @code{printf}-style string
interpolation, using strings obtained by calling
@code{build.getProperty(propname)}. Note that for every @code{%s} (or
@code{%d}, etc), you must have exactly one additional argument to
indicate which build property you want to insert.


You can also use python dictionary-style string interpolation by using
the @code{%(propname)s} syntax. In this form, the property name goes
in the parentheses, and WithProperties takes @emph{no} additional
arguments:

@example
s(ShellCommand,
  command=["tar", "czf",
           WithProperties("build-%(revision)s.tar.gz"),
           "source"],
 )
@end example

Don't forget the extra ``s'' after the closing parenthesis! This is
the cause of many confusing errors.

Note that, like python, you can either do positional-argument
interpolation @emph{or} keyword-argument interpolation, not both. Thus
you cannot use a string like
@code{WithProperties("foo-%(revision)s-%s", "branch")}.

At the moment, the only way to set build properties is by writing a
custom BuildStep.

@heading Common Build Properties

The following build properties are set when the build is started, and
are available to all steps.

@table @code
@item branch

This comes from the build's SourceStamp, and describes which branch is
being checked out. This will be @code{None} (which interpolates into
@code{WithProperties} as an empty string) if the build is on the
default branch, which is generally the trunk. Otherwise it will be a
string like ``branches/beta1.4''. The exact syntax depends upon the VC
system being used.

@item revision

This also comes from the SourceStamp, and is the revision of the
source code tree that was requested from the VC system. When a build
is requested of a specific revision (as is generally the case when the
build is triggered by Changes), this will contain the revision
specification. The syntax depends upon the VC system in use: for SVN
it is an integer, for Mercurial it is a short string, for Darcs it is
a rather large string, etc.

If the ``force build'' button was pressed, the revision will be
@code{None}, which means to use the most recent revision available.
This is a ``trunk build''. This will be interpolated as an empty
string.

@item got_revision

This is set when a Source step checks out the source tree, and
provides the revision that was actually obtained from the VC system.
In general this should be the same as @code{revision}, except for
trunk builds, where @code{got_revision} indicates what revision was
current when the checkout was performed. This can be used to rebuild
the same source code later.

Note that for some VC systems (Darcs in particular), the revision is a
large string containing newlines, and is not suitable for
interpolation into a filename.

@item buildername

This is a string that indicates which Builder the build was a part of.
The combination of buildername and buildnumber uniquely identify a
build.

@item buildnumber

Each build gets a number, scoped to the Builder (so the first build
performed on any given Builder will have a build number of 0). This
integer property contains the build's number.

@item slavename

This is a string which identifies which buildslave the build is
running on.

@end table


@node Interlocks, Build Factories, Build Steps, Build Process
@section Interlocks

@cindex locks

For various reasons, you may want to prevent certain Steps (or perhaps
entire Builds) from running simultaneously. Limited CPU speed or
network bandwidth to the VC server, problems with simultaneous access
to a database server used by unit tests, or multiple Builds which
access shared state may all require some kind of interlock to prevent
corruption, confusion, or resource overload.

@code{Locks} are the mechanism used to express these kinds of
constraints on when Builds or Steps can be run. There are two kinds of
@code{Locks}, each with their own scope: @code{SlaveLock}s are scoped
to a single buildslave, while @code{MasterLock} instances are scoped
to the buildbot as a whole. Each @code{Lock} is created with a unique
name.

To use a lock, simply include it in the @code{locks=} argument of the
@code{BuildStep} object that should obtain the lock before it runs.
This argument accepts a list of @code{Lock} objects: the Step will
acquire all of them before it runs.

To claim a lock for the whole Build, add a @code{'locks'} key to the
builder specification dictionary with the same list of @code{Lock}
objects. (This is the dictionary that has the @code{'name'},
@code{'slavename'}, @code{'builddir'}, and @code{'factory'} keys). The
@code{Build} object also accepts a @code{locks=} argument, but unless
you are writing your own @code{BuildFactory} subclass then it will be
easier to set the locks in the builder dictionary.

Note that there are no partial-acquire or partial-release semantics:
this prevents deadlocks caused by two Steps each waiting for a lock
held by the other@footnote{Also note that a clever buildmaster admin
could still create the opportunity for deadlock: Build A obtains Lock
1, inside which Step A.two tries to acquire Lock 2 at the Step level.
Meanwhile Build B obtains Lock 2, and has a Step B.two which wants to
acquire Lock 1 at the Step level. Don't Do That.}. This also means
that waiting to acquire a @code{Lock} can take an arbitrarily long
time: if the buildmaster is very busy, a Step or Build which requires
only one @code{Lock} may starve another that is waiting for that
@code{Lock} plus some others.


In the following example, we run the same build on three different
platforms. The unit-test steps of these builds all use a common
database server, and would interfere with each other if allowed to run
simultaneously. The @code{Lock} prevents more than one of these builds
from happening at the same time.

@example
from buildbot import locks
from buildbot.process import s, step, factory

db_lock = locks.MasterLock("database")
steps = [s(step.SVN, svnurl="http://example.org/svn/Trunk"),
         s(step.ShellCommand, command="make all"),
         s(step.ShellCommand, command="make test", locks=[db_lock]),
        ]
f = factory.BuildFactory(steps)
b1 = @{'name': 'full1', 'slavename': 'bot-1', builddir='f1', 'factory': f@}
b2 = @{'name': 'full2', 'slavename': 'bot-2', builddir='f2', 'factory': f@}
b3 = @{'name': 'full3', 'slavename': 'bot-3', builddir='f3', 'factory': f@}
c['builders'] = [b1, b2, b3]
@end example

In the next example, we have one buildslave hosting three separate
Builders (each running tests against a different version of Python).
The machine which hosts this buildslave is not particularly fast, so
we want to prevent the builds from all happening at the same time. We
use a @code{SlaveLock} because the builds happening on the slow slave
do not affect builds running on other slaves, and we use the lock on
the build as a whole because the slave is so slow that even multiple
SVN checkouts would be taxing.

@example
from buildbot import locks
from buildbot.process import s, step, factory

slow_lock = locks.SlaveLock("cpu")
source = s(step.SVN, svnurl="http://example.org/svn/Trunk")
f22 = factory.Trial(source, trialpython=["python2.2"])
f23 = factory.Trial(source, trialpython=["python2.3"])
f24 = factory.Trial(source, trialpython=["python2.4"])
b1 = @{'name': 'p22', 'slavename': 'bot-1', builddir='p22', 'factory': f22,
                     'locks': [slow_lock] @}
b2 = @{'name': 'p23', 'slavename': 'bot-1', builddir='p23', 'factory': f23,
                     'locks': [slow_lock] @}
b3 = @{'name': 'p24', 'slavename': 'bot-1', builddir='p24', 'factory': f24,
                     'locks': [slow_lock] @}
c['builders'] = [b1, b2, b3]
@end example

In the last example, we use two Locks at the same time. In this case,
we're concerned about both of the previous constraints, but we'll say
that only the tests are computationally intensive, and that they have
been split into those which use the database and those which do not.
In addition, two of the Builds run on a fast machine which does not
need to worry about the cpu lock, but which still must be prevented
from simultaneous database access.

@example
from buildbot import locks
from buildbot.process import s, step, factory

db_lock = locks.MasterLock("database")
cpu_lock = locks.SlaveLock("cpu")
slow_steps = [s(step.SVN, svnurl="http://example.org/svn/Trunk"),
              s(step.ShellCommand, command="make all", locks=[cpu_lock]),
              s(step.ShellCommand, command="make test", locks=[cpu_lock]),
              s(step.ShellCommand, command="make db-test",
                                   locks=[db_lock, cpu_lock]),
             ]
slow_f = factory.BuildFactory(slow_steps)
fast_steps = [s(step.SVN, svnurl="http://example.org/svn/Trunk"),
              s(step.ShellCommand, command="make all", locks=[]),
              s(step.ShellCommand, command="make test", locks=[]),
              s(step.ShellCommand, command="make db-test",
                                   locks=[db_lock]),
             ]
fast_factory = factory.BuildFactory(fast_steps)
b1 = @{'name': 'full1', 'slavename': 'bot-slow', builddir='full1',
                       'factory': slow_factory@}
b2 = @{'name': 'full2', 'slavename': 'bot-slow', builddir='full2',
                       'factory': slow_factory@}
b3 = @{'name': 'full3', 'slavename': 'bot-fast', builddir='full3',
                       'factory': fast_factory@}
b4 = @{'name': 'full4', 'slavename': 'bot-fast', builddir='full4',
                       'factory': fast_factory@}
c['builders'] = [b1, b2, b3, b4]
@end example

As a final note, remember that a unit test system which breaks when
multiple people run it at the same time is fragile and should be
fixed. Asking your human developers to serialize themselves when
running unit tests will just discourage them from running the unit
tests at all. Find a way to fix this: change the database tests to
create a new (uniquely-named) user or table for each test run, don't
use fixed listening TCP ports for network tests (instead listen on
port 0 to let the kernel choose a port for you and then query the
socket to find out what port was allocated). @code{MasterLock}s can be
used to accomodate broken test systems like this, but are really
intended for other purposes: build processes that store or retrieve
products in shared directories, or which do things that human
developers would not (or which might slow down or break in ways that
require human attention to deal with).

@code{SlaveLocks}s can be used to keep automated performance tests
from interfering with each other, when there are multiple Builders all
using the same buildslave. But they can't prevent other users from
running CPU-intensive jobs on that host while the tests are running.

@node Build Factories,  , Interlocks, Build Process
@section Build Factories


Each Builder is equipped with a ``build factory'', which is
responsible for producing the actual @code{Build} objects that perform
each build. This factory is created in the configuration file, and
attached to a Builder through the @code{factory} element of its
dictionary.

The standard @code{BuildFactory} object creates @code{Build} objects
by default. These Builds will each execute a collection of BuildSteps
in a fixed sequence. Each step can affect the results of the build,
but in general there is little intelligence to tie the different steps
together. You can create subclasses of @code{Build} to implement more
sophisticated build processes, and then use a subclass of
@code{BuildFactory} (or simply set the @code{buildClass} attribute) to
create instances of your new Build subclass.


@menu
* BuildStep Objects::           
* BuildFactory::                
* Process-Specific build factories::  
@end menu

@node BuildStep Objects, BuildFactory, Build Factories, Build Factories
@subsection BuildStep Objects

The steps used by these builds are all subclasses of @code{BuildStep}.
The standard ones provided with Buildbot are documented later,
@xref{Build Steps}. You can also write your own subclasses to use in
builds.

The basic behavior for a @code{BuildStep} is to:

@itemize @bullet
@item
run for a while, then stop
@item
possibly invoke some RemoteCommands on the attached build slave
@item
possibly produce a set of log files
@item
finish with a status described by one of four values defined in
buildbot.status.builder: SUCCESS, WARNINGS, FAILURE, SKIPPED
@item
provide a list of short strings to describe the step
@item
define a color (generally green, orange, or red) with which the
step should be displayed
@end itemize


More sophisticated steps may produce additional information and
provide it to later build steps, or store it in the factory to provide
to later builds.


@node BuildFactory, Process-Specific build factories, BuildStep Objects, Build Factories
@subsection BuildFactory

The default @code{BuildFactory}, provided in the
@code{buildbot.process.factory} module, is constructed with a list of
``BuildStep specifications'': a list of @code{(step_class, kwargs)}
tuples for each. When asked to create a Build, it loads the list of
steps into the new Build object. When the Build is actually started,
these step specifications are used to create the actual set of
BuildSteps, which are then executed one at a time. For example, a
build which consists of a CVS checkout followed by a @code{make build}
would be constructed as follows:

@example
from buildbot.process import step, factory
from buildbot.factory import s
# s is a convenience function, defined with:
# def s(steptype, **kwargs): return (steptype, kwargs)

f = factory.BuildFactory([s(step.CVS,
                            cvsroot=CVSROOT, cvsmodule="project",
                            mode="update"),
                          s(step.Compile, command=["make", "build"])])
@end example

Each step can affect the build process in the following ways:

@itemize @bullet
@item
If the step's @code{haltOnFailure} attribute is True, then a failure
in the step (i.e. if it completes with a result of FAILURE) will cause
the whole build to be terminated immediately: no further steps will be
executed. This is useful for setup steps upon which the rest of the
build depends: if the CVS checkout or @code{./configure} process
fails, there is no point in trying to compile or test the resulting
tree.

@item
If the @code{flunkOnFailure} or @code{flunkOnWarnings} flag is set,
then a result of FAILURE or WARNINGS will mark the build as a whole as
FAILED. However, the remaining steps will still be executed. This is
appropriate for things like multiple testing steps: a failure in any
one of them will indicate that the build has failed, however it is
still useful to run them all to completion.
 
@item
Similarly, if the @code{warnOnFailure} or @code{warnOnWarnings} flag
is set, then a result of FAILURE or WARNINGS will mark the build as
having WARNINGS, and the remaining steps will still be executed. This
may be appropriate for certain kinds of optional build or test steps.
For example, a failure experienced while building documentation files
should be made visible with a WARNINGS result but not be serious
enough to warrant marking the whole build with a FAILURE.

@end itemize

In addition, each Step produces its own results, may create logfiles,
etc. However only the flags described above have any effect on the
build as a whole.

The pre-defined BuildSteps like @code{CVS} and @code{Compile} have
reasonably appropriate flags set on them already. For example, without
a source tree there is no point in continuing the build, so the
@code{CVS} class has the @code{haltOnFailure} flag set to True. Look
in @file{buildbot/process/step.py} to see how the other Steps are
marked.

Each Step is created with an additional @code{workdir} argument that
indicates where its actions should take place. This is specified as a
subdirectory of the slave builder's base directory, with a default
value of @code{build}. This is only implemented as a step argument (as
opposed to simply being a part of the base directory) because the
CVS/SVN steps need to perform their checkouts from the parent
directory.

@menu
* BuildFactory Attributes::     
* Quick builds::                
@end menu

@node BuildFactory Attributes, Quick builds, BuildFactory, BuildFactory
@subsubsection BuildFactory Attributes

Some attributes from the BuildFactory are copied into each Build.

@cindex treeStableTimer

@table @code
@item useProgress
(defaults to True): if True, the buildmaster keeps track of how long
each step takes, so it can provide estimates of how long future builds
will take. If builds are not expected to take a consistent amount of
time (such as incremental builds in which a random set of files are
recompiled or tested each time), this should be set to False to
inhibit progress-tracking.

@end table


@node Quick builds,  , BuildFactory Attributes, BuildFactory
@subsubsection Quick builds

The difference between a ``full build'' and a ``quick build'' is that
quick builds are generally done incrementally, starting with the tree
where the previous build was performed. That simply means that the
source-checkout step should be given a @code{mode='update'} flag, to
do the source update in-place.

In addition to that, the @code{useProgress} flag should be set to
False. Incremental builds will (or at least the ought to) compile as
few files as necessary, so they will take an unpredictable amount of
time to run. Therefore it would be misleading to claim to predict how
long the build will take.


@node Process-Specific build factories,  , BuildFactory, Build Factories
@subsection Process-Specific build factories

Many projects use one of a few popular build frameworks to simplify
the creation and maintenance of Makefiles or other compilation
structures. Buildbot provides several pre-configured BuildFactory
subclasses which let you build these projects with a minimum of fuss.

@menu
* GNUAutoconf::                 
* CPAN::                        
* Python distutils::            
* Python/Twisted/trial projects::  
@end menu

@node GNUAutoconf, CPAN, Process-Specific build factories, Process-Specific build factories
@subsubsection GNUAutoconf

@uref{http://www.gnu.org/software/autoconf/, GNU Autoconf} is a
software portability tool, intended to make it possible to write
programs in C (and other languages) which will run on a variety of
UNIX-like systems. Most GNU software is built using autoconf. It is
frequently used in combination with GNU automake. These tools both
encourage a build process which usually looks like this:

@example
% CONFIG_ENV=foo ./configure --with-flags
% make all
% make check
# make install
@end example

(except of course the Buildbot always skips the @code{make install}
part).

The Buildbot's @code{buildbot.process.factory.GNUAutoconf} factory is
designed to build projects which use GNU autoconf and/or automake. The
configuration environment variables, the configure flags, and command
lines used for the compile and test are all configurable, in general
the default values will be suitable.

Example:

@example
# use the s() convenience function defined earlier
f = factory.GNUAutoconf(source=s(step.SVN, svnurl=URL, mode="copy"),
                        flags=["--disable-nls"])
@end example

Required Arguments:

@table @code
@item source
This argument must be a step specification tuple that provides a
BuildStep to generate the source tree.
@end table

Optional Arguments:

@table @code
@item configure
The command used to configure the tree. Defaults to
@code{./configure}. Accepts either a string or a list of shell argv
elements.

@item configureEnv
The environment used for the initial configuration step. This accepts
a dictionary which will be merged into the buildslave's normal
environment. This is commonly used to provide things like
@code{CFLAGS="-O2 -g"} (to turn off debug symbols during the compile).
Defaults to an empty dictionary.

@item configureFlags
A list of flags to be appended to the argument list of the configure
command. This is commonly used to enable or disable specific features
of the autoconf-controlled package, like @code{["--without-x"]} to
disable windowing support. Defaults to an empty list.

@item compile
this is a shell command or list of argv values which is used to
actually compile the tree. It defaults to @code{make all}. If set to
None, the compile step is skipped.

@item test
this is a shell command or list of argv values which is used to run
the tree's self-tests. It defaults to @code{make check}. If set to
None, the test step is skipped.

@end table


@node CPAN, Python distutils, GNUAutoconf, Process-Specific build factories
@subsubsection CPAN

Most Perl modules available from the @uref{http://www.cpan.org/, CPAN}
archive use the @code{MakeMaker} module to provide configuration,
build, and test services. The standard build routine for these modules
looks like:

@example
% perl Makefile.PL
% make
% make test
# make install
@end example

(except again Buildbot skips the install step)

Buildbot provides a @code{CPAN} factory to compile and test these
projects.


Arguments:
@table @code
@item source
(required): A step specification tuple, that that used by GNUAutoconf.

@item perl
A string which specifies the @code{perl} executable to use. Defaults
to just @code{perl}.

@end table


@node Python distutils, Python/Twisted/trial projects, CPAN, Process-Specific build factories
@subsubsection Python distutils

Most Python modules use the @code{distutils} package to provide
configuration and build services. The standard build process looks
like:

@example
% python ./setup.py build
% python ./setup.py install
@end example

Unfortunately, although Python provides a standard unit-test framework
named @code{unittest}, to the best of my knowledge @code{distutils}
does not provide a standardized target to run such unit tests. (please
let me know if I'm wrong, and I will update this factory).

The @code{Distutils} factory provides support for running the build
part of this process. It accepts the same @code{source=} parameter as
the other build factories.


Arguments:
@table @code
@item source
(required): A step specification tuple, that that used by GNUAutoconf.
  
@item python
A string which specifies the @code{python} executable to use. Defaults
to just @code{python}.

@item test
Provides a shell command which runs unit tests. This accepts either a
string or a list. The default value is None, which disables the test
step (since there is no common default command to run unit tests in
distutils modules).

@end table


@node Python/Twisted/trial projects,  , Python distutils, Process-Specific build factories
@subsubsection Python/Twisted/trial projects

Twisted provides a unit test tool named @code{trial} which provides a
few improvements over Python's built-in @code{unittest} module. Many
python projects which use Twisted for their networking or application
services also use trial for their unit tests. These modules are
usually built and tested with something like the following:

@example
% python ./setup.py build
% PYTHONPATH=build/lib.linux-i686-2.3 trial -v PROJECTNAME.test
% python ./setup.py install
@end example

Unfortunately, the @file{build/lib} directory into which the
built/copied .py files are placed is actually architecture-dependent,
and I do not yet know of a simple way to calculate its value. For many
projects it is sufficient to import their libraries ``in place'' from
the tree's base directory (@code{PYTHONPATH=.}).

In addition, the @var{PROJECTNAME} value where the test files are
located is project-dependent: it is usually just the project's
top-level library directory, as common practice suggests the unit test
files are put in the @code{test} sub-module. This value cannot be
guessed, the @code{Trial} class must be told where to find the test
files.

The @code{Trial} class provides support for building and testing
projects which use distutils and trial. If the test module name is
specified, trial will be invoked. The library path used for testing
can also be set.

One advantage of trial is that the Buildbot happens to know how to
parse trial output, letting it identify which tests passed and which
ones failed. The Buildbot can then provide fine-grained reports about
how many tests have failed, when individual tests fail when they had
been passing previously, etc.

Another feature of trial is that you can give it a series of source
.py files, and it will search them for special @code{test-case-name}
tags that indicate which test cases provide coverage for that file.
Trial can then run just the appropriate tests. This is useful for
quick builds, where you want to only run the test cases that cover the
changed functionality.

Arguments:
@table @code
@item source
(required): A step specification tuple, like that used by GNUAutoconf.

@item buildpython
A list (argv array) of strings which specifies the @code{python}
executable to use when building the package. Defaults to just
@code{['python']}. It may be useful to add flags here, to supress
warnings during compilation of extension modules. This list is
extended with @code{['./setup.py', 'build']} and then executed in a
ShellCommand.

@item testpath
Provides a directory to add to @code{PYTHONPATH} when running the unit
tests, if tests are being run. Defaults to @code{.} to include the
project files in-place. The generated build library is frequently
architecture-dependent, but may simply be @file{build/lib} for
pure-python modules.

@item trialpython
Another list of strings used to build the command that actually runs
trial. This is prepended to the contents of the @code{trial} argument
below. It may be useful to add @code{-W} flags here to supress
warnings that occur while tests are being run. Defaults to an empty
list, meaning @code{trial} will be run without an explicit
interpreter, which is generally what you want if you're using
@file{/usr/bin/trial} instead of, say, the @file{./bin/trial} that
lives in the Twisted source tree.

@item trial
provides the name of the @code{trial} command. It is occasionally
useful to use an alternate executable, such as @code{trial2.2} which
might run the tests under an older version of Python. Defaults to
@code{trial}.

@item tests
Provides a module name or names which contain the unit tests for this
project. Accepts a string, typically @code{PROJECTNAME.test}, or a
list of strings. Defaults to None, indicating that no tests should be
run. You must either set this or @code{useTestCaseNames} to do anyting
useful with the Trial factory.

@item useTestCaseNames
Tells the Step to provide the names of all changed .py files to trial,
so it can look for test-case-name tags and run just the matching test
cases. Suitable for use in quick builds. Defaults to False.

@item randomly
If @code{True}, tells Trial (with the @code{--random=0} argument) to
run the test cases in random order, which sometimes catches subtle
inter-test dependency bugs. Defaults to @code{False}.

@item recurse
If @code{True}, tells Trial (with the @code{--recurse} argument) to
look in all subdirectories for additional test cases. It isn't clear
to me how this works, but it may be useful to deal with the
unknown-PROJECTNAME problem described above, and is currently used in
the Twisted buildbot to accomodate the fact that test cases are now
distributed through multiple twisted.SUBPROJECT.test directories.

@end table  

Unless one of @code{trialModule} or @code{useTestCaseNames}
are set, no tests will be run.

Some quick examples follow. Most of these examples assume that the
target python code (the ``code under test'') can be reached directly
from the root of the target tree, rather than being in a @file{lib/}
subdirectory.

@example
#  Trial(source, tests="toplevel.test") does:
#   python ./setup.py build
#   PYTHONPATH=. trial -to toplevel.test

#  Trial(source, tests=["toplevel.test", "other.test"]) does:
#   python ./setup.py build
#   PYTHONPATH=. trial -to toplevel.test other.test

#  Trial(source, useTestCaseNames=True) does:
#   python ./setup.py build
#   PYTHONPATH=. trial -to --testmodule=foo/bar.py..  (from Changes)

#  Trial(source, buildpython=["python2.3", "-Wall"], tests="foo.tests"):
#   python2.3 -Wall ./setup.py build
#   PYTHONPATH=. trial -to foo.tests

#  Trial(source, trialpython="python2.3", trial="/usr/bin/trial",
#        tests="foo.tests") does:
#   python2.3 -Wall ./setup.py build
#   PYTHONPATH=. python2.3 /usr/bin/trial -to foo.tests

# For running trial out of the tree being tested (only useful when the
# tree being built is Twisted itself):
#  Trial(source, trialpython=["python2.3", "-Wall"], trial="./bin/trial",
#        tests="foo.tests") does:
#   python2.3 -Wall ./setup.py build
#   PYTHONPATH=. python2.3 -Wall ./bin/trial -to foo.tests
@end example

If the output directory of @code{./setup.py build} is known, you can
pull the python code from the built location instead of the source
directories. This should be able to handle variations in where the
source comes from, as well as accomodating binary extension modules:

@example
# Trial(source,tests="toplevel.test",testpath='build/lib.linux-i686-2.3')
# does:
#  python ./setup.py build
#  PYTHONPATH=build/lib.linux-i686-2.3 trial -to toplevel.test
@end example


@node Status Delivery, Command-line tool, Build Process, Top
@chapter Status Delivery

More details are available in the docstrings for each class, use
@code{pydoc buildbot.status.html.Waterfall} to see them. Most status
delivery objects take a @code{categories=} argument, which can contain
a list of ``category'' names: in this case, it will only show status
for Builders that are in one of the named categories.

(implementor's note: each of these objects should be a
service.MultiService which will be attached to the BuildMaster object
when the configuration is processed. They should use
@code{self.parent.getStatus()} to get access to the top-level IStatus
object, either inside @code{startService} or later. They may call
@code{status.subscribe()} in @code{startService} to receive
notifications of builder events, in which case they must define
@code{builderAdded} and related methods. See the docstrings in
@file{buildbot/interfaces.py} for full details.)

@menu
* HTML Waterfall::              
* IRC Bot::                     
* PBListener::                  
@end menu

@node HTML Waterfall, IRC Bot, Status Delivery, Status Delivery
@subsection HTML Waterfall

@cindex Waterfall

@example
from buildbot.status import html
w = html.Waterfall(http_port=8080)
c['status'].append(w)
@end example

The @code{buildbot.status.html.Waterfall} status target creates an
HTML ``waterfall display'', which shows a time-based chart of events.
This display provides detailed information about all steps of all
recent builds, and provides hyperlinks to look at individual build
logs and source changes. If the @code{http_port} argument is provided,
it provides a strports specification for the port that the web server
should listen on. This can be a simple port number, or a string like
@code{tcp:8080:interface=127.0.0.1} (to limit connections to the
loopback interface, and therefore to clients running on the same
host)@footnote{It may even be possible to provide SSL access by using
a specification like
@code{"ssl:12345:privateKey=mykey.pen:certKey=cert.pem"}, but this is
completely untested}.

If instead (or in addition) you provide the @code{distrib_port}
argument, a twisted.web distributed server will be started either on a
TCP port (if @code{distrib_port} is like @code{"tcp:12345"}) or more
likely on a UNIX socket (if @code{distrib_port} is like
@code{"unix:/path/to/socket"}).

The @code{distrib_port} option means that, on a host with a
suitably-configured twisted-web server, you do not need to consume a
separate TCP port for the buildmaster's status web page. When the web
server is constructed with @code{mktap web --user}, URLs that point to
@code{http://host/~username/} are dispatched to a sub-server that is
listening on a UNIX socket at @code{~username/.twisted-web-pb}. On
such a system, it is convenient to create a dedicated @code{buildbot}
user, then set @code{distrib_port} to
@code{"unix:"+os.path.expanduser("~/.twistd-web-pb")}. This
configuration will make the HTML status page available at
@code{http://host/~buildbot/} . Suitable URL remapping can make it
appear at @code{http://host/buildbot/}, and the right virtual host
setup can even place it at @code{http://buildbot.host/} .

Other arguments:

@table @code
@item allowForce
If set to True (the default), then the web page will provide a ``Force
Build'' button that allows visitors to manually trigger builds. This
is useful for developers to re-run builds that have failed because of
intermittent problems in the test suite, or because of libraries that
were not installed at the time of the previous build. You may not wish
to allow strangers to cause a build to run: in that case, set this to
False to remove these buttons.

@item favicon
If set to a string, this will be interpreted as a filename containing
a ``favicon'': a small image that contains an icon for the web site.
This is returned to browsers that request the @code{favicon.ico} file,
and should point to a .png or .ico image file. The default value uses
the buildbot/buildbot.png image (a small hex nut) contained in the
buildbot distribution. You can set this to None to avoid using a
favicon at all.

@item robots_txt
If set to a string, this will be interpreted as a filename containing
the contents of ``robots.txt''. Many search engine spiders request
this file before indexing the site. Setting it to a file which
contains:
@example
User-agent: *
Disallow: /
@end example
will prevent most search engines from trawling the (voluminous)
generated status pages.

@end table


@node IRC Bot, PBListener, HTML Waterfall, Status Delivery
@subsection IRC Bot

@cindex IRC

The @code{buildbot.status.words.IRC} status target creates an IRC bot
which will attach to certain channels and be available for status
queries. It can also be asked to announce builds as they occur, or be
told to shut up.

@example
from twisted.status import words
irc = words.IRC("irc.example.org", "botnickname", 
                channels=["channel1", "channel2"],
                password="mysecretpassword")
c['status'].append(irc)
@end example

Take a look at the docstring for @code{words.IRC} for more details on
configuring this service. The @code{password} argument, if provided,
will be sent to Nickserv to claim the nickname: some IRC servers will
not allow clients to send private messages until they have logged in
with a password.

To use the service, you address messages at the buildbot, either
normally (@code{botnickname: status}) or with private messages
(@code{/msg botnickname status}). The buildbot will respond in kind.

Some of the commands currently available:

@table @code

@item list builders
Emit a list of all configured builders
@item status BUILDER
Announce the status of a specific Builder: what it is doing right now.
@item status all
Announce the status of all Builders
@item watch BUILDER
If the given Builder is currently running, wait until the Build is
finished and then announce the results.
@item last BUILDER
Return the results of the last build to run on the given Builder.

@item help COMMAND
Describe a command. Use @code{help commands} to get a list of known
commands.
@item source
Announce the URL of the Buildbot's home page.
@item version
Announce the version of this Buildbot.
@end table

If the @code{allowForce=True} option was used, some addtional commands
will be available:

@table @code
@item force build BUILDER REASON
Tell the given Builder to start a build of the latest code. The user
requesting the build and REASON are recorded in the Build status. The
buildbot will announce the build's status when it finishes.

@item stop build BUILDER REASON
Terminate any running build in the given Builder. REASON will be added
to the build status to explain why it was stopped. You might use this
if you committed a bug, corrected it right away, and don't want to
wait for the first build (which is destined to fail) to complete
before starting the second (hopefully fixed) build.
@end table

@node PBListener,  , IRC Bot, Status Delivery
@subsection PBListener

@cindex PBListener

@example
import buildbot.status.client
pbl = buildbot.status.client.PBListener(port=int, user=str,
                                        passwd=str)
c['status'].append(pbl)
@end example

This sets up a PB listener on the given TCP port, to which a PB-based
status client can connect and retrieve status information.
@code{buildbot statusgui} (@pxref{statusgui}) is an example of such a
status client. The @code{port} argument can also be a strports
specification string.

@node Command-line tool, Resources, Status Delivery, Top
@chapter Command-line tool

The @command{buildbot} command-line tool can be used to start or stop a
buildmaster or buildbot, and to interact with a running buildmaster.
Some of its subcommands are intended for buildmaster admins, while
some are for developers who are editing the code that the buildbot is
monitoring.

@menu
* Administrator Tools::         
* Developer Tools::             
* Other Tools::                 
* .buildbot config directory::  
@end menu

@node Administrator Tools, Developer Tools, Command-line tool, Command-line tool
@section Administrator Tools

The following @command{buildbot} sub-commands are intended for
buildmaster administrators:

@heading master

This creates a new directory and populates it with files that allow it
to be used as a buildmaster's base directory.

@example
buildbot master BASEDIR
@end example

@heading slave

This creates a new directory and populates it with files that let it
be used as a buildslave's base directory. You must provide several
arguments, which are used to create the initial @file{buildbot.tac}
file.

@example
buildbot slave @var{BASEDIR} @var{MASTERHOST}:@var{PORT} @var{SLAVENAME} @var{PASSWORD}
@end example

@heading start

This starts a buildmaster or buildslave which was already created in
the given base directory. The daemon is launched in the background,
with events logged to a file named @file{twistd.log}.

@example
buildbot start BASEDIR
@end example

@heading stop

This terminates the daemon (either buildmaster or buildslave) running
in the given directory.

@example
buildbot stop BASEDIR
@end example

@heading sighup

This sends a SIGHUP to the buildmaster running in the given directory,
which causes it to re-read its @file{master.cfg} file.

@example
buildbot sighup BASEDIR
@end example

@node Developer Tools, Other Tools, Administrator Tools, Command-line tool
@section Developer Tools

These tools are provided for use by the developers who are working on
the code that the buildbot is monitoring.

@menu
* statuslog::                   
* statusgui::                   
* try::                         
@end menu

@node statuslog, statusgui, Developer Tools, Developer Tools
@subsection statuslog

@example
buildbot statuslog --master @var{MASTERHOST}:@var{PORT}
@end example

This command starts a simple text-based status client, one which just
prints out a new line each time an event occurs on the buildmaster.

The @option{--master} option provides the location of the
@code{client.PBListener} status port, used to deliver build
information to realtime status clients. The option is always in the
form of a string, with hostname and port number separated by a colon
(@code{HOSTNAME:PORTNUM}). Note that this port is @emph{not} the same
as the slaveport (although a future version may allow the same port
number to be used for both purposes).

The @option{--master} option can also be provided by the
@code{masterstatus} name in @file{.buildbot/options} (@pxref{.buildbot
config directory}).

@node statusgui, try, statuslog, Developer Tools
@subsection statusgui

@cindex statusgui

If you have set up a PBListener (@pxref{PBListener}), you will be able
to monitor your Buildbot using a simple Gtk+ application invoked with
the @code{buildbot statusgui} command:

@example
buildbot statusgui --master @var{MASTERHOST}:@var{PORT}
@end example

This command starts a simple Gtk+-based status client, which contains
a few boxes for each Builder that change color as events occur. It
uses the same @option{--master} argument as the @command{buildbot
statuslog} command (@pxref{statuslog}).

@node try,  , statusgui, Developer Tools
@subsection try

This lets a developer to ask the question ``What would happen if I
committed this patch right now?''. It runs the unit test suite (across
multiple build platforms) on the developer's current code, allowing
them to make sure they will not break the tree when they finally
commit their changes.

The @command{buildbot try} command is meant to be run from within a
developer's local tree, and starts by figuring out the base revision
of that tree (what revision was current the last time the tree was
updated), and a patch that can be applied to that revision of the tree
to make it match the developer's copy. This (revision, patch) pair is
then sent to the buildmaster, which runs a build with that
SourceStamp. If you want, the tool will emit status messages as the
builds run, and will not terminate until the first failure has been
detected (or the last success).

For this command to work, several pieces must be in place:


@heading TryScheduler

The buildmaster must have a @code{scheduler.Try} instance in
the config file's @code{c['schedulers']} list. This lets the
administrator control who may initiate these ``trial'' builds, which
branches are eligible for trial builds, and which Builders should be
used for them.

The @code{TryScheduler} has various means to accept build requests:
all of them enforce more security than the usual buildmaster ports do.
Any source code being built can be used to compromise the buildslave
accounts, but in general that code must be checked out from the VC
repository first, so only people with commit privileges can get
control of the buildslaves. The usual force-build control channels can
waste buildslave time but do not allow arbitrary commands to be
executed by people who don't have those commit privileges. However,
the source code patch that is provided with the trial build does not
have to go through the VC system first, so it is important to make
sure these builds cannot be abused by a non-committer to acquire as
much control over the buildslaves as a committer has. Ideally, only
developers who have commit access to the VC repository would be able
to start trial builds, but unfortunately the buildmaster does not, in
general, have access to VC system's user list.

As a result, the @code{TryScheduler} requires a bit more
configuration. There are currently two ways to set this up:

@table @strong
@item jobdir (ssh)

This approach creates a command queue directory, called the
``jobdir'', in the buildmaster's working directory. The buildmaster
admin sets the ownership and permissions of this directory to only
grant write access to the desired set of developers, all of whom must
have accounts on the machine. The @code{buildbot try} command creates
a special file containing the source stamp information and drops it in
the jobdir, just like a standard maildir. When the buildmaster notices
the new file, it unpacks the information inside and starts the builds.

The config file entries used by 'buildbot try' either specify a local
queuedir (for which write and mv are used) or a remote one (using scp
and ssh).

The advantage of this scheme is that it is quite secure, the
disadvantage is that it requires fiddling outside the buildmaster
config (to set the permissions on the jobdir correctly). If the
buildmaster machine happens to also house the VC repository, then it
can be fairly easy to keep the VC userlist in sync with the
trial-build userlist. If they are on different machines, this will be
much more of a hassle. It may also involve granting developer accounts
on a machine that would not otherwise require them.

To implement this, the buildslave invokes 'ssh -l username host
buildbot tryserver ARGS', passing the patch contents over stdin. The
arguments must include the inlet directory and the revision
information.

@item user+password (PB)

In this approach, each developer gets a username/password pair, which
are all listed in the buildmaster's configuration file. When the
developer runs @code{buildbot try}, their machine connects to the
buildmaster via PB and authenticates themselves using that username
and password, then sends a PB command to start the trial build.

The advantage of this scheme is that the entire configuration is
performed inside the buildmaster's config file. The disadvantages are
that it is less secure (while the ``cred'' authentication system does
not expose the password in plaintext over the wire, it does not offer
most of the other security properties that SSH does). In addition, the
buildmaster admin is responsible for maintaining the username/password
list, adding and deleting entries as developers come and go.

@end table


For example, to set up the ``jobdir'' style of trial build, using a
command queue directory of @file{MASTERDIR/jobdir} (and assuming that
all your project developers were members of the @code{developers} unix
group), you would first create that directory (with @command{mkdir
MASTERDIR/jobdir MASTERDIR/jobdir/new MASTERDIR/jobdir/cur
MASTERDIR/jobdir/tmp; chgrp developers MASTERDIR/jobdir
MASTERDIR/jobdir/*; chmod g+rwx,o-rwx MASTERDIR/jobdir
MASTERDIR/jobdir/*}), and then use the following scheduler in the
buildmaster's config file:

@example
from buildbot.scheduler import Try_Jobdir
s = Try_Jobdir("try1", ["full-linux", "full-netbsd", "full-OSX"],
               jobdir="jobdir")
c['schedulers'] = [s]
@end example

Note that you must create the jobdir before telling the buildmaster to
use this configuration, otherwise you will get an error. Also remember
that the buildmaster must be able to read and write to the jobdir as
well. Be sure to watch the @file{twistd.log} file (@pxref{Logfiles})
as you start using the jobdir, to make sure the buildmaster is happy
with it.

To use the username/password form of authentication, create a
@code{Try_Userpass} instance instead. It takes the same
@code{builderNames} argument as the @code{Try_Jobdir} form, but
accepts an addtional @code{port} argument (to specify the TCP port to
listen on) and a @code{userpass} list of username/password pairs to
accept. Remember to use good passwords for this: the security of the
buildslave accounts depends upon it:

@example
from buildbot.scheduler import Try_Userpass
s = Try_Userpass("try2", ["full-linux", "full-netbsd", "full-OSX"],
                 port=8031, userpass=[("alice","pw1"), ("bob", "pw2")] )
c['schedulers'] = [s]
@end example

Like most places in the buildbot, the @code{port} argument takes a
strports specification. See @code{twisted.application.strports} for
details.


@heading locating the master

The @command{try} command needs to be told how to connect to the
@code{TryScheduler}, and must know which of the authentication
approaches described above is in use by the buildmaster. You specify
the approach by using @option{--connect=ssh} or @option{--connect=pb}
(or @code{try_connect = 'ssh'} or @code{try_connect = 'pb'} in
@file{.buildbot/options}).

For the PB approach, the command must be given a @option{--master}
argument (in the form HOST:PORT) that points to TCP port that you
picked in the @code{Try_Userpass} scheduler. It also takes a
@option{--username} and @option{--passwd} pair of arguments that match
one of the entries in the buildmaster's @code{userpass} list. These
arguments can also be provided as @code{try_master},
@code{try_username}, and @code{try_password} entries in the
@file{.buildbot/options} file.

For the SSH approach, the command must be given @option{--tryhost},
@option{--username}, and optionally @option{--password} (TODO:
really?) to get to the buildmaster host. It must also be given
@option{--trydir}, which points to the inlet directory configured
above. The trydir can be relative to the user's home directory, but
most of the time you will use an explicit path like
@file{~buildbot/project/trydir}. These arguments can be provided in
@file{.buildbot/options} as @code{try_host}, @code{try_username},
@code{try_password}, and @code{try_dir}.

In addition, the SSH approach needs to connect to a PBListener status
port, so it can retrieve and report the results of the build (the PB
approach uses the existing connection to retrieve status information,
so this step is not necessary). This requires a @option{--master}
argument, or a @code{masterstatus} entry in @file{.buildbot/options},
in the form of a HOSTNAME:PORT string.


@heading choosing the Builders

A trial build is performed on multiple Builders at the same time, and
the developer gets to choose which Builders are used (limited to a set
selected by the buildmaster admin with the TryScheduler's
@code{builderNames=} argument). The set you choose will depend upon
what your goals are: if you are concerned about cross-platform
compatibility, you should use multiple Builders, one from each
platform of interest. You might use just one builder if that platform
has libraries or other facilities that allow better test coverage than
what you can accomplish on your own machine, or faster test runs.

The set of Builders to use can be specified with multiple
@option{--builder} arguments on the command line. It can also be
specified with a single @code{try_builders} option in
@file{.buildbot/options} that uses a list of strings to specify all
the Builder names:

@example
try_builders = ["full-OSX", "full-win32", "full-linux"]
@end example

@heading specifying the VC system

The @command{try} command also needs to know how to take the
developer's current tree and extract the (revision, patch)
source-stamp pair. Each VC system uses a different process, so you
start by telling the @command{try} command which VC system you are
using, with an argument like @option{--vc=cvs} or @option{--vc=tla}.
This can also be provided as @code{try_vc} in
@file{.buildbot/options}.

The following names are recognized: @code{cvs} @code{svn} @code{baz}
@code{tla} @code{hg} @code{darcs}


@heading finding the top of the tree

Some VC systems (notably CVS and SVN) track each directory
more-or-less independently, which means the @command{try} command
needs to move up to the top of the project tree before it will be able
to construct a proper full-tree patch. To accomplish this, the
@command{try} command will crawl up through the parent directories
until it finds a marker file. The default name for this marker file is
@file{.buildbot-top}, so when you are using CVS or SVN you should
@code{touch .buildbot-top} from the top of your tree before running
@command{buildbot try}. Alternatively, you can use a filename like
@file{ChangeLog} or @file{README}, since many projects put one of
these files in their top-most directory (and nowhere else). To set
this filename, use @option{--try-topfile=ChangeLog}, or set it in the
options file with @code{try_topfile = 'ChangeLog'}.

You can also manually set the top of the tree with
@option{--try-topdir=~/trees/mytree}, or @code{try_topdir =
'~/trees/mytree'}. If you use @code{try_topdir}, in a
@file{.buildbot/options} file, you will need a separate options file
for each tree you use, so it may be more convenient to use the
@code{try_topfile} approach instead.

Other VC systems which work on full projects instead of individual
directories (tla, baz, darcs, monotone, mercurial) do not require
@command{try} to know the top directory, so the @option{--try-topfile}
and @option{--try-topdir} arguments will be ignored.
@c is this true? I think I currently require topdirs all the time.

If the @command{try} command cannot find the top directory, it will
abort with an error message.

@heading determining the branch name

Some VC systems record the branch information in a way that ``try''
can locate it, in particular Arch (both @command{tla} and
@command{baz}). For the others, if you are using something other than
the default branch, you will have to tell the buildbot which branch
your tree is using. You can do this with either the @option{--branch}
argument, or a @option{try_branch} entry in the
@file{.buildbot/options} file.

@heading determining the revision and patch

Each VC system has a separate approach for determining the tree's base
revision and computing a patch.

@table @code

@item CVS

@command{try} pretends that the tree is up to date. It converts the
current time into a @code{-D} time specification, uses it as the base
revision, and computes the diff between the upstream tree as of that
point in time versus the current contents. This works, more or less,
but requires that the local clock be in reasonably good sync with the
repository.

@item SVN
@command{try} does a @code{svn status -u} to find the latest
repository revision number (emitted on the last line in the ``Status
against revision: NN'' message). It then performs an @code{svn diff
-rNN} to find out how your tree differs from the repository version,
and sends the resulting patch to the buildmaster. If your tree is not
up to date, this will result in the ``try'' tree being created with
the latest revision, then @emph{backwards} patches applied to bring it
``back'' to the version you actually checked out (plus your actual
code changes), but this will still result in the correct tree being
used for the build.

@item baz
@command{try} does a @code{baz tree-id} to determine the
fully-qualified version and patch identifier for the tree
(ARCHIVE/VERSION--patch-NN), and uses the VERSION--patch-NN component
as the base revision. It then does a @code{baz diff} to obtain the
patch.

@item tla
@command{try} does a @code{tla tree-version} to get the
fully-qualified version identifier (ARCHIVE/VERSION), then takes the
first line of @code{tla logs --reverse} to figure out the base
revision. Then it does @code{tla changes --diffs} to obtain the patch.

@item Darcs
@code{darcs changes --context} emits a text file that contains a list
of all patches back to and including the last tag was made. This text
file (plus the location of a repository that contains all these
patches) is sufficient to re-create the tree. Therefore the contents
of this ``context'' file @emph{are} the revision stamp for a
Darcs-controlled source tree.

So @command{try} does a @code{darcs changes --context} to determine
what your tree's base revision is, and then does a @code{darcs diff
-u} to compute the patch relative to that revision.

@item Mercurial
@code{hg identify} emits a short revision ID (basically a truncated
SHA1 hash of the current revision's contents), which is used as the
base revision. @code{hg diff} then provides the patch relative to that
revision. For @command{try} to work, your working directory must only
have patches that are available from the same remotely-available
repository that the build process' @code{step.Mercurial} will use.

@c TODO: monotone, git
@end table

@heading waiting for results

If you provide the @option{--wait} option (or @code{try_wait = True}
in @file{.buildbot/options}), the @command{buildbot try} command will
wait until your changes have either been proven good or bad before
exiting. Unless you use the @option{--quiet} option (or
@code{try_quiet=True}), it will emit a progress message every 60
seconds until the builds have completed.


@node Other Tools, .buildbot config directory, Developer Tools, Command-line tool
@section Other Tools

These tools are generally used by buildmaster administrators.

@menu
* sendchange::                  
* debugclient::                 
@end menu

@node sendchange, debugclient, Other Tools, Other Tools
@subsection sendchange

This command is used to tell the buildmaster about source changes. It
is intended to be used from within a commit script, installed on the
VC server.

@example
buildbot sendchange --master @var{MASTERHOST}:@var{PORT} --username @var{USER} @var{FILENAMES..}
@end example

There are other (optional) arguments which can influence the
@code{Change} that gets submitted:

@table @code
@item --branch
This provides the (string) branch specifier. If omitted, it defaults
to None, indicating the ``default branch''. All files included in this
Change must be on the same branch.

@item --revision_number
This provides a (numeric) revision number for the change, used for VC systems
that use numeric transaction numbers (like Subversion).

@item --revision
This provides a (string) revision specifier, for VC systems that use
strings (Arch would use something like patch-42 etc).

@item --revision_file
This provides a filename which will be opened and the contents used as
the revision specifier. This is specifically for Darcs, which uses the
output of @command{darcs changes --context} as a revision specifier.
This context file can be a couple of kilobytes long, spanning a couple
lines per patch, and would be a hassle to pass as a command-line
argument.

@item --comments
This provides the change comments as a single argument. You may want
to use @option{--logfile} instead.

@item --logfile
This instructs the tool to read the change comments from the given
file. If you use @code{-} as the filename, the tool will read the
change comments from stdin.
@end table


@node debugclient,  , sendchange, Other Tools
@subsection debugclient

@example
buildbot debugclient --master @var{MASTERHOST}:@var{PORT} --passwd @var{DEBUGPW}
@end example

This launches a small Gtk+/Glade-based debug tool, connecting to the
buildmaster's ``debug port''. This debug port shares the same port
number as the slaveport (@pxref{Setting the slaveport}), but the
@code{debugPort} is only enabled if you set a debug password in the
buildmaster's config file (@pxref{Debug options}). The
@option{--passwd} option must match the @code{c['debugPassword']}
value.

@option{--master} can also be provided in @file{.debug/options} by the
@code{master} key. @option{--passwd} can be provided by the
@code{debugPassword} key.

The @code{Connect} button must be pressed before any of the other
buttons will be active. This establishes the connection to the
buildmaster. The other sections of the tool are as follows:

@table @code
@item Reload .cfg
Forces the buildmaster to reload its @file{master.cfg} file. This is
equivalent to sending a SIGHUP to the buildmaster, but can be done
remotely through the debug port. Note that it is a good idea to be
watching the buildmaster's @file{twistd.log} as you reload the config
file, as any errors which are detected in the config file will be
announced there.

@item Rebuild .py
(not yet implemented). The idea here is to use Twisted's ``rebuild''
facilities to replace the buildmaster's running code with a new
version. Even if this worked, it would only be used by buildbot
developers.

@item poke IRC
This locates a @code{words.IRC} status target and causes it to emit a
message on all the channels to which it is currently connected. This
was used to debug a problem in which the buildmaster lost the
connection to the IRC server and did not attempt to reconnect.

@item Commit
This allows you to inject a Change, just as if a real one had been
delivered by whatever VC hook you are using. You can set the name of
the committed file and the name of the user who is doing the commit.
Optionally, you can also set a revision for the change. If the
revision you provide looks like a number, it will be sent as an
integer, otherwise it will be sent as a string.

@item Force Build
This lets you force a Builder (selected by name) to start a build of
the current source tree.

@item Currently
(obsolete). This was used to manually set the status of the given
Builder, but the status-assignment code was changed in an incompatible
way and these buttons are no longer meaningful.

@end table


@node .buildbot config directory,  , Other Tools, Command-line tool
@section .buildbot config directory

Many of the @command{buildbot} tools must be told how to contact the
buildmaster that they interact with. This specification can be
provided as a command-line argument, but most of the time it will be
easier to set them in an ``options'' file. The @command{buildbot}
command will look for a special directory named @file{.buildbot},
starting from the current directory (where the command was run) and
crawling upwards, eventually looking in the user's home directory. It
will look for a file named @file{options} in this directory, and will
evaluate it as a python script, looking for certain names to be set.
You can just put simple @code{name = 'value'} pairs in this file to
set the options.

For a description of the names used in this file, please see the
documentation for the individual @command{buildbot} sub-commands. The
following is a brief sample of what this file's contents could be.

@example
# for status-reading tools
masterstatus = 'buildbot.example.org:12345'
# for 'sendchange' or the debug port
master = 'buildbot.example.org:18990'
debugPassword = 'eiv7Po'
@end example

@table @code
@item masterstatus
Location of the @code{client.PBListener} status port, used by
@command{statuslog} and @command{statusgui}.

@item master
Location of the @code{debugPort} (for @command{debugclient}). Also the
location of the @code{pb.PBChangeSource} (for @command{sendchange}).
Usually shares the slaveport, but a future version may make it
possible to have these listen on a separate port number.

@item debugPassword
Must match the value of @code{c['debugPassword']}, used to protect the
debug port, for the @command{debugclient} command.

@item username
Provides a default username for the @command{sendchange} command.

@end table



@node Resources, Developer's Appendix, Command-line tool, Top
@chapter Resources

The Buildbot's home page is at @uref{http://buildbot.sourceforge.net/}

For configuration questions and general discussion, please use the
@code{buildbot-devel} mailing list. The subscription instructions and
archives are available at
@uref{http://lists.sourceforge.net/lists/listinfo/buildbot-devel}

@node Developer's Appendix, Index, Resources, Top
@unnumbered Developer's Appendix

This appendix contains random notes about the implementation of the
Buildbot, and is likely to only be of use to people intending to
extend the Buildbot's internals.

The buildmaster consists of a tree of Service objects, which is shaped
as follows:

@example
BuildMaster
 ChangeMaster  (in .change_svc)
  [IChangeSource instances]
 [IScheduler instances]  (in .schedulers)
 BotMaster  (in .botmaster)
 [IStatusTarget instances]  (in .statusTargets)
@end example

The BotMaster has a collection of Builder objects as values of its
@code{.builders} dictionary.


@node Index,  , Developer's Appendix, Top
@unnumbered Index

@printindex cp

@bye