|
| 1 | +#!/bin/bash |
| 2 | +# Taken from the Angular2 repo. |
| 3 | + |
| 4 | +set -e -o pipefail |
| 5 | + |
| 6 | +# Setup and start Sauce Connect for your TravisCI build |
| 7 | +# This script requires your .travis.yml to include the following two private env variables: |
| 8 | +# SAUCE_USERNAME |
| 9 | +# SAUCE_ACCESS_KEY |
| 10 | +# Follow the steps at https://saucelabs.com/opensource/travis to set that up. |
| 11 | +# |
| 12 | +# Curl and run this script as part of your .travis.yml before_script section: |
| 13 | +# before_script: |
| 14 | +# - curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash |
| 15 | + |
| 16 | +CONNECT_URL="https://saucelabs.com/downloads/sc-${SAUCE_CONNECT_VERSION}-linux.tar.gz" |
| 17 | +CONNECT_DIR="/tmp/sauce-connect-$RANDOM" |
| 18 | +CONNECT_DOWNLOAD="sc-latest-linux.tar.gz" |
| 19 | + |
| 20 | +CONNECT_LOG="$LOGS_DIR/sauce-connect" |
| 21 | +CONNECT_STDOUT="$LOGS_DIR/sauce-connect.stdout" |
| 22 | +CONNECT_STDERR="$LOGS_DIR/sauce-connect.stderr" |
| 23 | + |
| 24 | +# Get Connect and start it |
| 25 | +mkdir -p $CONNECT_DIR |
| 26 | +cd $CONNECT_DIR |
| 27 | +curl $CONNECT_URL -o $CONNECT_DOWNLOAD 2> /dev/null 1> /dev/null |
| 28 | +mkdir sauce-connect |
| 29 | +tar --extract --file=$CONNECT_DOWNLOAD --strip-components=1 --directory=sauce-connect > /dev/null |
| 30 | +rm $CONNECT_DOWNLOAD |
| 31 | + |
| 32 | +SAUCE_ACCESS_KEY=`echo $SAUCE_ACCESS_KEY | rev` |
| 33 | + |
| 34 | +ARGS="" |
| 35 | + |
| 36 | +# Set tunnel-id only on Travis, to make local testing easier. |
| 37 | +if [ ! -z "$TRAVIS_JOB_NUMBER" ]; then |
| 38 | + ARGS="$ARGS --tunnel-identifier $TRAVIS_JOB_NUMBER" |
| 39 | +fi |
| 40 | +if [ ! -z "$BROWSER_PROVIDER_READY_FILE" ]; then |
| 41 | + ARGS="$ARGS --readyfile $BROWSER_PROVIDER_READY_FILE" |
| 42 | +fi |
| 43 | + |
| 44 | + |
| 45 | +echo "Starting Sauce Connect in the background, logging into:" |
| 46 | +echo " $CONNECT_LOG" |
| 47 | +echo " $CONNECT_STDOUT" |
| 48 | +echo " $CONNECT_STDERR" |
| 49 | +sauce-connect/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY $ARGS \ |
| 50 | + --logfile $CONNECT_LOG 2> $CONNECT_STDERR 1> $CONNECT_STDOUT & |
0 commit comments