Skip to content

Instantly share code, notes, and snippets.

@awakia
Created May 27, 2016 11:30
Show Gist options
  • Save awakia/39b9017222b54b09c17566124b829e47 to your computer and use it in GitHub Desktop.
Save awakia/39b9017222b54b09c17566124b829e47 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# To resolve https://github.com/wercker/support/issues/125
# At first, this script tries to run `bundle install` using cache.
# If it fails, run again after cleaning up cache.
#
# Usage:
# script/ci-bundle-install
#
BUNDLER_CACHE_DIR=$WERCKER_CACHE_DIR/bundle-install/
MAX_RETRY_COUNT=3
bundle check --path $BUNDLER_CACHE_DIR
exit_code=$?
if [ $exit_code -eq 0 ]; then
echo "=====> All dependencies are already installed!"
exit 0
fi
retry_count=1
while [ $retry_count -le $MAX_RETRY_COUNT ]; do
bundle install -j4 --path $BUNDLER_CACHE_DIR
exit_code=$?
if [ $exit_code -eq 0 ]; then
echo "=====> bundle install has been successfully completed!"
exit 0
fi
echo "=====> Clear cache..."
rm -rf $BUNDLER_CACHE_DIR
echo "=====> Retry bundle install..."
retry_count=$(expr $retry_count + 1)
done
echo "=====> bundle install has been failed."
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment