Tester
Tester

Reputation: 53

How to get the end the time of the current jenkins build in pipeline code?

My requirement is to get the end time of the current build in pipeline code. How to get it?

Upvotes: 1

Views: 1251

Answers (1)

towel
towel

Reputation: 2214

You can take currentBuild.startTimeInMillis + currentBuild.duration at the end of the build:

import java.util.Date
import java.text.SimpleDateFormat
...
def endTime = currentBuild.startTimeInMillis + currentBuild.duration
def endTimeString = new SimpleDateFormat("HH:mm:ss.SSS").format(new Date(endTime))
println endTimeString

Upvotes: 1

Related Questions