Skip to content

Instantly share code, notes, and snippets.

@mhodgson
Last active February 23, 2017 20:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhodgson/7234752 to your computer and use it in GitHub Desktop.
Save mhodgson/7234752 to your computer and use it in GitHub Desktop.
Custom Sauce Labs / Travis CI Integration
#!/bin/bash
# Setup and start Sauce Connect for your TravisCI build
# This script requires your .travis.yml to include the following two private env variables:
# SAUCE_USERNAME
# SAUCE_ACCESS_KEY
# Follow the steps at https://saucelabs.com/opensource/travis to set that up.
#
# Curl and run this script as part of your .travis.yml before_script section:
# before_script:
# - curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash
CONNECT_URL="https://saucelabs.com/downloads/sc-4.3.5-linux32.tar.gz"
CONNECT_DIR="/tmp/sauce-connect-$RANDOM"
CONNECT_DOWNLOAD="sc-4.3.5-linux32.tar.gz"
CONNECT_DOWNLOAD_DIR="$CONNECT_DIR/sc-4.3.5-linux32"
READY_FILE="connect-ready-$RANDOM"
CONNECT_LOG_FILE="connect-log-$RANDOM.log"
# Get Connect and start it
mkdir -p $CONNECT_DIR
cd $CONNECT_DIR
curl $CONNECT_URL > $CONNECT_DOWNLOAD
tar -zxvf $CONNECT_DOWNLOAD
rm $CONNECT_DOWNLOAD
cd $CONNECT_DOWNLOAD_DIR
bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY \
--readyfile $READY_FILE \
--tunnel-domains $CONNECT_TUNNEL_DOMAINS \
--tunnel-identifier $TRAVIS_JOB_NUMBER \
--logfile $CONNECT_LOG_FILE &
# Wait for Connect to be ready before exiting
while [ ! -f $READY_FILE ]; do
sleep .5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment