Created
October 24, 2016 14:24
-
-
Save brb/8107553ff739f773ed2f9c87b094aeb0 to your computer and use it in GitHub Desktop.
circleci-grep
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/bash | |
set -ue | |
API_URL="https://circleci.com/api/v1.1" | |
VCS_TYPE="github" | |
CACHE_DIR="/tmp/.circleci-grep" | |
PROJECT="" | |
BUILD="" | |
function usage() { | |
echo "$(basename $0) --project <project-name> --build <build-id> [--cache-dir <DIR>]" | |
exit 1 | |
} | |
while [ $# -gt 0 ]; do | |
case "$1" in | |
--cache-dir) | |
CACHE_DIR="$2" | |
shift | |
;; | |
--project) | |
PROJECT="$2" | |
shift | |
;; | |
--build) | |
BUILD="$2" | |
shift | |
;; | |
esac | |
shift | |
done | |
if [ -z "$PROJECT" -o -z "$BUILD" ]; then | |
echo "$PROJECT" | |
echo "$BUILD" | |
usage | |
fi | |
WORK_DIR="$CACHE_DIR/$PROJECT/$BUILD" | |
MAIN_JSON="$WORK_DIR/main.json" | |
TEST_JSON="$WORK_DIR/test.json" | |
mkdir -p "$WORK_DIR" | |
echo "Fetching build info to $WORK_DIR ..." >&2 | |
if [ ! -e "$MAIN_JSON" ]; then | |
echo "$API_URL/project/$VCS_TYPE/$PROJECT/$BUILD" >&2 | |
curl -L "$API_URL/project/$VCS_TYPE/$PROJECT/$BUILD" -o "$MAIN_JSON" | |
fi | |
if [ ! -e "$TEST_JSON" ]; then | |
for url in $(jq '.steps[] | select(.name | contains("run_all.sh")) | .actions[] | .output_url' "$MAIN_JSON"); do | |
url="${url%\"}" | |
url="${url#\"}" | |
curl -L --compressed "$url" >> "$TEST_JSON" | |
echo "" >> "$TEST_JSON" | |
done | |
fi | |
while read -r dump; do | |
echo "$dump" | jq -r '.[].message' | tr "\\r\\n" "\n" | while read -r line; do | |
echo "$line" | |
done | |
done < "$TEST_JSON" |
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 | |
for i in `seq 6000 6910`; do | |
echo "$i" | |
./fetch.sh --project weaveworks/weave --build "$i" 2>/dev/null | grep 'Fail ./380_' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment