Add option to report elapsed build times.
The new format will be:
"http://logs.example.com/6/1/gate/project2-merge/2 : SUCCESS in 00:00:00"
And the option is enabled by default.
Change-Id: Ib50c4948ea0a7b552d46a0e72ecb6c1a9609a771
Reviewed-on: https://review.openstack.org/27570
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
diff --git a/doc/source/zuul.rst b/doc/source/zuul.rst
index 668bb8f..d79600f 100644
--- a/doc/source/zuul.rst
+++ b/doc/source/zuul.rst
@@ -100,6 +100,11 @@
git_dir.
``push_change_refs=true``
+**report_times**
+ Boolean value (``true`` or ``false``) that determines if Zuul should
+ include elapsed times for each job in the textual report.
+ ``report_times=true``
+
**status_url**
URL that will be posted in Zuul comments made to Gerrit changes when
beginning Jenkins jobs for a change.
diff --git a/zuul/scheduler.py b/zuul/scheduler.py
index 364d543..7abb803 100644
--- a/zuul/scheduler.py
+++ b/zuul/scheduler.py
@@ -508,6 +508,11 @@
self.success_action = {}
self.failure_action = {}
self.start_action = {}
+ if self.sched.config.has_option('zuul', 'report_times'):
+ self.report_times = self.sched.config.getboolean(
+ 'zuul', 'report_times')
+ else:
+ self.report_times = True
def __str__(self):
return "<%s %s>" % (self.__class__.__name__, self.pipeline.name)
@@ -884,7 +889,14 @@
voting = ' (non-voting)'
else:
voting = ''
- ret += '- %s : %s%s\n' % (url, result, voting)
+ if self.report_times and build.end_time and build.start_time:
+ dt = int(build.end_time - build.start_time)
+ m, s = divmod(dt, 60)
+ h, m = divmod(m, 60)
+ elapsed = ' in %02d:%02d:%02d' % (h, m, s)
+ else:
+ elapsed = ''
+ ret += '- %s : %s%s%s\n' % (url, result, elapsed, voting)
return ret
def formatDescription(self, build):