Skip to content

Commit

Permalink
Merge branch 'patch-3' of git://github.com/benallard/buildbot
Browse files Browse the repository at this point in the history
* 'patch-3' of git://github.com/benallard/buildbot:
  Add a test for the url argument of the FileUpload step
  Update documentation about the url parameter of the transfer steps
  Add an url parameter to the FileFransfer steps to show in the HTML status
  • Loading branch information
djmitche committed Oct 9, 2011
2 parents 7f9c6af + 9320cfe commit 9642f9d
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 16 deletions.
15 changes: 12 additions & 3 deletions master/buildbot/steps/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,11 @@ class FileUpload(_TransferBuildStep):

name = 'upload'

renderables = [ 'slavesrc', 'masterdest' ]
renderables = [ 'slavesrc', 'masterdest', 'url' ]

def __init__(self, slavesrc, masterdest,
workdir=None, maxsize=None, blocksize=16*1024, mode=None, keepstamp=False,
workdir=None, maxsize=None, blocksize=16*1024, mode=None,
keepstamp=False, url=None,
**buildstep_kwargs):
BuildStep.__init__(self, **buildstep_kwargs)
self.addFactoryArguments(slavesrc=slavesrc,
Expand All @@ -241,6 +242,7 @@ def __init__(self, slavesrc, masterdest,
blocksize=blocksize,
mode=mode,
keepstamp=keepstamp,
url=url,
)

self.slavesrc = slavesrc
Expand All @@ -251,6 +253,7 @@ def __init__(self, slavesrc, masterdest,
assert isinstance(mode, (int, type(None)))
self.mode = mode
self.keepstamp = keepstamp
self.url = url

def start(self):
version = self.slaveVersion("uploadFile")
Expand All @@ -270,6 +273,8 @@ def start(self):
% (source, masterdest))

self.step_status.setText(['uploading', os.path.basename(source)])
if self.url is not None:
self.addURL(os.path.basename(masterdest), self.url)

# we use maxsize to limit the amount of data on both sides
fileWriter = _FileWriter(masterdest, self.maxsize, self.mode)
Expand Down Expand Up @@ -302,14 +307,15 @@ class DirectoryUpload(_TransferBuildStep):

def __init__(self, slavesrc, masterdest,
workdir=None, maxsize=None, blocksize=16*1024,
compress=None, **buildstep_kwargs):
compress=None, url=None, **buildstep_kwargs):
BuildStep.__init__(self, **buildstep_kwargs)
self.addFactoryArguments(slavesrc=slavesrc,
masterdest=masterdest,
workdir=workdir,
maxsize=maxsize,
blocksize=blocksize,
compress=compress,
url=url,
)

self.slavesrc = slavesrc
Expand All @@ -319,6 +325,7 @@ def __init__(self, slavesrc, masterdest,
self.blocksize = blocksize
assert compress in (None, 'gz', 'bz2')
self.compress = compress
self.url = url

def start(self):
version = self.slaveVersion("uploadDirectory")
Expand All @@ -338,6 +345,8 @@ def start(self):
% (source, masterdest))

self.step_status.setText(['uploading', os.path.basename(source)])
if self.url is not None:
self.addURL(os.path.basename(masterdest), self.url)

# we use maxsize to limit the amount of data on both sides
dirWriter = _DirectoryWriter(masterdest, self.maxsize, self.compress, 0600)
Expand Down
29 changes: 29 additions & 0 deletions master/buildbot/test/unit/test_steps_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,35 @@ def testTimestamp(self):
self.assertAlmostEquals(timestamp[0],desttimestamp[0],places=5)
self.assertAlmostEquals(timestamp[1],desttimestamp[1],places=5)

def testURL(self):
s = FileUpload(slavesrc=__file__, masterdest=self.destfile, url="http://server/file")
s.build = Mock()
s.build.getProperties.return_value = Properties()
s.build.getSlaveCommandVersion.return_value = "2.13"

s.step_status = Mock()
s.step_status.addURL = Mock()
s.buildslave = Mock()
s.remote = Mock()
s.start()

for c in s.remote.method_calls:
name, command, args = c
commandName = command[3]
kwargs = command[-1]
if commandName == 'uploadFile':
self.assertEquals(kwargs['slavesrc'], __file__)
writer = kwargs['writer']
writer.remote_write(open(__file__, "rb").read())
self.assert_(not os.path.exists(self.destfile))
writer.remote_close()
break
else:
self.assert_(False, "No uploadFile command found")

s.step_status.addURL.assert_called_once_with(
os.path.basename(self.destfile), "http://server/file")

class TestStringDownload(unittest.TestCase):
def testBasic(self):
s = StringDownload("Hello World", "hello.txt")
Expand Down
30 changes: 24 additions & 6 deletions master/docs/manual/cfg-buildsteps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2095,21 +2095,26 @@ project documentation. We want to move this file to the buildmaster,
into a :file:`~/public_html` directory, so it can be visible to
developers. This file will wind up in the slave-side working directory
under the name :file:`docs/reference.html`. We want to put it into the
master-side :file:`~/public_html/ref.html`. ::
master-side :file:`~/public_html/ref.html`, and add a link to the HTML
status to the uploaded file. ::

