heinst
heinst

Reputation: 8786

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?

Upvotes: 2

Views: 5513

Answers (1)

Daniel Beck
Daniel Beck

Reputation: 6513

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().

Upvotes: 6

Related Questions