Skip to content

Commit

Permalink
Translate branch input to version before getting build (elastic#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
liza-mae authored Feb 14, 2019
1 parent 0c0a315 commit afee1f2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/shell/lib/build_funcs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,21 @@ export_env_vars() {

# Added to get latest build from server
if [ ! -z $ES_BUILD_SERVER ] && [ ! -z $ES_BUILD_BRANCH ]; then
ARTIFACTS_BASE_URL="https://artifacts-api.elastic.co/v1/versions/${ES_BUILD_BRANCH##*/}/builds/latest"
if [[ "$ES_BUILD_SERVER" =~ "snapshots" ]]; then
ARTIFACTS_BASE_URL="https://artifacts-api.elastic.co/v1/versions/${ES_BUILD_BRANCH##*/}-SNAPSHOT/builds/latest"
# Translate branch to a version
ES_BUILD_VERSION=$(curl -s "https://artifacts-api.elastic.co/v1/branches/${ES_BUILD_BRANCH##*/}" | jq -r .branch.builds[0].version)
# Find latest build based on the version
ARTIFACTS_BASE_URL="https://artifacts-api.elastic.co/v1/versions/${ES_BUILD_VERSION}/builds/latest"
if [[ "$ES_BUILD_SERVER" =~ "snapshots" ]] && [[ "$ES_BUILD_VERSION" != *"SNAPSHOT"* ]]; then
ARTIFACTS_BASE_URL="https://artifacts-api.elastic.co/v1/versions/${ES_BUILD_VERSION}-SNAPSHOT/builds/latest"
elif [[ "$ES_BUILD_SERVER" =~ "staging" ]] && [[ "$ES_BUILD_VERSION" =~ "SNAPSHOT" ]]; then
ARTIFACTS_BASE_URL="https://artifacts-api.elastic.co/v1/versions/${ES_BUILD_VERSION//[!0-9.]/}/builds/latest"
fi
export LATEST_BUILD_ID=$(curl -s ${ARTIFACTS_BASE_URL} | jq -r .build.build_id)
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 afee1f2

Please sign in to comment.