Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 540 lines (424 sloc) 18.73 kb
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
Schedulers are responsible for initiating builds on builders.

Some schedulers listen for changes from ChangeSources and generate build sets
in response to these changes. Others generate build sets without changes,
based on other events in the buildmaster.

@menu
* Configuring Schedulers::
* Change Filters::
* Scheduler Scheduler::
* AnyBranchScheduler::
* Dependent Scheduler::
* Periodic Scheduler::
* Nightly Scheduler::
* Try Schedulers::
* Triggerable Scheduler::
* Scheduler Index::
@end menu

@node Configuring Schedulers
@subsection Configuring Schedulers

@bcindex 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.

Scheduler arguments should always be specified by name (as keyword arguments),
to allow for future expansion:

@example
sched = Scheduler(name="quick", builderNames=['lin', 'win'])
@end example

All schedulers have several arguments in common:

@table @code
@item name

Each Scheduler must have a unique name. This is used in status
displays, and is also available in the build property @code{scheduler}.

@item builderNames

This is the set of builders which this scheduler should trigger, specified
as a list of names (strings).

@item properties
@cindex Properties

This is a dictionary specifying properties that will be transmitted
to all builds started by this scheduler.

@end table

The remaining subsections represent a catalog of the available Scheduler types.
All these Schedulers are defined in modules under @code{buildbot.schedulers},
and the docstrings there are the best source of documentation on the arguments
taken by each one.

@node Change Filters
@subsection Change Filters
@slindex buildbot.schedulers.filter.ChangeFilter

Several schedulers perform filtering on an incoming set of changes. The filter
can most generically be specified as a ChangeFilter. Set up a ChangeFilter
like this:

@example
from buildbot.schedulers.filter import ChangeFilter
my_filter = ChangeFilter(
    project_re="^baseproduct/.*",
    branch="devel")
@end example

There are four attributes of changes on which you can filter changes:

@itemize
@item project
the project string, as defined by the ChangeSource.
@item repository
the repository in which this change occurred.
@item branch
the branch on which this change occurred. Note that 'trunk' or 'master' is often
denoted by @code{None}.
@item category
the category, again as defined by the ChangeSource.
@end itemize

For each attribute, the filter can look for a single, specific value:
@example
my_filter = ChangeFilter(project = 'myproject')
@end example

or accept any of a set of values:

@example
my_filter = ChangeFilter(project = ['myproject', 'jimsproject'])
@end example

It can apply a regular expression, use the attribute name with a suffix of
@code{_re}:

@example
my_filter = ChangeFilter(category_re = '.*deve.*')
# or, to use regular expression flags:
import re
my_filter = ChangeFilter(category_re = re.compile('.*deve.*', re.I))
@end example

For anything more complicated, define a Python function to recognize the strings
you want:

@example
def my_branch_fn(branch):
    return branch in branches_to_build and branch not in branches_to_ignore
my_filter = ChangeFilter(branch_fn = my_branch_fn)
@end example

The special argument @code{filter_fn} can be used to specify a function that is
given the entire Change object, and returns a boolean.

A Change passes the filter only if @i{all} arguments are satisfied. If no
filter object is given to a scheduler, then all changes will be built (subject
to any other restrictions the scheduler enforces).

@node Scheduler Scheduler
@subsection Scheduler Scheduler
@slindex buildbot.schedulers.basic.Scheduler

This is the original and still most popular 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.

The arguments to this scheduler are:

@table @code
@item name

@item builderNames

@item properties

@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.

If treeStableTimer is @code{None}, then a separate build is started
immediately for each Change.

@item fileIsImportant
A callable which takes one argument, a Change instance, and returns
@code{True} if the change is worth building, and @code{False} if
it is not. Unimportant Changes are accumulated until the build is
triggered by an important change. The default value of None means
that all Changes are important.

@item change_filter

The change filter that will determine whch changes are recognized by this
Scheduler. Note that this is different from @code{fileIsImportant}: if the
change filter filters out a Change, then it is completely ignored by the
scheduler. If a Change is allowed by the change filter, but is deemed
unimportant, then it will not cause builds to start, but will be remembered and
shown in status displays.

@item categories (deprecated; use change_filter)
A list of categories of changes that this scheduler will respond to. If this
is specified, then any non-matching changes are ignored.

@item branch (deprecated; use change_filter)

If specified, then 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"}.

@end table

