Environment Variables
Configure curl-runner behavior using environment variables for consistent settings across different environments.
Overview
Environment variables provide a way to configure curl-runner without modifying YAML files or using command-line options. This is particularly useful for CI/CD pipelines, containerized environments, and maintaining consistent settings across teams.
Configuration Precedence
Settings are applied in the following order (later overrides earlier):
- Default values
- Configuration file (curl-runner.yaml)
- Environment variables
- Command-line options
Basic Usage
Set environment variables in your shell or include them inline when running commands.
# Set verbose output
export CURL_RUNNER_VERBOSE=true
curl-runner tests/
# Set parallel execution
export CURL_RUNNER_EXECUTION=parallel
curl-runner api-tests.yaml
# Set multiple variables
export CURL_RUNNER_VERBOSE=true
export CURL_RUNNER_EXECUTION=parallel
export CURL_RUNNER_CONTINUE_ON_ERROR=true
curl-runner tests/
# Inline environment variables (one-time use)
CURL_RUNNER_VERBOSE=true curl-runner tests/Available Variables
All curl-runner environment variables follow the CURL_RUNNER_* naming convention.
CURL_RUNNER_VERBOSEEnable verbose output with detailed request/response information
export CURL_RUNNER_VERBOSE=trueCURL_RUNNER_EXECUTIONSet execution mode: sequential or parallel
export CURL_RUNNER_EXECUTION=parallelCURL_RUNNER_CONTINUE_ON_ERRORContinue execution when individual requests fail
export CURL_RUNNER_CONTINUE_ON_ERROR=trueCURL_RUNNER_OUTPUT_FORMATSet output format: json, pretty, or raw
export CURL_RUNNER_OUTPUT_FORMAT=jsonCURL_RUNNER_PRETTY_LEVELSet pretty format detail level: minimal, standard, or detailed
export CURL_RUNNER_PRETTY_LEVEL=detailedCURL_RUNNER_OUTPUT_FILESave execution results to specified file
export CURL_RUNNER_OUTPUT_FILE=results.jsonCURL_RUNNER_TIMEOUTSet global timeout for all requests in milliseconds
export CURL_RUNNER_TIMEOUT=10000CURL_RUNNER_RETRIESSet maximum number of retries for failed requests
export CURL_RUNNER_RETRIES=3CURL_RUNNER_RETRY_DELAYSet delay between retry attempts in milliseconds
export CURL_RUNNER_RETRY_DELAY=2000Output Configuration
Control how results are displayed and saved using output-related environment variables.
# Set output format
export CURL_RUNNER_OUTPUT_FORMAT=json
curl-runner tests/
# Set pretty level for detailed output
export CURL_RUNNER_OUTPUT_FORMAT=pretty
export CURL_RUNNER_PRETTY_LEVEL=detailed
curl-runner tests/
# Save output to file
export CURL_RUNNER_OUTPUT_FILE=results.json
curl-runner tests/
# Enable verbose logging
export CURL_RUNNER_VERBOSE=true
curl-runner tests/Request Configuration
Configure default request behavior including timeouts and retry logic.
# Set global timeout (milliseconds)
export CURL_RUNNER_TIMEOUT=10000
curl-runner tests/
# Configure retry behavior
export CURL_RUNNER_RETRIES=3
export CURL_RUNNER_RETRY_DELAY=2000
curl-runner tests/
# Disable retries
export CURL_RUNNER_RETRIES=0
curl-runner tests/Execution Configuration
Control how requests are executed and how errors are handled.
# Set execution mode
export CURL_RUNNER_EXECUTION=parallel
curl-runner tests/
# Continue on errors
export CURL_RUNNER_CONTINUE_ON_ERROR=true
curl-runner tests/
# Combine execution settings
export CURL_RUNNER_EXECUTION=parallel
export CURL_RUNNER_CONTINUE_ON_ERROR=true
curl-runner tests/Docker & Containers
Environment variables are ideal for containerized deployments where configuration should be injected at runtime.
# Dockerfile example
FROM node:20-alpine
ENV CURL_RUNNER_VERBOSE=false
ENV CURL_RUNNER_OUTPUT_FORMAT=json
ENV CURL_RUNNER_EXECUTION=sequential
WORKDIR /app
RUN npm install -g curl-runner
CMD ["curl-runner", "/tests"]CI/CD Integration
Examples of using environment variables in popular CI/CD platforms.
# GitHub Actions
- name: Run API Tests
env:
CURL_RUNNER_VERBOSE: true
CURL_RUNNER_OUTPUT_FORMAT: json
CURL_RUNNER_CONTINUE_ON_ERROR: true
run: curl-runner tests/
# GitLab CI
test:
variables:
CURL_RUNNER_EXECUTION: parallel
CURL_RUNNER_TIMEOUT: "30000"
script:
- curl-runner api-tests.yaml
# Jenkins Pipeline
pipeline {
environment {
CURL_RUNNER_VERBOSE = 'true'
CURL_RUNNER_OUTPUT_FILE = 'test-results.json'
}
stages {
stage('Test') {
steps {
sh 'curl-runner tests/'
}
}
}
}Best Practices
Use for Environment-Specific Settings
Environment variables are perfect for settings that change between development, staging, and production environments.
Keep Secrets Secure
While curl-runner doesn't directly handle secrets, avoid logging verbose output in production when sensitive data might be exposed.
Document Your Variables
Create a .env.example file in your project to document required environment variables for your team.
Prefer Explicit Over Implicit
For critical settings like timeouts and retries, consider using explicit command-line options for clarity in scripts and CI pipelines.