On Tue, Mar 15, 2016 at 6:48 AM, Pierre Tardy <tar...@gmail.com> wrote: >> > For eight indeed you are pretty much bound to polling the json api. >> One bit of data I don't know how to access is the build request's >> submitted_at time. How would one get at that via json? > > Looks like there is none alas. I had to hack one or two endpoints in my own > old eight instance.
What about in nine -- will the stats service expose submitted_at (or its more interesting dual, latency = start_time - submitted_at)? Back on eight, this hack seems to work, but of course doesn't give me anything for old builds (Is there a way to get the real submitted_at as a property, instead of faking it?): --- a/master/buildbot/schedulers/base.py +++ b/master/buildbot/schedulers/base.py @@ -23,6 +23,7 @@ from twisted.internet import defer from twisted.python import failure from twisted.python import log from zope.interface import implements +import time class BaseScheduler(service.MultiService, ComparableMixin, StateMixin): @@ -442,6 +443,9 @@ class BaseScheduler(service.MultiService, ComparableMixin, StateMixin): if not builderNames: builderNames = self.builderNames + # fake submitted_at; it should come from BuildSetStatus, really? + properties.setProperty("submitted_at", str(time.time()), "fakedByBaseScheduler", True) + # translate properties object into a dict as required by the # addBuildset method properties_dict = properties.asDict() --- a/master/contrib/buildbot_json.py +++ b/master/contrib/buildbot_json.py @@ -692,7 +692,7 @@ class BuildSteps(NonAddressableNodeList): class Build(AddressableDataNode): printable_attributes = AddressableDataNode.printable_attributes + [ 'key', 'number', 'steps', 'blame', 'reason', 'revision', 'result', - 'simplified_result', 'start_time', 'end_time', 'duration', 'slave', + 'simplified_result', 'start_time', 'end_time', 'latency', 'duration', 'slave', 'properties', 'completed', ] @@ -715,6 +715,14 @@ class Build(AddressableDataNode): return self.parent.parent.parent.parent.builders[self.data['builderName']] @property + def latency(self): + if self.data.get('times'): + for p in self.data.get('properties'): + if p[0] == 'submitted_at': + submitted_at = int(round(float(p[1]))) + return self.start_time - submitted_at + + @property def start_time(self): if self.data.get('times'): return int(round(self.data['times'][0])) _______________________________________________ users mailing list users@buildbot.net https://lists.buildbot.net/mailman/listinfo/users