Skip to content
Latchkey

hurl --variable: Inject Values into Hurl Files

hurl --variable name=value substitutes {{name}} placeholders in the Hurl file, parameterizing host, tokens, and expectations.

A single .hurl file can target staging or production by injecting the base URL and secrets at run time. --variable sets one, and --variables-file loads many from a file.

What it does

--variable name=value defines a variable that replaces {{name}} in the Hurl file. --variables-file <file> reads name=value pairs, one per line. Variables also come from captures and from environment variables prefixed HURL_. Undefined placeholders cause a run-time error rather than a silent empty substitution.

Common usage

Terminal
hurl --variable host=https://staging.example.com smoke.hurl
hurl --variable token="$API_TOKEN" --test api.hurl
hurl --variables-file ci.env --test tests/*.hurl
# ci.env contains: host=https://example.com

Options

FlagWhat it does
--variable name=valueDefine a single variable
--variables-file <file>Load variables from a file (name=value lines)
HURL_name env varEnvironment variable picked up as a variable
{{name}}Placeholder in the Hurl file to substitute

In CI

Pass secrets via --variable token="$SECRET" sourced from the CI secret store, and keep the non-secret host/config in a --variables-file committed to the repo. One file then covers every environment by swapping the variables at run time.

Common errors in CI

error: Undefined variable\n | {{host}} means a placeholder was used but never provided by --variable, a file, or a capture; define it or check the spelling. A request going to the wrong environment usually means the variable value was set but the file still hardcodes the URL instead of using {{host}}.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →