Sauce Connect Proxy Environment Variables
The standard way to launch a Sauce Connect Proxy tunnel is to run a single command line comprised of all required flags and any optional flags you want to use to customize tunnel behavior. It's also possible to pass the same command-line arguments through a YAML config file, and as environment variables. If you pass the same argument through multiple methods, the order of precedence is as follows (from highest to lowest):
- command-line option
- environment variable
- YAML config file
Sauce Connect Proxy environment variables can be divided into 3 groups:
- User credentials
- All command line options as environment variables
- Proxy environment variables
User Credentials Environment Variables
Environment Variable | Description | Corresponding CLI Option |
---|---|---|
SAUCE_USERNAME SAUCE_USER | Sets your Sauce Labs username. | --user |
SAUCE_ACCESS_KEY SAUCE_API_KEY | Sets your Sauce Labs access key. | --api-key |
Use Cases
We recommend configuring credentials via environment variables in the following scenarios:
- Sauce Connect Proxy command containing credentials may be exposed via process monitoring tools such as
ps
. - When running Sauce Connect Proxy in CI/CD environment to avoid clear-text logging your credentials.
Command Line Options Environment Variables
You can set via environment variables almost all Sauce Connect Proxy command-line options. Each option description includes the corresponding environment variable.
Use Cases
We recommend configuring options via environment variables in the following scenarios.
- Sauce Connect Proxy command is too long and not easily readable.
- Sauce Connect Proxy runs in a docker container, and a CI system (such as GitLab) allows a straightforward way to set environment variables.
Proxy Environment Variables
Sauce Connect Proxy supports the following proxy auto-configuration environment variables, but we strongly advise using Sauce Connect Proxy specific variables, such as SAUCE_PROXY
or SAUCE_PROXY_TUNNEL
instead, since the auto-configuration variables listed here behave differently on different platforms.
Environment Variable | Description | Platforms |
---|---|---|
http_proxy HTTP_PROXY all_proxy ALL_PROXY | Sets an HTTP proxy to be used by Sauce Connect Proxy. It can be formatted as http://hostname:port or hostname:port .On Linux and Mac environments, http_proxy variable can contain proxy credentials in the following format: scheme://user:password@host:port | Linux, macOS |
no_proxy NO_PROXY | Sets hostnames that will not be proxied, even when Sauce Connect Proxy is configured to use a proxy. Format as a comma-separated list. Subdomain wildcarding is supported when the hostname starts with a . Examples:saucelabs.com,spam.net : Only requests hitting saucelabs.com and spam.net will not be proxied. All other requests will be proxied..example.com : All requests going to any subdomain of example.com will not be proxied (e.g., one.example.com , asdf.example.com ) | Linux, macOS |
--no-autodetect
command-line option disables proxy auto-detection.
Running Sauce Connect Proxy With Environment Variables
- macOS and Linux
- Windows
- In your terminal window, set the following environment variables
export SAUCE_USERNAME="your Sauce username"
export SAUCE_ACCESS_KEY="your Sauce access key" - Starting a new Sauce Connect Proxy does not require adding
--api-key
or--user
flags.sc --region us-west
.bash_profile
or .zshrc
.- Open
~/.bash_profile
or~/.zshrc
in your preferred text editor. - Add the variables
export SAUCE_USERNAME="your Sauce username"
export SAUCE_ACCESS_KEY="your Sauce access key" - Start a new shell or a new terminal.
- To confirm that your environment variables are set, enter
echo $SAUCE_USERNAME
in your terminal. The expected response is your username value. - Just as above, starting a new Sauce Connect Proxy does not require adding
--api-key
or--user
flags.sc --region us-west
- Open the Control Panel and click the System icon to open the System Properties dialog.
- Click Environment Variables to open the Environment Variables dialog.
- In the User variables section, click New to open the New System Variable dialog.
- For Variable name, enter SAUCE_USERNAME and for Variable value, enter your Sauce username and then click OK.
- Repeat 3-4 to set up the SAUCE_ACCESS_KEY or any other environment variable.
- Confirm that your environment variables have been set by typing
echo %SAUCE_USERNAME%
in your terminal. The response should be your username value. Then do the same for your access key. - Starting a new Sauce Connect Proxy will not require adding
--api-key
or--user
flags.sc.exe --region us-west