Skip to content

Commit

Permalink
remove branch example
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Aug 29, 2011
1 parent e1c185c commit 8aee38b
Showing 1 changed file with 0 additions and 98 deletions.
98 changes: 0 additions & 98 deletions master/docs/manual/cfg-buildsteps.rst
Expand Up @@ -907,107 +907,9 @@ should preferentially create the ``SVN`` step with the
depth-infinity. Infinity is equivalent to SVN default update behavior, without
specifying any depth argument.


If you are using branches, you must also make sure your
:class:`ChangeSource` will report the correct branch names.

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:

.. code-block:: none
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
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 :class:`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 :bb:chsrc:`PBChangeSource` over a TCP
connection. (you can use the ``buildbot sendchange`` utility
for this purpose, but you will still need an external program to
decide what value should be passed to the :option:`--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 :class:`Change` instance with
``branch='features/newthing'`` and ``file='src/foo.c'``.

The second piece is an :bb:sched:`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 :bb:sched:`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
``branch.startswith('features/')`` to remove the need for this
explicit list. Or, if you want to build user branches too, you can use
:bb:sched:`AnyBranchScheduler` with ``branches=None`` to indicate that you want
it to pay attention to all branches.

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

from buildbot.changes.pb import PBChangeSource
from buildbot.scheduler import AnyBranchScheduler
from buildbot.process import source, factory
from buildbot.steps import source, shell
c['change_source'] = PBChangeSource()
s1 = AnyBranchScheduler('main',
['trunk', 'features/newthing', 'features/otherthing'],
10*60, ['test-i386', 'test-ppc'])
c['schedulers'] = [s1]
f = factory.BuildFactory()
f.addStep(source.SVN(mode='update',
baseURL='svn://svn.example.org/MyProject/',
defaultBranch='trunk'))
f.addStep(shell.Compile(command="make all"))
f.addStep(shell.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 },
]

In this example, when a change arrives with a ``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 :file:`src/foo.c`, then the SVN step
will concatenate ``svn://svn.example.org/MyProject/`` with
``features/newthing`` to get the svnurl for checkout.

For added flexibility, ``baseURL`` may contain a ``%%BRANCH%%``
placeholder, which will be replaced either by the branch in the SourceStamp or
the default specified in ``defaultBranch``. ::

source.SVN( mode='update',
baseURL='svn://svn.example.org/svn/%%BRANCH%%/myproject',
defaultBranch='trunk' )

.. bb:step:: Darcs (Old)
Darcs (Old)
Expand Down

0 comments on commit 8aee38b

Please sign in to comment.