Skip to content

feat: Add support for loading environment variables from .env files#3127

Open
sailsdima wants to merge 9 commits intomobile-dev-inc:mainfrom
sailsdima:env-file-support
Open

feat: Add support for loading environment variables from .env files#3127
sailsdima wants to merge 9 commits intomobile-dev-inc:mainfrom
sailsdima:env-file-support

Conversation

@sailsdima
Copy link
Copy Markdown
Contributor

@sailsdima sailsdima commented Apr 3, 2026

Proposed changes

This PR adds a new --env-file CLI option that allows loading environment variables from a .env file instead of passing them one-by-one with -e. The support is added for commands: test, record, and cloud.

EnvFileParser - parses .env files into key-value map. TestCommand, RecordCommand and CloudCommand call merge .env file with environment map logic.

File parser supports:

  • Values in format NAME=VALUE
  • Line comments: # Comment
  • Inline comments: NAME=VALUE # Comment
  • Quoting values: NAME='Quote 1 # no-comment' OR NAME="Quote 2 # no-comment". Usage: COLOR="#FFFFFF"

Usage example:

# Test comment
APP_ID=com.example.app # Test inline comment
orientationLandscapeLeft=LANDSCAPE_LEFT
orientationLandscapeRight=LANDSCAPE_RIGHT
orientationUpsideDown= UPSIDE_DOWN
orientationPortrait= PORTRAIT
TEST_MESSAGE=Hello from environment file!
TEST_URL=https://api.example.com
TEST_QUOTE_1="Quote 1"
TEST_QUOTE_2='Quote 2'
./maestro-cli/build/install/maestro/bin/maestro test flow.yaml --env-file environments/.env

Note: if both --env-file and -e used, env variables added via -e will override values with the same name from --env-file.

copilot:summary

Testing

Does this need e2e tests? Please consider contributing them to the demo app repository.

Created a new e2e test with tag env-file-orientation that uses --env-file which is based on Maestro Orientation sample app. Updated run_tests script to use it.

Usage for local run:

./maestro-cli/build/install/maestro/bin/maestro test e2e/workspaces/setOrientation/test-env-file-and-set-orientation.yaml --env-file e2e/workspaces/setOrientation/.env    
image image

Issues fixed

#2817

@sailsdima sailsdima changed the title Add support for loading environment variables from .env files feat: Add support for loading environment variables from .env files Apr 3, 2026
@sailsdima sailsdima force-pushed the env-file-support branch 4 times, most recently from 9f35111 to e3351b8 Compare April 6, 2026 14:23
@sailsdima sailsdima marked this pull request as ready for review April 7, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant