Skip to content

Instantly share code, notes, and snippets.

@jone
Last active December 12, 2015 07:58
Show Gist options
  • Save jone/4739999 to your computer and use it in GitHub Desktop.
Save jone/4739999 to your computer and use it in GitHub Desktop.
sauce jenkins
import socket
# Sauce only tunnels certain ports, so we need to pick one of those ports and it should be
# not used.
# See port list at: https://saucelabs.com/docs/connect#localhost
PORTS = [2000, 2001, 2020, 2222, 3000, 3001, 3030, 3333, 4000, 4001, 4040, 5000, 5001, 5050, 5555, 6000, 6001, 6060, 6666, 7000, 7070, 7777, 8000, 8001, 8080, 8888, 9000, 9001, 9080, 9090, 9999, 4502, 4503, 8003, 8031]
def get_free_port():
for port in PORTS:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(60)
try:
sock.connect(('localhost', port))
except socket.error:
return port
else:
sock.close()
print get_free_port()
export REMOTE_URL="http://XXXX:[email protected]:80/wd/hub"
export ZSERVER_HOST="0.0.0.0"
export ZSERVER_PORT="2000"
$PYTHON27 bootstrap.py
bin/buildout
DESIRED_CAPABILITIES=$(cat <<EOF | python -
import os
SELENIUM_DRIVER = os.environ.get('SELENIUM_DRIVER')
DESIRED_CAPABILITIES = ''
for item in SELENIUM_DRIVER.split('?', 1)[1].split('&'):
DESIRED_CAPABILITIES += ','
item = item.replace('=', ':')
item = item.replace('os:', 'platform:')
item = item.replace('browser-version:', 'version:')
DESIRED_CAPABILITIES += item
DESIRED_CAPABILITIES = DESIRED_CAPABILITIES[1:]
JOB_NAME = os.environ.get('JOB_NAME').replace('jenkins-', '').replace('/SELENIUM_DRIVER=', ' | ')
BULD_NUMBER = os.environ.get('BUILD_NUMBER')
DESIRED_CAPABILITIES += ',name:' + JOB_NAME + ' | #' + BULD_NUMBER
print DESIRED_CAPABILITIES
EOF)
export DESIRED_CAPABILITIES
BROWSER=$(echo $SELENIUM_DRIVER | perl -pe 's|.*browser=(.*?)&.*|\1|')
export BROWSER
bin/test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment