Skip to content

ci: look for arch-specific snapshots when necessary #977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 44 additions & 33 deletions .ci/docker-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,42 @@ set -e

VERSION_URL="https://raw.githubusercontent.com/elastic/logstash/master/ci/logstash_releases.json"


download_and_load_docker_snapshot_artifact() {
project="${1?project name required}"

artifact_type="docker-image"
artifact_name_base="${project}${DISTRIBUTION_SUFFIX}-${ELASTIC_STACK_VERSION}-${artifact_type}"
echo "Downloading snapshot docker image: ${project}${DISTRIBUTION_SUFFIX} (${ELASTIC_STACK_VERSION})"

artifact_name_noarch="${artifact_name_base}.tar.gz"
artifact_name_arch="${artifact_name_base}-x86_64.tar.gz"

jq_extract_artifact_url=".build.projects.\"${project}\".packages | (.\"${artifact_name_noarch}\" // .\"${artifact_name_arch}\") | .url"

artifact_list=$(curl --silent "https://artifacts-api.elastic.co/v1/versions/${ELASTIC_STACK_VERSION}/builds/latest")
artifact_url=$(echo "${artifact_list}" | jq --raw-output "${jq_extract_artifact_url}")

if [[ "${artifact_url}" == "null" ]]; then
echo "Failed to find '${artifact_name_noarch}'"
echo "Failed to find '${artifact_name_arch}'"
echo "Listing:"
echo "${artifact_list}" | jq --raw-output ".build.projects.\"${project}\".packages | keys | map(select(contains(\"${artifact_type}\")))"
return 1
fi

echo "${artifact_url}"

cd /tmp
curl "${artifact_url}" > "${project}-docker-image.tar.gz"
tar xfvz "${project}-docker-image.tar.gz" repositories
echo "Loading ${project} docker image: "
cat repositories
docker load < "${project}-docker-image.tar.gz"
rm "${project}-docker-image.tar.gz"
cd -
}

if [ "$ELASTIC_STACK_VERSION" ]; then
echo "Fetching versions from $VERSION_URL"
VERSIONS=$(curl --silent $VERSION_URL)
Expand All @@ -23,43 +59,18 @@ if [ "$ELASTIC_STACK_VERSION" ]; then
export ELASTIC_STACK_VERSION=$ELASTIC_STACK_RETRIEVED_VERSION
fi

if [[ "$DISTRIBUTION" = "oss" ]]; then
export DISTRIBUTION_SUFFIX="-oss"
else
export DISTRIBUTION_SUFFIX=""
fi
case "${DISTRIBUTION}" in
default) DISTRIBUTION_SUFFIX="" ;; # empty string when explicit "default" is given
*) DISTRIBUTION_SUFFIX="${DISTRIBUTION/*/-}${DISTRIBUTION}" ;;
esac
export DISTRIBUTION_SUFFIX

echo "Testing against version: $ELASTIC_STACK_VERSION"
echo "Testing against version: $ELASTIC_STACK_VERSION (distribution: ${DISTRIBUTION:-'default'})"

if [[ "$ELASTIC_STACK_VERSION" = *"-SNAPSHOT" ]]; then
cd /tmp

jq=".build.projects.\"logstash\".packages.\"logstash$DISTRIBUTION_SUFFIX-$ELASTIC_STACK_VERSION-docker-image.tar.gz\".url"
result=$(curl --silent https://artifacts-api.elastic.co/v1/versions/$ELASTIC_STACK_VERSION/builds/latest | jq -r $jq)
echo $result
curl $result > logstash-docker-image.tar.gz
tar xfvz logstash-docker-image.tar.gz repositories
echo "Loading docker image: "
cat repositories
docker load < logstash-docker-image.tar.gz
rm logstash-docker-image.tar.gz
cd -

download_and_load_docker_snapshot_artifact "logstash"
if [ "$INTEGRATION" == "true" ]; then

cd /tmp

jq=".build.projects.\"elasticsearch\".packages.\"elasticsearch$DISTRIBUTION_SUFFIX-$ELASTIC_STACK_VERSION-docker-image.tar.gz\".url"
result=$(curl --silent https://artifacts-api.elastic.co/v1/versions/$ELASTIC_STACK_VERSION/builds/latest | jq -r $jq)
echo $result
curl $result > elasticsearch-docker-image.tar.gz
tar xfvz elasticsearch-docker-image.tar.gz repositories
echo "Loading docker image: "
cat repositories
docker load < elasticsearch-docker-image.tar.gz
rm elasticsearch-docker-image.tar.gz
cd -

download_and_load_docker_snapshot_artifact "elasticsearch"
fi
fi

Expand Down