from buildbot.steps.shell import ShellCommand
from buildbot.steps.transfer import FileUpload
f.addStep(ShellCommand(command=["make", "docs"]))
f.addStep(FileUpload(slavesrc="docs/reference.html",
masterdest="~/public_html/ref.html"))
masterdest="~/public_html/ref.html",
url="/~buildbot/ref.html"))

The ``masterdest=`` argument will be passed to :meth:`os.path.expanduser`,
so things like ``~`` will be expanded properly. Non-absolute paths
will be interpreted relative to the buildmaster's base directory.
Likewise, the ``slavesrc=`` argument will be expanded and
interpreted relative to the builder's working directory.

.. note:: The copied file will have the same permissions on the master
as on the slave, look at the ``mode=`` parameter to set it
differently.

To move a file from the master to the slave, use the
:bb:step:`FileDownload` command. For example, let's assume that some step
Expand Down Expand Up @@ -2157,8 +2162,15 @@ creation time (:ref:`Buildslave-Options`).

The ``keepstamp=`` argument is a boolean that, when ``True``, forces
the modified and accessed time of the destination file to match the
times of the source file. When ``False`` (the default), the modified and accessed times
of the destination file are set to the current time on the buildmaster.
times of the source file. When ``False`` (the default), the modified
and accessed times of the destination file are set to the current time
on the buildmaster.

The ``url=`` argument allows you to specify an url that will be
displayed in the HTML status. The title of the url will be the name of
the item transfered (directory for :class:`DirectoryUpload` or file
for :class:`FileUpload`). This allows the user to add a link to the
uploaded item if that one is uploaded to an accessible place.

.. bb:step:: DirectoryUpload
Expand All @@ -2173,15 +2185,17 @@ just for directories. However it does not support the ``maxsize``,
``blocksize`` and ``mode`` arguments. As an example, let's assume an
generated project documentation, which consists of many files (like the output
of :command:`doxygen` or :command:`epydoc`). We want to move the entire documentation to the
buildmaster, into a :file:`~/public_html/docs` directory. On the slave-side
buildmaster, into a :file:`~/public_html/docs` directory, and add a
link to the uploaded documentation on the HTML status page. On the slave-side
the directory can be found under :file:`docs`::

from buildbot.steps.shell import ShellCommand
from buildbot.steps.transfer import DirectoryUpload
f.addStep(ShellCommand(command=["make", "docs"]))
f.addStep(DirectoryUpload(slavesrc="docs",
masterdest="~/public_html/docs"))
masterdest="~/public_html/docs",
url="~buildbot/docs"))

The :bb:step:`DirectoryUpload` step will create all necessary directories and
transfers empty directories, too.
Expand All @@ -2194,6 +2208,10 @@ encoding used (currently tar).
The optional ``compress`` argument can be given as ``'gz'`` or
``'bz2'`` to compress the datastream.

.. note:: The permissions on the copied files will be the same on the
master as originately on the slave, see :option:`buildslave
create-slave --umask` to change the default one.

.. bb:step:: StringDownload
.. bb:step:: JSONStringDownload
.. bb:step:: JSONPropertiesDownload
Expand Down
23 changes: 16 additions & 7 deletions master/docs/manual/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -560,19 +560,24 @@ command line, like this
buildslave create-slave --umask=022 ~/buildslave buildmaster.example.org:42012 {myslavename} {mypasswd}
``--no-logrotate``
.. program:: buildslave create-slave

.. option:: --no-logrotate

This disables internal buildslave log management mechanism. With this option
buildslave does not override the default logfile name and its behaviour giving
a possibility to control those with command-line options of twistd
daemon.

``--usepty``
.. option:: --usepty

This is a boolean flag that tells the buildslave whether to launch child
processes in a PTY or with regular pipes (the default) when the master does not
specify. This option is deprecated, as this particular parameter is better
specified on the master.

``--umask``
.. option:: --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
Expand All @@ -584,7 +589,8 @@ command line, like this
build products to be *writable* by other accounts too, use
``--umask=000``, but this is likely to be a security problem.

``--keepalive``
.. option:: --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
Expand All @@ -598,16 +604,19 @@ command line, like this
disappeared, and builds will time out. Meanwhile the buildslave will
not realize than anything is wrong.

``--maxdelay``
.. option:: --maxdelay

This is a number that indicates the maximum amount of time the
buildslave will wait between connection attempts, expressed in
seconds. The default (300) causes the buildslave to wait at most 5
minutes before trying to connect to the buildmaster again.

``--log-size``
.. option:: --log-size

This is the size in bytes when to rotate the Twisted log files.

``--log-count``
.. option:: --log-count

This is the number of log rotations to keep around. You can either
specify a number or ``None`` to keep all :file:`twistd.log` files
around. The default is 10.
Expand Down

0 comments on commit 9642f9d

Please sign in to comment.