Option 2: Use a command-line utility
You can use a command-line tool like dotenv-cli or a similar utility to load the environment variables into your shell environment before executing the k6 command.
- Install the utility (e.g.,
dotenv-cliusing npm):
bashnpm install -g dotenv-cli
Use code with caution. - Run your k6 test
using the utility:
bashdotenv k6 run script.js
Use code with caution.
This command loads variables from your.envfile and passes them as environment variables to the k6 process.
—
Copied from https://share.google/aimode/oOFV8NQbC5m7h1KJ6