Example:

@example
from buildbot.schedulers.basic import Scheduler
quick = Scheduler(name="quick",
                    branch=None,
                    treeStableTimer=60,
                    builderNames=["quick-linux", "quick-netbsd"])
full = Scheduler(name="full",
                    branch=None,
                    treeStableTimer=5*60,
                    builderNames=["full-linux", "full-netbsd", "full-OSX"])
c['schedulers'] = [quick, full]
@end example

In this example, the two ``quick'' builders 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.

@node AnyBranchScheduler
@subsection AnyBranchScheduler
@slindex buildbot.schedulers.basic.AnyBranchScheduler

This scheduler uses a tree-stable-timer like the default one, but
uses a separate timer for each branch.

The arguments to this scheduler are:

@table @code
@item name

@item builderNames

@item properties

@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 fileIsImportant
A callable which takes one argument, a Change instance, and returns
@code{True} if the change is worth building, and @code{False} if
it is not. Unimportant Changes are accumulated until the build is
triggered by an important change. The default value of None means
that all Changes are important.

@item change_filter
The change filter that will determine whch changes are recognized by this
Scheduler. Note that this is different from @code{fileIsImportant}: if the
change filter filters out a Change, then it is completely ignored by the
scheduler. If a Change is allowed by the change filter, but is deemed
unimportant, then it will not cause builds to start, but will be remembered and
shown in status displays.

@item branches (deprecated; use change_filter)
This Scheduler will pay attention to any number of branches, ignoring
Changes that occur on other branches.

@item categories (deprecated; use change_filter)
A list of categories of changes that this scheduler will respond to. If this
is specified, then any non-matching changes are ignored.

@end table

@node Dependent Scheduler
@subsection Dependent Scheduler
@cindex Dependent
@cindex Dependencies
@slindex buildbot.schedulers.basic.Dependent

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 ``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 build fails on any of the Builders in the upstream set,
the downstream builds will not fire. Note that, for SourceStamps
generated by a ChangeSource, the @code{revision} is None, meaning HEAD.
If any changes are committed between the time the upstream scheduler
begins its build and the time the dependent scheduler begins its
build, then those changes will be included in the downstream build.
See the @pxref{Triggerable Scheduler} for a more flexible dependency
mechanism that can avoid this problem.

The keyword arguments to this scheduler are:

@table @code
@item name

@item builderNames

@item properties

@item upstream
The upstream scheduler to watch. Note that this is an ``instance'',
not the name of the scheduler.
@end table

Example:

@example
from buildbot.schedulers import basic
tests = basic.Scheduler("just-tests", None, 5*60,
                            ["full-linux", "full-netbsd", "full-OSX"])
package = basic.Dependent(name="build-package",
                              upstream=tests, # <- no quotes!
                              builderNames=["make-tarball", "make-deb", "make-rpm"])
c['schedulers'] = [tests, package]
@end example

@node Periodic Scheduler
@subsection Periodic Scheduler
@slindex buildbot.schedulers.timed.Periodic

This simple scheduler just triggers a build every N seconds.

The arguments to this scheduler are:

@table @code
@item name

@item builderNames

@item properties

@item periodicBuildTimer
The time, in seconds, after which to start a build.
@end table

Example:

@example
from buildbot.schedulers import timed
nightly = timed.Periodic(name="nightly",
                builderNames=["full-solaris"],
                periodicBuildTimer=24*60*60)
c['schedulers'] = [nightly]
@end example

The 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.

@node Nightly Scheduler
@subsection Nightly Scheduler
@slindex buildbot.schedulers.timed.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.

Pass some subset of @code{minute}, @code{hour}, @code{dayOfMonth},
@code{month}, and @code{dayOfWeek}; each may be a single number or
a list of valid values. The builds will be triggered whenever the
current time matches these values. Wildcards are represented by a
'*' string. All fields default to a wildcard except 'minute', so
with no fields this defaults to a build every hour, on the hour.
The full list of parameters is:

@table @code
@item name

@item builderNames

@item properties

@item branch
The branch to build when the time comes.

@item minute
The minute of the hour on which to start the build. This defaults
to 0, meaning an hourly build.

@item hour
The hour of the day on which to start the build, in 24-hour notation.
This defaults to *, meaning every hour.

@item month
The month in which to start the build, with January = 1. This defaults
to *, meaning every month.

