Last active
September 9, 2022 09:50
-
-
Save jpswade/d1012fda4bda527f742ea3823f9a8718 to your computer and use it in GitHub Desktop.
Pipeline Duration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
#aws codepipeline list-pipeline-executions --pipeline-name spectre-prod>codepipeline.json | |
import json | |
import sys | |
import dateutil.parser as parser | |
import datetime | |
data = json.load(sys.stdin) | |
total = 0 | |
count = 0 | |
print("pipelineExecutionId,startTime,lastUpdateTime,DurationInSeconds,DurationInMinutes") | |
for record in data['pipelineExecutionSummaries']: | |
if record['status'] == 'Succeeded': | |
count = count + 1 | |
lastUpdateTime = parser.parse(record['lastUpdateTime']) | |
startTime = parser.parse(record['startTime']) | |
diff = lastUpdateTime - startTime | |
diff_in_seconds = diff.total_seconds() | |
total = total + diff_in_seconds | |
diff_in_minutes = diff_in_seconds / 60 | |
print("%s,%s,%s,%s,%s" % (record['pipelineExecutionId'],startTime.strftime("%d/%m/%Y %H:%M"),lastUpdateTime.strftime("%d/%m/%Y %H:%M"),diff_in_seconds, diff_in_minutes)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment