avoid incosistent timestamps by using parent start time if available

Signed-off-by: Jakub Sokołowski <jakub@status.im>
Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
Jakub Sokołowski 2019-02-04 20:02:38 +01:00 committed by Igor Mandrigin
parent 256401c417
commit bf51592496
No known key found for this signature in database
GPG Key ID: 4A0EDDE26E66BC8B
1 changed files with 8 additions and 1 deletions

View File

@ -163,8 +163,15 @@ def uploadArtifact(path) {
return "https://${bucket}.${domain}/${getFilename(path)}"
}
def parentOrCurrentBuild() {
def c = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause)
if (c == null) { return currentBuild }
return c.getUpstreamRun()
}
def timestamp() {
def now = new Date(currentBuild.timeInMillis)
/* we use parent if available to make timestmaps consistent */
def now = new Date(parentOrCurrentBuild().timeInMillis)
return now.format('yyMMdd-HHmmss', TimeZone.getTimeZone('UTC'))
}