Skip to content

Commit

Permalink
Ticket #2226 - Added build step LogRenderable
Browse files Browse the repository at this point in the history
  • Loading branch information
jbotto committed Mar 21, 2013
1 parent b540d7a commit 5bbff24
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
19 changes: 19 additions & 0 deletions master/buildbot/steps/master.py
Expand Up @@ -20,6 +20,7 @@
from buildbot.process.buildstep import SUCCESS, FAILURE
from twisted.internet import error
from twisted.internet.protocol import ProcessProtocol
import pprint

class MasterShellCommand(BuildStep):
"""
Expand Down Expand Up @@ -169,3 +170,21 @@ def interrupt(self, reason):
except error.ProcessExitedAlready:
pass
BuildStep.interrupt(self, reason)

class LogRenderable(BuildStep):
name='LogRenderable'
description=['Logging']
descriptionDone=['Logged']
renderables = ['content']

def __init__(self, content, **kwargs):
BuildStep.__init__(self, **kwargs)
self.content = content

def start(self):
content = pprint.pformat(self.content)
self.addCompleteLog(name='Output', text=content)
self.step_status.setText(self.describe(done=True))
self.finished(SUCCESS)


19 changes: 19 additions & 0 deletions master/buildbot/test/unit/test_steps_master.py
Expand Up @@ -22,6 +22,9 @@
from buildbot.status.results import SUCCESS, FAILURE, EXCEPTION
from buildbot.steps import master
from buildbot.process.properties import WithProperties
from buildbot.process.properties import Interpolate
import pprint


class TestMasterShellCommand(steps.BuildStepMixin, unittest.TestCase):

Expand Down Expand Up @@ -193,3 +196,19 @@ def test_constr_args_descriptionSuffix(self):
])
self.expectOutcome(result=SUCCESS, status_text=['y', 'z'])
return self.runStep()

class TestLogRenderable(steps.BuildStepMixin, unittest.TestCase):

def setUp(self):
return self.setUpBuildStep()

def tearDown(self):
return self.tearDownBuildStep()

def test_simple(self):
self.setupStep(master.LogRenderable(content=Interpolate('sch=%(prop:scheduler)s, slave=%(prop:slavename)s')))
self.properties.setProperty('scheduler', 'force', source='TestSetProperty', runtime=True)
self.properties.setProperty('slavename', 'testSlave', source='TestSetProperty', runtime=True)
self.expectOutcome(result=SUCCESS, status_text=['LogRenderable'])
self.expectLogfile('Output', pprint.pformat('sch=force, slave=testSlave'))
return self.runStep()
10 changes: 10 additions & 0 deletions master/docs/manual/cfg-buildsteps.rst
Expand Up @@ -2529,6 +2529,16 @@ be substituted using :ref:`Interpolate`.

``interruptSignal``
(optional) Signal to use to end the process, if the step is interrupted.

.. bb:step:: LogRenderable
LogRenderable
+++++++++++++

.. py:class:: buildbot.steps.master.LogRenderable
This build step takes content which can be renderable and logs it in a pretty-printed format.
It can be useful for debugging properties during a build.

.. index:: Properties; from steps

Expand Down
2 changes: 2 additions & 0 deletions master/docs/relnotes/index.rst
Expand Up @@ -43,6 +43,8 @@ Features

* The build request DB connector method :py:meth:`~buildbot.db.buildrequests.BuildRequestsConnectorComponent.getBuildRequests` can now filter by branch and repository.

* Added :bb:step:`LogRenderable`. This allows logging content including renderables.


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

0 comments on commit 5bbff24

Please sign in to comment.