@item dayOfWeek
The day of the week to start a build, with Monday = 0. This defauls
to *, meaning every day of the week.

@item onlyIfChanged
If this is true, then builds will not be scheduled at the designated time
unless the source has changed since the previous build.
@end table

For example, the following master.cfg clause will cause a build to be
started every night at 3:00am:

@example
from buildbot.schedulers import timed
s = timed.Nightly(name='nightly',
        builderNames=['builder1', 'builder2'],
        hour=3,
        minute=0)
@end example

This scheduler will perform a build each monday morning at 6:23am and
again at 8:23am, but only if someone has committed code in the interim:

@example
s = timed.Nightly(name='BeforeWork',
         builderNames=['builder1'],
         dayOfWeek=0,
         hour=[6,8],
         minute=23,
         onlyIfChanged=True)
@end example

The following runs a build every two hours, using Python's @code{range}
function:

@example
s = timed.Nightly(name='every2hours',
        builderNames=['builder1'],
        hour=range(0, 24, 2))
@end example

Finally, this example will run only on December 24th:

@example
s = timed.Nightly(name='SleighPreflightCheck',
        builderNames=['flying_circuits', 'radar'],
        month=12,
        dayOfMonth=24,
        hour=12,
        minute=0)
@end example

@node Try Schedulers
@subsection Try Schedulers
@slindex buildbot.schedulers.trysched.Try_Jobdir
@slindex buildbot.schedulers.trysched.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.

Two implementations are available: @code{Try_Jobdir} and
@code{Try_Userpass}. The former monitors a job directory, specified
by the @code{jobdir} parameter, while the latter listens for PB
connections on a specific @code{port}, and authenticates against
@code{userport}.

@node Triggerable Scheduler
@subsection Triggerable Scheduler
@cindex Triggers
@slindex buildbot.schedulers.triggerable.Triggerable

The @code{Triggerable} scheduler waits to be triggered by a Trigger
step (see @ref{Triggering Schedulers}) in another build. That step
can optionally wait for the scheduler's builds to complete. This
provides two advantages over Dependent schedulers. First, the same
scheduler can be triggered from multiple builds. Second, the ability
to wait for a Triggerable's builds to complete provides a form of
"subroutine call", where one or more builds can "call" a scheduler
to perform some work for them, perhaps on other buildslaves.

The parameters are just the basics:

@table @code
@item name
@item builderNames
@item properties
@end table

This class is only useful in conjunction with the @code{Trigger} step.
Here is a fully-worked example:

@example
from buildbot.schedulers import basic, timed, triggerable
from buildbot.process import factory
from buildbot.steps import trigger

checkin = basic.Scheduler(name="checkin",
            branch=None,
            treeStableTimer=5*60,
            builderNames=["checkin"])
nightly = timed.Nightly(name='nightly',
            builderNames=['nightly'],
            hour=3,
            minute=0)

mktarball = triggerable.Triggerable(name="mktarball",
                builderNames=["mktarball"])
build = triggerable.Triggerable(name="build-all-platforms",
                builderNames=["build-all-platforms"])
test = triggerable.Triggerable(name="distributed-test",
                builderNames=["distributed-test"])
package = triggerable.Triggerable(name="package-all-platforms",
                builderNames=["package-all-platforms"])

c['schedulers'] = [mktarball, checkin, nightly, build, test, package]

# on checkin, make a tarball, build it, and test it
checkin_factory = factory.BuildFactory()
checkin_factory.addStep(trigger.Trigger(schedulerNames=['mktarball'],
                                       waitForFinish=True))
checkin_factory.addStep(trigger.Trigger(schedulerNames=['build-all-platforms'],
                                   waitForFinish=True))
checkin_factory.addStep(trigger.Trigger(schedulerNames=['distributed-test'],
                                  waitForFinish=True))

# and every night, make a tarball, build it, and package it
nightly_factory = factory.BuildFactory()
nightly_factory.addStep(trigger.Trigger(schedulerNames=['mktarball'],
                                       waitForFinish=True))
nightly_factory.addStep(trigger.Trigger(schedulerNames=['build-all-platforms'],
                                   waitForFinish=True))
nightly_factory.addStep(trigger.Trigger(schedulerNames=['package-all-platforms'],
                                     waitForFinish=True))
@end example

@node Scheduler Index
@subsection Scheduler Index
@printindex sl
Something went wrong with that request. Please try again.