Created
March 2, 2023 13:32
-
-
Save robertgzr/590e683a0a814e63621fd09c8959bbd6 to your computer and use it in GitHub Desktop.
circleci insights to csv
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
export CIRCLE_TOKEN={apitoken} | |
export START_DATE=2022-12-01T12:00:00Z | |
export END_DATE=2023-03-01T12:00:00Z |
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/sh | |
set -ex | |
curl -sS --header "Circle-Token: ${CIRCLE_TOKEN:?}" \ | |
"https://circleci.com/api/v2/insights/gh/postmanlabs/starship-next/branches?workflow-name=starship" | | |
tee /dev/stderr | | |
jq '.branches[]' -r | | |
tee /dev/stderr | | |
xargs -I{} curl -sS --header "Circle-Token: ${CIRCLE_TOKEN:?}" \ | |
"https://circleci.com/api/v2/insights/time-series/gh/postmanlabs/starship-next/workflows/starship/jobs?timeseries-granularity=hourly&start-date=${START_DATE:?}&end-date=${END_DATE:?}&branch={}" | | |
tee /dev/stderr | | |
jq '.items[] | select(.name?=="debug-macos-x64-standalone") | [.timestamp,.metrics.median_credits_used,.metrics.duration_metrics.p95]|@csv' -r | | |
sort |
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/sh | |
set -ex | |
curl -sS --header "Circle-Token: ${CIRCLE_TOKEN:?}" \ | |
"https://circleci.com/api/v2/insights/gh/postmanlabs/starship/branches?workflow-name=starship" | | |
tee /dev/stderr | | |
jq '.branches[]' -r | | |
tee /dev/stderr | | |
xargs -I{} curl -sS --header "Circle-Token: ${CIRCLE_TOKEN:?}" \ | |
"https://circleci.com/api/v2/insights/time-series/gh/postmanlabs/starship/workflows/starship/jobs?timeseries-granularity=hourly&start-date=${START_DATE:?}&end-date=${END_DATE:?}&branch={}" | | |
tee /dev/stderr | | |
jq '.items[] | select(.name?=="dev-build-macos-x64") | [.timestamp,.metrics.median_credits_used,.metrics.duration_metrics.p95]|@csv' -r | | |
sort |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment