github.com/mirantis/virtlet@v1.5.2-0.20191204181327-1659b8a48e9b/build/circle-dump.sh (about) 1 #!/bin/bash 2 set -o errexit 3 set -o nounset 4 set -o pipefail 5 set -o errtrace 6 7 DIND_SCRIPT="${DIND_SCRIPT:-$HOME/dind-cluster-v1.14.sh}" 8 circle_token_file="$HOME/.circle-token" 9 10 job_num="${1:-}" 11 if [[ ! ${job_num} ]]; then 12 echo >&2 "Usage: ${0} job_number" 13 echo >&2 14 echo >&2 "You need to have kubeadm-dind-cluster script pointed" 15 echo >&2 "to by DIND_SCRIPT environment variable" 16 echo >&2 "(defaults to ${DIND_SCRIPT})." 17 echo >&2 "Besides, you need to specify your CircleCI token via" 18 echo >&2 "CIRCLE_TOKEN environment variable or have it stored" 19 echo >&2 "using base64 encoding in ${circle_token_file}." 20 exit 1 21 fi 22 23 if [[ ! ${CIRCLE_TOKEN:-} && ! -e ${circle_token_file} ]]; then 24 echo >&2 "You need to specify CIRCLE_TOKEN or store base64-encoded CircleCI token in ${circle_token_file}" 25 exit 1 26 fi 27 28 CIRCLE_TOKEN="${CIRCLE_TOKEN:-"$(base64 --decode "${circle_token_file}")"}" 29 30 if [[ ! -e "${DIND_SCRIPT}" ]]; then 31 echo >&2 "Please specify the path to kubeadm-dind-cluster script with DIND_SCRIPT" 32 exit 1 33 fi 34 35 base_url="https://circleci.com/api/v1.1/project/github/Mirantis/virtlet" 36 37 rm -rf virtlet-circle-dump 38 mkdir virtlet-circle-dump 39 cd virtlet-circle-dump 40 41 url="$(curl -sSL -u "${CIRCLE_TOKEN}:" "${base_url}/${job_num}/artifacts" | 42 jq -r '.[]|select(.path=="tmp/cluster_state/kdc-dump.gz")|.url')" 43 echo >&2 "Getting cluster dump from ${url}" 44 curl -sSL "${url}" | gunzip | ~/dind-cluster-v1.14.sh split-dump 45 46 url="$(curl -sSL -u "${CIRCLE_TOKEN}:" "${base_url}/${job_num}/artifacts" | 47 jq -r '.[]|select(.path=="tmp/cluster_state/virtlet-dump.json.gz")|.url')" 48 echo >&2 "Getting virtlet dump from ${url}" 49 curl -sSL "${url}" | gunzip | virtletctl diag unpack virtlet/