Skip to content

Instantly share code, notes, and snippets.

@htnosm
Last active January 2, 2022 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save htnosm/84ac43da9451e075e5f119a4853096c9 to your computer and use it in GitHub Desktop.
Save htnosm/84ac43da9451e075e5f119a4853096c9 to your computer and use it in GitHub Desktop.
List output of AWS CodeBuild duration times.
_PROJECT="Your CodeBuild Project Name"
aws --no-cli-pager codebuild batch-get-builds \
--ids $(aws --no-cli-pager codebuild list-builds-for-project \
--project-name "${_PROJECT}" \
--sort-order DESCENDING --query 'ids[]' --max-items 100 --output text \
| grep -v 'None') \
| jq -r '[
"id", "buildNumber", "startTime", "endTime", "buildStatus",
"buildDuration",
"SUBMITTED_duration",
"QUEUED_duration",
"PROVISIONING_duration",
"DOWNLOAD_SOURCE_duration",
"INSTALL_duration",
"PRE_BUILD_duration",
"BUILD_duration",
"POST_BUILD_duration",
"UPLOAD_ARTIFACTS_duration",
"FINALIZING_duration"
],(.builds[] | [
.id, .buildNumber, .startTime, .endTime, .buildStatus,
(.endTime | gsub("[\\.|\\+].*$"; "Z") | fromdate) - (.startTime | gsub("[\\.|\\+].*$"; "Z") | fromdate),
(.phases[] | select(.phaseType=="SUBMITTED") |.durationInSeconds),
(.phases[] | select(.phaseType=="QUEUED") |.durationInSeconds),
(.phases[] | select(.phaseType=="PROVISIONING") |.durationInSeconds),
(.phases[] | select(.phaseType=="DOWNLOAD_SOURCE") |.durationInSeconds),
(.phases[] | select(.phaseType=="INSTALL") |.durationInSeconds),
(.phases[] | select(.phaseType=="PRE_BUILD") |.durationInSeconds),
(.phases[] | select(.phaseType=="BUILD") |.durationInSeconds),
(.phases[] | select(.phaseType=="POST_BUILD") |.durationInSeconds),
(.phases[] | select(.phaseType=="UPLOAD_ARTIFACTS") |.durationInSeconds),
(.phases[] | select(.phaseType=="FINALIZING") |.durationInSeconds)
]) | @tsv'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment