Skip to content

Commit

Permalink
Fix getCommitTimestamp (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikRehmTT committed Sep 4, 2024
1 parent a32d77a commit 4c4bd09
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions vars/pipeline2ATX.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,11 @@ def calculateTime(executionTestSteps, build) {
def setupDuration = 0.0
def executionDuration = 0.0
def teardownDuration = 0.0
def commitTimeStamp = !env.GIT_COMMIT ? null : getCommitTimestamp()
def commitTimestamp = !env.GIT_COMMIT ? null : getCommitTimestamp()
def startTimeMillis = build.getStartTimeInMillis()
def queueDuration = (startTimeMillis - build.getTimeInMillis()) / 1000.0
def errorTime = calculateErrorTime(executionTestSteps)
def fromCommitToStartTime = !commitTimeStamp ? null : (startTimeMillis/1000.0) - commitTimeStamp
def fromCommitToStartTime = !commitTimestamp ? null : (startTimeMillis/1000.0) - commitTimestamp

executionTestSteps.each { stage ->
def stageName = stage.name
Expand Down Expand Up @@ -292,7 +292,7 @@ def calculateTime(executionTestSteps, build) {
totalDuration: convertTimeValueToDouble(totalDuration),
fromCommitToStartTime: fromCommitToStartTime != null ? convertTimeValueToDouble(fromCommitToStartTime) : null,
errorTime: errorTime != null ? convertTimeValueToDouble(setupDuration + queueDuration + errorTime) : null,
commitToError: !errorTime || !commitTimeStamp ? null : errorTime - commitTimeStamp
commitToError: !errorTime || !commitTimestamp ? null : errorTime - commitTimestamp
]
}

Expand Down Expand Up @@ -403,9 +403,10 @@ def getCommitTimestamp() {
def error = new StringBuffer()
process.consumeProcessOutput(output, error)
process.waitFor()

println(output.toString())
if (process.exitValue() == 0) {
commitTimeStamp = output.toString().trim().toLong()
commitTimestamp = output.toString().trim().toLong()
println(commitTimestamp)
}
} catch (Exception e) {
println("Exception occurred: ${e.message}")
Expand Down

0 comments on commit 4c4bd09

Please sign in to comment.