2
2
3
3
set -e -o pipefail
4
4
5
- # Setup and start Sauce Connect for your TravisCI build
6
- # This script requires your .travis.yml to include the following two private env variables:
7
- # SAUCE_USERNAME
8
- # SAUCE_ACCESS_KEY
9
- # Follow the steps at https://saucelabs.com/opensource/travis to set that up.
10
- #
11
- # Curl and run this script as part of your .travis.yml before_script section:
12
- # before_script:
13
- # - curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash
14
-
15
- CONNECT_DIR=" /tmp/sauce-connect-$RANDOM "
16
- CONNECT_DOWNLOAD=" sc-latest-linux.tar.gz"
17
-
18
- CONNECT_LOG=" $LOGS_DIR /sauce-connect"
19
- CONNECT_STDOUT=" $LOGS_DIR /sauce-connect.stdout"
20
- CONNECT_STDERR=" $LOGS_DIR /sauce-connect.stderr"
21
-
22
- # Get the appropriate URL for downloading Sauce Connect
23
- if [ ` uname -s` = " Darwin" ]; then
24
- # If the user is running Mac, download the OSX version
25
- # https://en.wikipedia.org/wiki/Darwin_(operating_system)
26
- CONNECT_URL=" https://saucelabs.com/downloads/sc-4.4.2-osx.zip"
27
- else
28
- # Otherwise, default to Linux for Travis-CI
29
- CONNECT_URL=" https://saucelabs.com/downloads/sc-4.4.2-linux.tar.gz"
30
- fi
31
- mkdir -p $CONNECT_DIR
32
- cd $CONNECT_DIR
33
- curl $CONNECT_URL -o $CONNECT_DOWNLOAD 2> /dev/null 1> /dev/null
34
- mkdir sauce-connect
35
- tar --extract --file=$CONNECT_DOWNLOAD --strip-components=1 --directory=sauce-connect > /dev/null
36
- rm $CONNECT_DOWNLOAD
5
+ TUNNEL_FILE=" sc-4.4.2-linux.tar.gz"
6
+ TUNNEL_URL=" https://saucelabs.com/downloads/$TUNNEL_FILE "
7
+ TUNNEL_DIR=" /tmp/saucelabs-connect"
37
8
9
+ TUNNEL_LOG=" $LOGS_DIR /sauce-connect"
38
10
39
11
SAUCE_ACCESS_KEY=` echo $SAUCE_ACCESS_KEY | rev`
40
12
13
+ # Cleanup and create the folder structure for the tunnel connector.
14
+ rm -rf $TUNNEL_DIR $BROWSER_PROVIDER_READY_FILE
15
+ mkdir -p $TUNNEL_DIR
16
+
17
+ cd $TUNNEL_DIR
18
+
19
+ # Download the saucelabs connect binaries.
20
+ curl $TUNNEL_URL -o $TUNNEL_FILE 2> /dev/null 1> /dev/null
21
+
22
+ # Extract the saucelabs connect binaries from the tarball.
23
+ mkdir -p sauce-connect
24
+ tar --extract --file=$TUNNEL_FILE --strip-components=1 --directory=sauce-connect > /dev/null
25
+
26
+ # Cleanup the download directory.
27
+ rm $TUNNEL_FILE
28
+
41
29
ARGS=" "
42
30
43
31
# Set tunnel-id only on Travis, to make local testing easier.
44
- if [ ! -z " $TRAVIS_JOB_NUMBER " ]; then
45
- ARGS=" $ARGS --tunnel-identifier $TRAVIS_JOB_NUMBER "
32
+ if [ ! -z " $TRAVIS_JOB_ID " ]; then
33
+ ARGS=" $ARGS --tunnel-identifier $TRAVIS_JOB_ID "
46
34
fi
47
35
if [ ! -z " $BROWSER_PROVIDER_READY_FILE " ]; then
48
36
ARGS=" $ARGS --readyfile $BROWSER_PROVIDER_READY_FILE "
49
37
fi
50
38
51
-
52
39
echo " Starting Sauce Connect in the background, logging into:"
53
- echo " $CONNECT_LOG "
54
- echo " $CONNECT_STDOUT "
55
- echo " $CONNECT_STDERR "
40
+ echo " $TUNNEL_LOG "
56
41
echo " ---"
57
42
echo " $ARGS "
58
- sauce-connect/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY $ARGS \
59
- --logfile $CONNECT_LOG 2> $CONNECT_STDERR 1> $CONNECT_STDOUT &
43
+
44
+ sauce-connect/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY $ARGS --logfile $TUNNEL_LOG &
0 commit comments