66
77VERSION_URL=" https://raw.githubusercontent.com/elastic/logstash/master/ci/logstash_releases.json"
88
9+
10+ download_and_load_docker_snapshot_artifact () {
11+ project=" ${1?project name required} "
12+
13+ artifact_type=" docker-image"
14+ artifact_name_base=" ${project}${DISTRIBUTION_SUFFIX} -${ELASTIC_STACK_VERSION} -${artifact_type} "
15+ echo " Downloading snapshot docker image: ${project}${DISTRIBUTION_SUFFIX} (${ELASTIC_STACK_VERSION} )"
16+
17+ artifact_name_noarch=" ${artifact_name_base} .tar.gz"
18+ artifact_name_arch=" ${artifact_name_base} -x86_64.tar.gz"
19+
20+ jq_extract_artifact_url=" .build.projects.\" ${project} \" .packages | (.\" ${artifact_name_noarch} \" // .\" ${artifact_name_arch} \" ) | .url"
21+
22+ artifact_list=$( curl --silent " https://artifacts-api.elastic.co/v1/versions/${ELASTIC_STACK_VERSION} /builds/latest" )
23+ artifact_url=$( echo " ${artifact_list} " | jq --raw-output " ${jq_extract_artifact_url} " )
24+
25+ if [[ " ${artifact_url} " == " null" ]]; then
26+ echo " Failed to find '${artifact_name_noarch} '"
27+ echo " Failed to find '${artifact_name_arch} '"
28+ echo " Listing:"
29+ echo " ${artifact_list} " | jq --raw-output " .build.projects.\" ${project} \" .packages | keys | map(select(contains(\" ${artifact_type} \" )))"
30+ return 1
31+ fi
32+
33+ echo " ${artifact_url} "
34+
35+ cd /tmp
36+ curl " ${artifact_url} " > " ${project} -docker-image.tar.gz"
37+ tar xfvz " ${project} -docker-image.tar.gz" repositories
38+ echo " Loading ${project} docker image: "
39+ cat repositories
40+ docker load < " ${project} -docker-image.tar.gz"
41+ rm " ${project} -docker-image.tar.gz"
42+ cd -
43+ }
44+
945if [ " $ELASTIC_STACK_VERSION " ]; then
1046 echo " Fetching versions from $VERSION_URL "
1147 VERSIONS=$( curl --silent $VERSION_URL )
@@ -23,43 +59,18 @@ if [ "$ELASTIC_STACK_VERSION" ]; then
2359 export ELASTIC_STACK_VERSION=$ELASTIC_STACK_RETRIEVED_VERSION
2460 fi
2561
26- if [[ " $ DISTRIBUTION" = " oss " ]] ; then
27- export DISTRIBUTION_SUFFIX=" -oss "
28- else
29- export DISTRIBUTION_SUFFIX= " "
30- fi
62+ case " ${ DISTRIBUTION} " in
63+ default) DISTRIBUTION_SUFFIX=" " ;; # empty string when explicit "default" is given
64+ * ) DISTRIBUTION_SUFFIX= " ${DISTRIBUTION /*/ -}${DISTRIBUTION} " ;;
65+ esac
66+ export DISTRIBUTION_SUFFIX
3167
32- echo " Testing against version: $ELASTIC_STACK_VERSION "
68+ echo " Testing against version: $ELASTIC_STACK_VERSION (distribution: ${DISTRIBUTION :- ' default ' } ) "
3369
3470 if [[ " $ELASTIC_STACK_VERSION " = * " -SNAPSHOT" ]]; then
35- cd /tmp
36-
37- jq=" .build.projects.\" logstash\" .packages.\" logstash$DISTRIBUTION_SUFFIX -$ELASTIC_STACK_VERSION -docker-image.tar.gz\" .url"
38- result=$( curl --silent https://artifacts-api.elastic.co/v1/versions/$ELASTIC_STACK_VERSION /builds/latest | jq -r $jq )
39- echo $result
40- curl $result > logstash-docker-image.tar.gz
41- tar xfvz logstash-docker-image.tar.gz repositories
42- echo " Loading docker image: "
43- cat repositories
44- docker load < logstash-docker-image.tar.gz
45- rm logstash-docker-image.tar.gz
46- cd -
47-
71+ download_and_load_docker_snapshot_artifact " logstash"
4872 if [ " $INTEGRATION " == " true" ]; then
49-
50- cd /tmp
51-
52- jq=" .build.projects.\" elasticsearch\" .packages.\" elasticsearch$DISTRIBUTION_SUFFIX -$ELASTIC_STACK_VERSION -docker-image.tar.gz\" .url"
53- result=$( curl --silent https://artifacts-api.elastic.co/v1/versions/$ELASTIC_STACK_VERSION /builds/latest | jq -r $jq )
54- echo $result
55- curl $result > elasticsearch-docker-image.tar.gz
56- tar xfvz elasticsearch-docker-image.tar.gz repositories
57- echo " Loading docker image: "
58- cat repositories
59- docker load < elasticsearch-docker-image.tar.gz
60- rm elasticsearch-docker-image.tar.gz
61- cd -
62-
73+ download_and_load_docker_snapshot_artifact " elasticsearch"
6374 fi
6475 fi
6576
0 commit comments