What Is an Environment Variable? Config in the Shell
An environment variable is a named value stored in a process and inherited by the programs it launches, used to pass configuration without hardcoding it.
Environment variables are how the shell and the programs it runs share small pieces of configuration: where to find things, which mode to run in, or which credentials to use. A child process inherits a copy of its parent's environment, which is exactly how CI passes settings and secrets into your build steps.
What an environment variable is
It is a key-value pair attached to a process. When that process starts a child, the child receives a copy. The classic example is PATH, but applications read many of their own, like NODE_ENV or CI.
Setting and reading them
In Bash you set one with export NAME=value and read it with $NAME or "${NAME}". Without export, the variable stays a shell variable and is not passed to child programs.
Common uses
- Configuration: feature flags, log levels, target environments.
- Discovery: PATH, HOME, and similar locations.
- Secrets: API tokens and credentials injected at runtime.
- CI signals: the
CI=truevariable many tools check.
Environment variables vs shell variables
A plain shell variable lives only in the current shell. An environment variable (one you exported) is inherited by child processes. This distinction explains why a value set in one place is sometimes invisible to a program you launch.
Env vars in CI
CI platforms inject environment variables for configuration and secrets. In GitHub Actions you set per-step values inline, or write to the $GITHUB_ENV file to share a value with later steps, since each step runs in its own shell.
Secrets and managed runners
On Latchkey runners, secrets are delivered as masked environment variables so they are available to your job but redacted from logs. Treat any secret-bearing variable carefully and avoid echoing it.
Key takeaways
- An environment variable is a named value a process passes down to its children.
- You must
exporta variable for child programs to see it. - CI uses environment variables to inject config and secrets into build steps.