Skip to content

Commit

Permalink
Merge pull request #1380 from benallard/build_properties
Browse files Browse the repository at this point in the history
Build properties
  • Loading branch information
Mikhail Sobolev committed Nov 27, 2014
2 parents 7a432ba + b19dd1c commit a9fcf31
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions master/buildbot/process/build.py
Expand Up @@ -403,9 +403,22 @@ def startNextStep(self):
self.executedSteps.append(s)
self.currentStep = s
d = defer.maybeDeferred(s.startStep, self.conn)
d.addBoth(self._flushProperties)
d.addCallback(self._stepDone, s)
d.addErrback(self.buildException)

@defer.inlineCallbacks
def _flushProperties(self, results):
# `results` is just passed on to the next callback
props = interfaces.IProperties(self)

properties = props.getProperties().asList()
for name, value, source in properties:
yield self.master.data.updates.setBuildProperty(
self.buildid, name, value, source)

defer.returnValue(results)

def _stepDone(self, results, step):
self.currentStep = None
if self.finished:
Expand Down
23 changes: 23 additions & 0 deletions master/buildbot/test/unit/test_process_build.py
Expand Up @@ -633,6 +633,29 @@ def test_getSummaryStatistic(self):
self.assertEqual(b.getSummaryStatistic('casualties', add), 11)
self.assertEqual(b.getSummaryStatistic('casualties', add, 10), 21)

@defer.inlineCallbacks
def testflushProperties(self):
b = self.build

class FakeBuildStatus(Mock):
implements(interfaces.IProperties)
b.build_status = FakeBuildStatus()

class Properties(Mock):

def asList(self):
return [(u'p', 5, u'fake'),
(u'p2', ['abc', 9], u'mock')]
b.master.data.updates.setBuildProperty = Mock()
b.build_status.getProperties.return_value = Properties()
b.buildid = 42
result = 'SUCCESS'
res = yield b._flushProperties(result)
self.assertEquals(res, result)
b.master.data.updates.setBuildProperty.assert_has_calls([
call(42, u'p', 5, u'fake'),
call(42, u'p2', ['abc', 9], u'mock')])


class TestMultipleSourceStamps(unittest.TestCase):

Expand Down
2 changes: 2 additions & 0 deletions master/docs/relnotes/index.rst
Expand Up @@ -171,6 +171,8 @@ Fixes
* Fixed SVN master-side source step: if a SVN operation fails, the repository end up in a situation when a manual intervention is required.
Now if SVN reports such a situation during initial check, the checkout will be clobbered.

* The build properties are now stored in the database in the ``build_properties`` table.

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

Expand Down

0 comments on commit a9fcf31

Please sign in to comment.