2

how to display Following details in Jenkins Email notification

Last build (#86), 14 hr ago - Duration 5 mins and 30 sec

Last stable build (#79), 1 day 21 hr ago - Duration 5 mins and 30 sec

Last successful build (#79), 1 day 21 hr ago - Duration 5 mins and 30 sec

Last failed build (#86), 14 hr ago - Duration 5 mins and 30 sec

Last unsuccessful build (#86), 14 hr ago - Duration 5 mins and 30 sec

Last completed build (#86), 14 hr ago - Duration 5 mins and 30 sec

enter image description here enter image description here

I am finding difficulty in writing duration and date. It is displaying empty data.

Output in mail body as ${currentBuild.durationString} ${currentBuild.timeInMillis}

venkatesh
  • 93
  • 3
  • 11

1 Answers1

0

As in here, you could currentBuild.durationString (since Jenkins 2.14 and this issue resolved)

currentbuild is part of the global variable references

Its properties includes startTimeInMillis.
A Groovy script can help format those values and set them in a variable that cou can use in your post-build step.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @venkatesh Yes: 2.113 came well after 2.14. – VonC Jun 06 '19 at 09:53
  • i have used ${currentBuild.durationString}, ${currentBuild.timeInMillis} but it is not displaying any thing – venkatesh Jun 06 '19 at 12:51
  • @venkatesh As shown in the groovy script I reference in the answer (https://stackoverflow.com/a/54947196/6309), a variable like `currentBuild.durationString` is *not* accessed with `${...}`. The idea would be to use a groovy script to set variables with those values: said variables would then be referenced with `${avariable}` – VonC Jun 06 '19 at 20:03