Skip to main content

Multi-Environment Setup

Rumour makes it easy to switch your test executions across different target environments (such as development, staging, or production) by swapping environment configuration files.

Workspace Directory Structure​

A common practice is to define a default workspace.env.toml for local development, and create dedicated configuration files for other targets:

project/
├── workspace.env.toml # Default config (e.g., local/dev)
├── staging.env.toml # Staging config
├── prod.env.toml # Production config
├── auth/
│ └── login.toml
└── users/
└── get_user.toml

Choosing an Environment​

Example Setup​

Let's test environment swapping interactively. Initialize a new test workspace:

rumour init multi_env_example
cd multi_env_example

Create a default environment and a staging environment:

workspace.env.toml (Default)

base_url = "http://localhost:4000"
env_name = "local_dev"

staging.env.toml (Non-default)

base_url = "http://localhost:4000"
env_name = "staging_cloud"

And create a simple request to echo the {{env_name}} variable:

request.toml

name = "env_check"

[request]
method = "POST"
url = "{{base_url}}/post"

[body]
type = "json"
raw = '{"current_env": "{{env_name}}"}'

1. Default Loading Behavior​

If a workspace.env.toml file exists in your project root, Rumour automatically detects and loads its variables for every execution. You do not need to pass any extra parameters:

rumour run request.toml -v

The mock server will echo "current_env": "local_dev".

2. Custom Environment Loading​

To execute requests against a non-default environment, pass the path of the environment file using the -e or --env-file flag:

rumour run request.toml -e staging.env.toml -v

The mock server will now echo "current_env": "staging_cloud", proving the staging environment successfully loaded!

note

The -e file acts as an overlay that overrides any auto-discovered .env.toml files in the request's directory tree. If a variable is defined in both your local auth/local.env.toml and your explicit staging.env.toml, the value from the -e flag wins. To override even the -e file, use a CLI override (-V). See Variable Precedence for the full priority stack.

3. CLI Variable Overrides​

For quick, one-off changes without modifying any files, override individual variables directly from the command line using -V:

# Combine with environment file selection
rumour run request.toml -e staging.env.toml -V "env_name=hotfix_branch" -v

CLI -V overrides have the highest priority among non-vault sources, so the mock server will echo "current_env": "hotfix_branch".

Best Practices & Version Control​

To prevent sensitive environment configurations from being leaked or causing sync issues, follow these conventions:

1. Gitignore Sensitive Environment Files​

Avoid committing environment files that contain real credentials or environment-specific URLs. Add patterns to your .gitignore as appropriate:

# .gitignore
# Exclude environment-specific configs with real credentials
staging.env.toml
prod.env.toml

# Or exclude all env files and rely on .example templates
# *.env.toml
tip

workspace.env.toml can be safely committed if it only contains non-sensitive defaults (e.g., base_url = "http://localhost:3000") or vault references (e.g., token = "{{vault.api_token}}"). Only exclude it if it contains raw credentials.

2. Provide Template Examples​

Create and commit template configuration files (with .example suffixes) containing empty or mock values. This documents the required variables for team members without exposing live credentials:

# workspace.env.toml.example
base_url = "https://api-dev.example.com"
api_version = "v2"
github_token = "YOUR_VAULT_KEY_HERE"

To use the template, developers copy the example file:

cp workspace.env.toml.example workspace.env.toml

3. Use Vault for Secrets​

Instead of placing raw API keys or passwords in .env.toml files, store them in the encrypted Rumour Vault and reference them:

# workspace.env.toml — safe to share in templates
base_url = "https://api.github.com"
github_token = "{{vault.github_token}}"

See Encrypted Vault Secrets for setup instructions.