Skip to content

Commit

Permalink
Merge branch 'webstatus_property_filter' of git://github.com/andrewjc…
Browse files Browse the repository at this point in the history
…g/buildbot
  • Loading branch information
djmitche committed May 15, 2013
2 parents 000e727 + b70b6d5 commit e6fd9ac
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
6 changes: 5 additions & 1 deletion master/buildbot/status/builder.py
Expand Up @@ -336,7 +336,8 @@ def generateFinishedBuilds(self, branches=[],
max_buildnum=None,
finished_before=None,
results=None,
max_search=200):
max_search=200,
filter_fn=None):
got = 0
branches = set(branches)
for Nb in itertools.count(1):
Expand All @@ -363,6 +364,9 @@ def generateFinishedBuilds(self, branches=[],
if results is not None:
if build.getResults() not in results:
continue
if filter_fn is not None:
if not filter_fn(build):
continue
got += 1
yield build
if num_builds is not None:
Expand Down
26 changes: 24 additions & 2 deletions master/buildbot/status/web/builder.py
Expand Up @@ -250,13 +250,29 @@ def builder(self, build, req):
def content(self, req, cxt):
b = self.builder_status

# Grab all the parameters which are prefixed with 'property.'.
# We'll use these to filter the builds and build requests we
# show below.
props = {}
prop_prefix = 'property.'
for arg, val in req.args.iteritems():
if arg.startswith(prop_prefix):
props[arg[len(prop_prefix):]] = val[0]
def prop_match(oprops):
for key, val in props.iteritems():
if key not in oprops or val != str(oprops[key]):
return False
return True

cxt['name'] = b.getName()
cxt['description'] = b.getDescription()
req.setHeader('Cache-Control', 'no-cache')
slaves = b.getSlaves()
connected_slaves = [s for s in slaves if s.isConnected()]

cxt['current'] = [self.builder(x, req) for x in b.getCurrentBuilds()]
cxt['current'] = [
self.builder(x, req) for x in b.getCurrentBuilds()
if prop_match(x.getProperties())]

cxt['pending'] = []
statuses = yield b.getPendingBuildRequestStatuses()
Expand All @@ -269,6 +285,8 @@ def content(self, req, cxt):

properties = yield \
pb.master.db.buildsets.getBuildsetProperties(bsid)
if not prop_match(properties):
continue

if source.changes:
for c in source.changes:
Expand All @@ -288,8 +306,12 @@ def content(self, req, cxt):
})

numbuilds = cxt['numbuilds'] = int(req.args.get('numbuilds', [self.numbuilds])[0])
maxsearch = int(req.args.get('maxsearch', [200])[0])
recent = cxt['recent'] = []
for build in b.generateFinishedBuilds(num_builds=int(numbuilds)):
for build in b.generateFinishedBuilds(
num_builds=int(numbuilds),
max_search=maxsearch,
filter_fn=lambda b: prop_match(b.getProperties())):
recent.append(self.get_line_values(req, build, False))

sl = cxt['slaves'] = []
Expand Down
5 changes: 4 additions & 1 deletion master/docs/manual/cfg-statustargets.rst
Expand Up @@ -302,7 +302,10 @@ be used to access them.
:samp:`/builders/${BUILDERNAME}`
This describes the given :class:`Builder` and provides buttons to force a
build. A ``numbuilds=`` argument will control how many build lines
are displayed (5 by default).
are displayed (5 by default). This page also accepts property filters
of the form ``property.${PROPERTYNAME}=${PROPERTVALUE}``. When used,
only builds and build requests which have properties with matching string
representations will be shown.

:samp:`/builders/${BUILDERNAME}/builds/${BUILDNUM}`
This describes a specific Build.
Expand Down
2 changes: 2 additions & 0 deletions master/docs/relnotes/index.rst
Expand Up @@ -32,6 +32,8 @@ Features

* The ``comments`` field of changes is no longer limited to 1024 characters on MySQL and Postgres. See :bb:bug:`2367` and :bb:pull:`736`.

* The WebStatus builder page can now filter pending/current/finished builds by property parameters of the form ``?property.<name>=<value>``.

Deprecations, Removals, and Non-Compatible Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit e6fd9ac

Please sign in to comment.