Skip to main content

Sauce Connect Proxy Environment Variables

The standard way to launch a Sauce Connect Proxy tunnel is to execute 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. When the same argument is passed 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 envirment variables
  • Proxy environment variables

User Credentials Environment Variables

Environment VariableDescriptionCorresponding 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

Almost all Sauce Connect Proxy command-line options can be set via environment variables. 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 docker container and CI system (such as Gitlab) allows a simple 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 VariableDescriptionPlatforms
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
note

--no-autodetect command-line option disables proxy auto-detection.

Running Sauce Connect Proxy With Environment Variables

Follow the steps below to configure Sauce Connect Proxy using environment variables in the current terminal.

  1. In your terminal window, set the following environment variables
    export SAUCE_USERNAME="your Sauce username"
    export SAUCE_ACCESS_KEY="your Sauce access key"
  2. Starting a new Sauce Connect Proxy will not require adding --api-key or --user flags.
    sc --region us-west

Alternatively, Sauce Connect Proxy environment variables may be added to one of the user environment configuration files, such as ~/.bash_profile.

  1. To make environment variables always available, open ~/.bash_profile in your prefered text editor.
  2. Add the variables, for example:
    export SAUCE_USERNAME="your Sauce username"
    export SAUCE_ACCESS_KEY="your Sauce access key"
  3. Start a new shell or a new terminal.
  4. Confirm that your environment variables have been set by typing echo $SAUCE_USERNAME in your terminal. The response should be your username value.
  5. Just as above, starting a new Sauce Connect Proxy will not require adding --api-key or --user flags.
    sc --region us-west

More Information