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):- Script options (
export const options = {}) - Configuration file (
k6.json) - Environment variables
- CLI flags (highest priority)
Runtime Environment Variables
K6_TYPE
Override test type detection.Values:
js, archiveK6_INCLUDE_SYSTEM_ENV_VARS
Pass system environment variables to the script runtime.
K6_COMPATIBILITY_MODE
JavaScript runtime compatibility mode.Values:
extended, base, experimental_enhancedOutput and Summary Variables
K6_OUT
Metrics output destinations (comma-separated).
K6_NO_SUMMARY
Disable the end-of-test summary.Deprecated: Use
K6_SUMMARY_MODE=disabled instead.K6_SUMMARY_MODE
Summary display mode.Values:
compact, full, disabled, legacy (deprecated)K6_SUMMARY_EXPORT
Export summary to a JSON file.
K6_NO_THRESHOLDS
Disable threshold execution.
Test Execution Variables
K6_LINGER
Keep the API server alive after test completion.
K6_NO_USAGE_REPORT
Disable anonymous usage statistics.
K6_WEB_DASHBOARD
Enable the web dashboard.
Tracing Variables
K6_TRACES_OUTPUT
Distributed tracing output configuration.Values:
none, otel, otel=host:portSSLKEYLOGFILE
File to write TLS master secrets for decrypting traffic.
Cloud Variables
K6_CLOUD_TOKEN
Grafana Cloud k6 authentication token.
K6_CLOUD_HOST
Grafana Cloud k6 API host.
K6_CLOUD_PROJECT_ID
Project ID for organizing cloud tests.
K6_CLOUD_STACK_ID
Stack ID for Grafana Cloud instance.
K6_SHOW_CLOUD_LOGS
Stream cloud test logs to terminal.
K6_EXIT_ON_RUNNING
Exit when cloud test reaches running state.
K6_CLOUD_UPLOAD_ONLY
Upload test to cloud without running it.Deprecated: Use
k6 cloud upload instead.K6_NO_ARCHIVE_UPLOAD
Disable archive upload in cloud run commands.
Global Variables
K6_ADDRESS
REST API server address.
K6_CONFIG
Path to configuration file.
K6_LOG_FORMAT
Log output format.Values:
text, jsonK6_LOG_OUTPUT
Log output destination.Values:
stderr, stdout, or file pathK6_NO_COLOR
Disable colored output.
K6_QUIET
Disable progress updates.
K6_VERBOSE
Enable verbose logging.
Script Environment Variables
Variables prefixed withK6_ are k6 configuration. To pass custom variables to 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: