a-if

  • Blog

K6 Load Env Variable

Written by

Adashif Commit

at

2025-11-07 17:01:52 (GMT+0700)

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.

  1. Install the utility (e.g., dotenv-cli using npm):

    bash
    npm install -g dotenv-cli

    Use code with caution.
  2. Run your k6 test 
    using the utility:

    bash
    dotenv k6 run script.js

    Use code with caution.

    This command loads variables from your .env file and passes them as environment variables to the k6 process. 

    —
    Copied from https://share.google/aimode/oOFV8NQbC5m7h1KJ6
Category: AI-Assisted Q&A

←Prev
Repository to Diagram
Next→
Creating QR code in MacBook is Really Easy