From 517937fe5739e2b5633490d705016c9e20174df7 Mon Sep 17 00:00:00 2001 From: Rob Bavey Date: Wed, 17 Oct 2018 11:45:19 -0400 Subject: [PATCH 1/3] [Build] Download Logstash from elastic.co instead of building from source --- .travis.yml | 16 +++++++-------- ci/build.sh | 14 ++++--------- ci/setup.sh | 58 +++++++++++++++++++++++++++++++---------------------- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/.travis.yml b/.travis.yml index 248dcd8ee..bd4fce588 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,23 +20,21 @@ rvm: matrix: include: - rvm: jruby-9.1.13.0 - env: LOGSTASH_BRANCH=master + env: LOGSTASH_VERSION=7.x - rvm: jruby-9.1.13.0 - env: LOGSTASH_BRANCH=6.x - - rvm: jruby-9.1.13.0 - env: LOGSTASH_BRANCH=6.5 + env: LOGSTASH_VERSION=6.x - rvm: jruby-1.7.27 - env: LOGSTASH_BRANCH=5.6 + env: LOGSTASH_VERSION=5.x - rvm: jruby-1.7.27 - env: DISTRIBUTION=legacy INTEGRATION=true ES_VERSION=5.6.13 LOGSTASH_BRANCH=5.6 TEST_DEBUG=true + env: DISTRIBUTION=legacy INTEGRATION=true ES_VERSION=5.6.13 LOGSTASH_VERSION=5.x TEST_DEBUG=true - rvm: jruby-9.1.13.0 - env: DISTRIBUTION=default INTEGRATION=true ES_VERSION=LATEST-SNAPSHOT-6 LOGSTASH_BRANCH=6.6 TEST_DEBUG=true + env: DISTRIBUTION=default INTEGRATION=true ES_VERSION=LATEST-SNAPSHOT-6 LOGSTASH_VERSION=6.x TEST_DEBUG=true - rvm: jruby-9.1.13.0 - env: DISTRIBUTION=default INTEGRATION=true ES_VERSION=LATEST-SNAPSHOT-7 LOGSTASH_BRANCH=master TEST_DEBUG=true + env: DISTRIBUTION=default INTEGRATION=true ES_VERSION=LATEST-SNAPSHOT-7 LOGSTASH_VERSION=7.x TEST_DEBUG=true allow_failures: - env: DISTRIBUTION=default INTEGRATION=true ES_VERSION=LATEST-SNAPSHOT-7 TEST_DEBUG=true - rvm: jruby-9.1.13.0 - env: DISTRIBUTION=default INTEGRATION=true ES_VERSION=LATEST-SNAPSHOT-7 LOGSTASH_BRANCH=master TEST_DEBUG=true + env: DISTRIBUTION=default INTEGRATION=true ES_VERSION=LATEST-SNAPSHOT-7 LOGSTASH_VERSION=7.x TEST_DEBUG=true fast_finish: true install: true script: ci/build.sh diff --git a/ci/build.sh b/ci/build.sh index 06caffdc1..1f512eeb7 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -7,15 +7,9 @@ ######################################################## set -e -echo "Starting build process in: `pwd`" +export LOGSTASH_PATH=$PWD/logstash-${LOGSTASH_VERSION} source ./ci/setup.sh +export PATH=$LOGSTASH_PATH/vendor/jruby/bin:$LOGSTASH_PATH/vendor/bundle/jruby/1.9.3/bin:$LOGSTASH_PATH/vendor/bundle/jruby/2.3.0/bin:$PATH +export LOGSTASH_SOURCE=1 -if [[ -f "ci/run.sh" ]]; then - echo "Running custom build script in: `pwd`/ci/run.sh" - source ./ci/run.sh -else - echo "Running default build scripts in: `pwd`/ci/build.sh" - bundle install - bundle exec rake vendor - bundle exec rspec spec -fi +jruby -S bundle exec rspec \ No newline at end of file diff --git a/ci/setup.sh b/ci/setup.sh index 835fa437b..c48a23675 100755 --- a/ci/setup.sh +++ b/ci/setup.sh @@ -1,26 +1,36 @@ #!/bin/bash -# version: 1 -######################################################## -# -# AUTOMATICALLY GENERATED! DO NOT EDIT -# -######################################################## set -e -if [ "$LOGSTASH_BRANCH" ]; then - echo "Building plugin using Logstash source" - BASE_DIR=`pwd` - echo "Checking out branch: $LOGSTASH_BRANCH" - git clone -b $LOGSTASH_BRANCH https://github.com/elastic/logstash.git ../../logstash --depth 1 - printf "Checked out Logstash revision: %s\n" "$(git -C ../../logstash rev-parse HEAD)" - cd ../../logstash - echo "Building plugins with Logstash version:" - cat versions.yml - echo "---" - # We need to build the jars for that specific version - echo "Running gradle assemble in: `pwd`" - ./gradlew assemble - cd $BASE_DIR - export LOGSTASH_SOURCE=1 -else - echo "Building plugin using released gems on rubygems" -fi + +VERSION_URL="https://raw.githubusercontent.com/elastic/logstash/master/ci/logstash_releases.json" + +download_logstash() { + logstash_version=$1 + wget https://artifacts.elastic.co/downloads/logstash/logstash-$logstash_version.tar.gz +} + +translate_version() { + requested_version=$1 + echo "Fetching versions from $VERSION_URL" + VERSIONS=$(curl $VERSION_URL) + RETRIEVED_VERSION=$(echo $VERSIONS | jq '.releases."'"$requested_version"'"') + if [[ "$RETRIEVED_VERSION" != "null" ]]; then + # remove starting and trailing double quotes + RETRIEVED_VERSION="${RETRIEVED_VERSION%\"}" + RETRIEVED_VERSION="${RETRIEVED_VERSION#\"}" + echo "Translated $requested_version to ${RETRIEVED_VERSION}" + export LOGSTASH_VERSION=$RETRIEVED_VERSION + fi +} + + +translate_version $LOGSTASH_VERSION +echo "Downloading logstash version: $LOGSTASH_VERSION" +download_logstash $LOGSTASH_VERSION +tar -zxf logstash-$LOGSTASH_VERSION.tar.gz +export LOGSTASH_PATH=$PWD/logstash-${LOGSTASH_VERSION} +export PATH=$LOGSTASH_PATH/vendor/jruby/bin:$LOGSTASH_PATH/vendor/bundle/jruby/1.9.3/bin:$LOGSTASH_PATH/vendor/bundle/jruby/2.3.0/bin:$PATH +export LOGSTASH_SOURCE=1 +cp $LOGSTASH_PATH/logstash-core/versions-gem-copy.yml $LOGSTASH_PATH/versions.yml +gem install bundler +jruby -S bundle install --jobs=3 --retry=3 --path=vendor/bundler +jruby -S bundle exec rake vendor From cc1a35b7c7c942b92e18992d8456a9c5399c9eca Mon Sep 17 00:00:00 2001 From: Joao Duarte Date: Tue, 5 Feb 2019 13:35:18 +0000 Subject: [PATCH 2/3] add default logstash testing version --- ci/setup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/setup.sh b/ci/setup.sh index c48a23675..6a42fba01 100755 --- a/ci/setup.sh +++ b/ci/setup.sh @@ -22,6 +22,10 @@ translate_version() { fi } +if [ -z "$LOGSTASH_VERSION" ] +then + export LOGSTASH_VERSION="6.x" +fi translate_version $LOGSTASH_VERSION echo "Downloading logstash version: $LOGSTASH_VERSION" From 26e2c6233fd852005e3b1fd0508702a49b809edf Mon Sep 17 00:00:00 2001 From: Joao Duarte Date: Tue, 5 Feb 2019 13:36:23 +0000 Subject: [PATCH 3/3] pin bundler to 1.x in ci testing --- ci/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/setup.sh b/ci/setup.sh index 6a42fba01..f372a696e 100755 --- a/ci/setup.sh +++ b/ci/setup.sh @@ -35,6 +35,6 @@ export LOGSTASH_PATH=$PWD/logstash-${LOGSTASH_VERSION} export PATH=$LOGSTASH_PATH/vendor/jruby/bin:$LOGSTASH_PATH/vendor/bundle/jruby/1.9.3/bin:$LOGSTASH_PATH/vendor/bundle/jruby/2.3.0/bin:$PATH export LOGSTASH_SOURCE=1 cp $LOGSTASH_PATH/logstash-core/versions-gem-copy.yml $LOGSTASH_PATH/versions.yml -gem install bundler +gem install bundler -v "~> 1" jruby -S bundle install --jobs=3 --retry=3 --path=vendor/bundler jruby -S bundle exec rake vendor