.. bb:step:: SVN

.. _Step-SVN:

SVN
+++

.. py:class:: buildbot.steps.source.svn.SVN

The :bb:step:`SVN` build step performs a `Subversion <https://subversion.apache.org>`_ checkout or update.
There are two basic ways of setting up the checkout step, depending upon whether you are using multiple branches or not.

The :bb:step:`SVN` step should be created with the ``repourl`` argument:

``repourl``
   (required): this specifies the ``URL`` argument that will be given to the :command:`svn checkout` command.
   It dictates both where the repository is located and which sub-tree should be extracted.
   One way to specify the branch is to use ``Interpolate``.
   For example, if you wanted to check out the trunk repository, you could use ``repourl=Interpolate("http://svn.example.com/repos/%(src::branch)s")``.
   Alternatively, if you are using a remote Subversion repository which is accessible through HTTP at a URL of ``http://svn.example.com/repos``, and you wanted to check out the ``trunk/calc`` sub-tree, you would directly use ``repourl="http://svn.example.com/repos/trunk/calc"`` as an argument to your :bb:step:`SVN` step.

If you are building from multiple branches, then you should create the :bb:step:`SVN` step with the ``repourl`` and provide branch information with :ref:`Interpolate`:

.. code-block:: python

    from buildbot.plugins import steps, util

    factory.addStep(
        steps.SVN(mode='incremental',
                  repourl=util.Interpolate(
                      'svn://svn.example.org/svn/%(src::branch)s/myproject')))

Alternatively, the ``repourl`` argument can be used to create the :bb:step:`SVN` step without :ref:`Interpolate`:

.. code-block:: python

    from buildbot.plugins import steps

    factory.addStep(steps.SVN(mode='full',
                    repourl='svn://svn.example.org/svn/myproject/trunk'))

``username``
   (optional): if specified, this will be passed to the ``svn`` binary with a ``--username`` option.

``password``
   (optional): if specified, this will be passed to the ``svn`` binary with a ``--password`` option.

``extra_args``
   (optional): if specified, an array of strings that will be passed as extra arguments to the ``svn`` binary.

``keep_on_purge``
   (optional): specific files or directories to keep between purges, like some build outputs that can be reused between builds.

``depth``
   (optional): Specify depth argument to achieve sparse checkout.
   Only available if worker has Subversion 1.5 or higher.

   If set to ``empty`` updates will not pull in any files or subdirectories not already present.
   If set to ``files``, updates will pull in any files not already present, but not directories.
   If set to ``immediates``, updates will pull in any files or subdirectories not already present, the new subdirectories will have depth: empty.
   If set to ``infinity``, updates will pull in any files or subdirectories not already present; the new subdirectories will have depth-infinity.
   Infinity is equivalent to SVN default update behavior, without specifying any depth argument.

``preferLastChangedRev``
   (optional): By default, the ``got_revision`` property is set to the repository's global revision ("Revision" in the `svn info` output).
   Set this parameter to ``True`` to have it set to the "Last Changed Rev" instead.

``mode``
``method``

   SVN's incremental mode does not require a method.
   The full mode has five methods defined:

   ``clobber``
      It removes the working directory for each build then makes full checkout.

   ``fresh``
      This always always purges local changes before updating.
      This deletes unversioned files and reverts everything that would appear in a :command:`svn status --no-ignore`.
      This is equivalent to the old update mode with ``always_purge``.

   ``clean``
      This is same as fresh except that it deletes all unversioned files generated by :command:`svn status`.

   ``copy``
      This first checkout source into source directory then copy the ``source`` directory to ``build`` directory then performs the build operation in the copied directory.
      This way we make fresh builds with very less bandwidth to download source.
      The behavior of source checkout follows exactly same as incremental.
      It performs all the incremental checkout behavior in ``source`` directory.

   ``export``
      Similar to ``method='copy'``, except using ``svn export`` to create build directory so that there are no ``.svn`` directories in the build directory.

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