Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
sauce-connect: saucelabs/sauce-connect@1.0.1
Use sauce-connect
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
Open a named saucelabs tunnel before running mvn verify
1
2
3
4
5
6
7
8
9
version: 2.1
orbs:
saucelabs: saucelabs/connect@volatile
workflows:
basic_workflow:
jobs:
- saucelabs/with_proxy:
steps:
- run: mvn verify -B
Open a named saucelabs tunnel before running mvn verify
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
version: 2.1
orbs:
saucelabs: saucelabs/connect@volatile
workflows:
browser_tests:
jobs:
- saucelabs/with_proxy:
name: Chrome Tests
steps:
- run: mvn verify -B -Dsauce.browser=chrome -Dsauce.tunnel="chrome"
tunnel_identifier: chrome
- saucelabs/with_proxy:
name: Safari Tests
steps:
- run: mvn verify -B -Dsauce.browser=safari -Dsauce.tunnel="safari"
tunnel_identifier: safari
Use Sauce Connect with a Proxy
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
docker | - | No | circleci/openjdk:8 | string |
tunnel_identifier | Name your Sauce Connect tunnel make sure to use the tunnelIdentifier desired capability in your test script | No | '' | string |
version | - | No | 4.5.1 | string |
steps | Steps to execute once the Sauce Connect Tunnel is available | Yes | - | steps |
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
version | You can specify which version of Sauce Connect Proxy to use. | No | 4.5.1 | string |
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
tunnel_identifier | This desired capability will let the test job use any shared tunnels available from the specified parent account. i.e. any account that is upstream in the hierarchy. If using a shared tunnel, you must specify both tunnelIdentifier and parentTunnel. | No | '' | string |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: >
Encapsulates interactions with Sauce Connect Proxy
The source repo for this ORB can be found here: https://github.com/saucelabs-sample-test-frameworks/CircleCI-SauceLabs-ORB
commands:
install:
parameters:
version:
description: You can specify which version of Sauce Connect Proxy to use.
type: string
default: "4.5.1"
steps:
- run:
name: Install Sauce Connect Proxy
command: |
cd /tmp
curl https://saucelabs.com/downloads/sc-<<parameters.version>>-linux.tar.gz -o saucelabs.tar.gz
tar -xzf saucelabs.tar.gz
chmod a+x sc-<<parameters.version>>-linux/bin/sc
sudo cp sc-<<parameters.version>>-linux/bin/sc /usr/local/bin
sc --version
open_tunnel:
parameters:
tunnel_identifier:
description: This desired capability will let the test job use any shared tunnels available from the specified parent account. i.e. any account that is upstream in the hierarchy. If using a shared tunnel, you must specify both tunnelIdentifier and parentTunnel.
type: string
default: ""
steps:
- run:
name: Open Sauce Connect Proxy Tunnel
command: |
: ${SAUCELABS_USER:?"Required Env Variable not found!"}
: ${SAUCELABS_KEY:?"Required Env Variable not found!"}
# startup saucelabs tunnel as background task (its a blocking command)
sc -u ${SAUCELABS_USER} -k ${SAUCELABS_KEY} <<# parameters.tunnel_identifier >> -i <<parameters.tunnel_identifier>> <</ parameters.tunnel_identifier>> &
#wait for sauce tunnel up to 1 minute
wget --retry-connrefused --no-check-certificate -T 60 localhost:4445
close_tunnel:
steps:
- run:
name: Close Sauce Connect Tunnels
command: killall sc
jobs:
with_proxy:
description: Use Sauce Connect with a Proxy
parameters:
docker:
type: string
default: "circleci/openjdk:8"
tunnel_identifier:
description: Name your Sauce Connect tunnel make sure to use the tunnelIdentifier desired capability in your test script
type: string
default: ""
version:
type: string
default: "4.5.1"
steps:
type: steps
description: Steps to execute once the Sauce Connect Tunnel is available
docker:
- image: <<parameters.docker>>
steps:
- checkout
- install:
version: <<parameters.version>>
- open_tunnel:
tunnel_identifier: <<parameters.tunnel_identifier>>
- steps: << parameters.steps >>
- close_tunnel
examples:
simple_test:
description: Open a named saucelabs tunnel before running mvn verify
usage:
version: 2.1
orbs:
saucelabs: saucelabs/connect@volatile
workflows:
basic_workflow:
jobs:
- saucelabs/with_proxy:
steps:
- run: mvn verify -B
parallel_tunnels:
description: Open a named saucelabs tunnel before running mvn verify
usage:
version: 2.1
orbs:
saucelabs: saucelabs/connect@volatile
workflows:
browser_tests:
jobs:
- saucelabs/with_proxy:
name: "Chrome Tests"
steps:
- run: mvn verify -B -Dsauce.browser=chrome -Dsauce.tunnel="chrome"
tunnel_identifier: "chrome"
- saucelabs/with_proxy:
name: "Safari Tests"
steps:
- run: mvn verify -B -Dsauce.browser=safari -Dsauce.tunnel="safari"
tunnel_identifier: "safari"