Skip to content

Commit

Permalink
Retry once for correct build id for a server (elastic#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
liza-mae authored Jan 25, 2019
1 parent 22da9c4 commit c6e4fd4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion scripts/shell/lib/build_funcs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,22 @@ export_env_vars() {

# Added to get latest build from server
if [ ! -z $ES_BUILD_SERVER ] && [ ! -z $ES_BUILD_BRANCH ]; then
LATEST_BUILD_ID=$(curl -s https://artifacts-api.elastic.co/v1/branches/${ES_BUILD_BRANCH##*/}/builds/latest | jq -r .build.build_id)
ARTIFACTS_BASE_URL="https://artifacts-api.elastic.co/v1/branches/${ES_BUILD_BRANCH##*/}"
ALL_BUILDS=$(curl -s ${ARTIFACTS_BASE_URL}/builds | jq -r .builds)
LATEST_BUILD_ID=$(echo $ALL_BUILDS | tr -d '\\[\\]\\"\ ' | cut -d',' -f1)
echo "First build in list: $LATEST_BUILD_ID"
BUILD_INFO=$(curl -s ${ARTIFACTS_BASE_URL}/builds/${LATEST_BUILD_ID})
if [[ ! "$BUILD_INFO" =~ "${ES_BUILD_SERVER}" ]]; then
LATEST_BUILD_ID=$(echo $ALL_BUILDS | tr -d '\\[\\]\\"\ ' | cut -d',' -f2)
echo "Second build in list: $LATEST_BUILD_ID"
BUILD_INFO=$(curl -s ${ARTIFACTS_BASE_URL}/builds/${LATEST_BUILD_ID})
if [[ ! "$BUILD_INFO" =~ "${ES_BUILD_SERVER}" ]]; then
echo_error "First two builds are not from ${ES_BUILD_SERVER}! Check builds and rerun."
exit 1
fi
fi
export ES_BUILD_URL="${ES_BUILD_SERVER}.elastic.co/$LATEST_BUILD_ID"
echo $ES_BUILD_URL
fi

env | sort
Expand Down

0 comments on commit c6e4fd4

Please sign in to comment.