Skip to main content

Environment Variables

k6 supports configuration through environment variables, which provide an alternative to CLI flags and are particularly useful in CI/CD environments.

Precedence

Configuration sources are applied in this order (later overrides earlier):
  1. Script options (export const options = {})
  2. Configuration file (k6.json)
  3. Environment variables
  4. CLI flags (highest priority)

Runtime Environment Variables

K6_TYPE

string
Override test type detection.Values: js, archive

K6_INCLUDE_SYSTEM_ENV_VARS

boolean
default:"false"
Pass system environment variables to the script runtime.

K6_COMPATIBILITY_MODE

string
default:"extended"
JavaScript runtime compatibility mode.Values: extended, base, experimental_enhanced

Output and Summary Variables

K6_OUT

string[]
Metrics output destinations (comma-separated).

K6_NO_SUMMARY

boolean
Disable the end-of-test summary.Deprecated: Use K6_SUMMARY_MODE=disabled instead.

K6_SUMMARY_MODE

string
default:"compact"
Summary display mode.Values: compact, full, disabled, legacy (deprecated)

K6_SUMMARY_EXPORT

string
Export summary to a JSON file.

K6_NO_THRESHOLDS

boolean
Disable threshold execution.

Test Execution Variables

K6_LINGER

boolean
Keep the API server alive after test completion.

K6_NO_USAGE_REPORT

boolean
Disable anonymous usage statistics.

K6_WEB_DASHBOARD

boolean
Enable the web dashboard.

Tracing Variables

K6_TRACES_OUTPUT

string
default:"none"
Distributed tracing output configuration.Values: none, otel, otel=host:port

SSLKEYLOGFILE

string
File to write TLS master secrets for decrypting traffic.

Cloud Variables

K6_CLOUD_TOKEN

string
Grafana Cloud k6 authentication token.

K6_CLOUD_HOST

string
default:"https://ingest.k6.io"
Grafana Cloud k6 API host.

K6_CLOUD_PROJECT_ID

int
Project ID for organizing cloud tests.

K6_CLOUD_STACK_ID

int
Stack ID for Grafana Cloud instance.

K6_SHOW_CLOUD_LOGS

boolean
default:"true"
Stream cloud test logs to terminal.

K6_EXIT_ON_RUNNING

boolean
Exit when cloud test reaches running state.

K6_CLOUD_UPLOAD_ONLY

boolean
Upload test to cloud without running it.Deprecated: Use k6 cloud upload instead.

K6_NO_ARCHIVE_UPLOAD

boolean
Disable archive upload in cloud run commands.

Global Variables

K6_ADDRESS

string
default:"localhost:6565"
REST API server address.

K6_CONFIG

string
default:"./k6.json"
Path to configuration file.

K6_LOG_FORMAT

string
default:"text"
Log output format.Values: text, json

K6_LOG_OUTPUT

string
default:"stderr"
Log output destination.Values: stderr, stdout, or file path

K6_NO_COLOR

boolean
Disable colored output.

K6_QUIET

boolean
Disable progress updates.

K6_VERBOSE

boolean
Enable verbose logging.

Script Environment Variables

Variables prefixed with K6_ are k6 configuration. To pass custom variables to your script:
In your script:

CI/CD Best Practices

Secrets Management

Never hardcode secrets in scripts:

Configuration Matrix

Use environment variables for test variants:

Output Configuration

Configure outputs per environment:

Boolean Values

Environment variables accept these boolean values: True: 1, t, T, true, TRUE, True False: 0, f, F, false, FALSE, False Example:

See Also