Skip to content

Instantly share code, notes, and snippets.

@drnic
Created July 17, 2023 00:16
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 drnic/09b04e299ec191454cb3ac34109322a7 to your computer and use it in GitHub Desktop.
Save drnic/09b04e299ec191454cb3ac34109322a7 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
# e.g. https://api.buildkite.com/v2/organizations/myorg/pipelines/mypipeline/builds/1234
build_url=${BUILD_URL}
function _curl() {
curl -sS -H "${BUILDKITE_API_AUTH?:required}" $@
}
failed_jobs_raw_log_url=$(
_curl "${build_url}?include_retried_jobs=true" |
jq -r '.jobs | map(select(.exit_status != 0 and .type == "script")) | .[].raw_log_url'
)
for raw_log_url in ${failed_jobs_raw_log_url[@]}; do
log_data=$(_curl $raw_log_url)
echo "$log_data" | sed 's/\x1b\[[0-9;]*m//g' | grep -E '^rspec' | awk '{print $1 $2}'
done
@drnic
Copy link
Author

drnic commented Jul 17, 2023

We have retried jobs because some rspec commands are flakey. I wanted to find them.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment