Skip to content

Commit

Permalink
Merge prasoon2211/buildbot:setPropFromComm_issue2928 (PR #1590)
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Mar 16, 2015
2 parents d07a195 + a5308c0 commit 44993d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 9 additions & 2 deletions master/buildbot/steps/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,26 @@ class SetPropertyFromCommand(ShellCommand):
name = "setproperty"
renderables = ['property']

def __init__(self, property=None, extract_fn=None, strip=True, **kwargs):
def __init__(self, property=None, extract_fn=None, strip=True,
includeStdout=True, includeStderr=False, **kwargs):
self.property = property
self.extract_fn = extract_fn
self.strip = strip
self.includeStdout = includeStdout
self.includeStderr = includeStderr

if not ((property is not None) ^ (extract_fn is not None)):
config.error(
"Exactly one of property and extract_fn must be set")

ShellCommand.__init__(self, **kwargs)

if self.extract_fn:
self.includeStderr = True

self.observer = logobserver.BufferLogObserver(
wantStdout=True, wantStderr=self.extract_fn)
wantStdout=self.includeStdout,
wantStderr=self.includeStderr)
self.addLogObserver('stdio', self.observer)

self.property_changes = {}
Expand Down
6 changes: 6 additions & 0 deletions master/docs/manual/cfg-buildsteps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2216,12 +2216,18 @@ To avoid stripping, add ``strip=False``.

The ``property`` argument can be specified as a :ref:`Interpolate` object, allowing the property name to be built from other property values.

Passing ``includeStdout=False`` (default ``True``) stops capture from stdout.

Passing ``includeStderr=True`` (default ``False``) allows capture from stderr.

The more advanced usage allows you to specify a function to extract properties from the command output.
Here you can use regular expressions, string interpolation, or whatever you would like.
In this form, :func:`extract_fn` should be passed, and not :class:`Property`.
The :func:`extract_fn` function is called with three arguments: the exit status of the command, its standard output as a string, and its standard error as a string.
It should return a dictionary containing all new properties.

Note that passing in :func:`extract_fn` will set ``includeStderr`` to ``True``.

::

def glob2list(rc, stdout, stderr):
Expand Down

0 comments on commit 44993d1

Please sign in to comment.