Skip to content

[Build] Download Logstash from elastic.co instead of building from source #839

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
16 changes: 7 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 4 additions & 10 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
60 changes: 37 additions & 23 deletions ci/setup.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
#!/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"

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
}

if [ -z "$LOGSTASH_VERSION" ]
then
export LOGSTASH_VERSION="6.x"
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 -v "~> 1"
jruby -S bundle install --jobs=3 --retry=3 --path=vendor/bundler
jruby -S bundle exec rake vendor