Skip to content

Commit

Permalink
Add metric Successful-Run-Streak(#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikRehmTT committed Sep 4, 2024
1 parent c592f50 commit a2ae85a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion vars/pipeline2ATX.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ def getBuildMetrics(build, testExecutionSteps) {
[name: "TEARDOWN_PERCENTAGE", direction: "OUT", value: timeValues.teardownPercentage],
[name: "QUEUE_TIME", direction: "OUT", value: timeValues.queueDuration],
[name: "COMMIT_TO_START_TIME", direction: "OUT", value: timeValues.fromCommitToStartTime],
[name: "TIME_TO_ERROR", direction: "OUT", value: timeValues.errorTime]
[name: "TIME_TO_ERROR", direction: "OUT", value: timeValues.errorTime],
[name: "SUCCESSFUL_RUNS_STREAK", direction: "OUT", value: getSuccessfulRunsStreak(build)]
]
return metrics.findAll { param -> param.value != null }
}
Expand Down Expand Up @@ -291,6 +292,22 @@ def calculateTime(executionTestSteps, build) {
errorTime: errorTime != null ? convertTimeValueToDouble(setupDuration + queueDuration + errorTime) : null]
}

def getSuccessfulRunsStreak(build) {
if (build.resultIsWorseOrEqualTo("UNSTABLE")) {
return 0
}
def result = build.getNumber()

def b = build.getPreviousBuild()
while (b != null && b.getResult() == "SUCCESS") {
b = b.getPreviousBuild()
}
if (b != null) {
return result - b.getNumber()
}
return result
}

/**
* Converts a none null time value to a double with one decimal place.
* @param value
Expand Down

0 comments on commit a2ae85a

Please sign in to comment.