简体   繁体   English

使用构建后的Groovy脚本获取构建持续时间(Jenkins / Hudson)

[英]Get build duration using post-build Groovy script (Jenkins/Hudson)

I have a post build script and am trying to get the build duration. 我有一个后构建脚本,正在尝试获取构建持续时间。 I am trying to get it like so: 我正在努力让它像这样:

def build = manager.build
build.duration.toString()

but that just yields 0. Is there a way I can get the build duration using a post build groovy script? 但这只会产生0。有没有一种方法可以使用构建后的Groovy脚本获取构建持续时间?

While a build is still running, the duration has not yet been set. 虽然构建仍在运行,但持续时间尚未设置。 Use Run.getDurationString() instead, or get the current duration from the difference between Run.getTimeInMillis() and System.currentTimeMillis() . 请改用Run.getDurationString() ,或者从Run.getTimeInMillis()System.currentTimeMillis()之间的差中获取当前持续时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM