---
title: "Environment variables"
description: "Environment variable expansion — syntax and where it applies"
url: "https://docs.justcat.it/reference/project-file/environment-variables/"
---
# Environment variables


Environment variables serve two purposes in CAT configuration:

* keeping sensitive values — passwords, secrets, whole connection strings — out of the file, and out of version control;
* parametrizing a project file, so one set of definitions can be run against several environments, terminals, regions and so on.

## Syntax

Refer to an environment variable as `%YOUR_ENVIRONMENT_VARIABLE_NAME%`.

Variable names follow the rules of the operating system: on Windows `%testing_user%` and `%TESTING_USER%` are the same variable, on Linux and macOS they are not. Write the name exactly as it is defined and it works on both.

Replacement happens only when a variable of that name exists. Text between percent signs that names no variable is left untouched — a query containing `WHERE PilotName LIKE '%SMITH%'` is passed through unchanged, because no variable named `SMITH` exists.

> **🐱:** **A `LIKE` pattern can collide with a real variable.** `LIKE '%PATH%'` or `LIKE '%TEMP%'` *is* replaced, because `PATH` and `TEMP` exist on every machine. There is no escape sequence; keep the two percent signs apart from the name, for example `'%' + 'PATH' + '%'`.



## Where it applies

In values — almost anywhere a value is read. Keys are never expanded. A whole connection string, or part of one:

```yaml
Connection string: '%AERO_CONNECTION_STRING%'
# or
Connection string: >
  Host=localhost;port=5432;database=aero_operations;CommandTimeout=10;
  User ID=%TESTING_USER%;Password=%TESTING_PASSWORD%;
```

Inside SQL or DAX statements — this is how a query is parametrized, a terminal or a race number coming from outside the file:

```yaml
Query: |
  SELECT  COUNT(*) AS Count
  FROM    Operation.SecurityCheck
  WHERE   Terminal = %TERMINAL_NUMBER%
```

In test names, in descriptions, in the path a [list](https://docs.justcat.it/reference/project-file/lists/ "Lists") points at, in [root settings](https://docs.justcat.it/reference/project-file/root-settings/ "Root settings") such as `Threads` — wherever a value is needed.

> **🐱:** **Expansion is not limited to the `.cat.yaml` file.** Definitions loaded from anywhere else are expanded the same way: other YAML files, worksheets, database tables and stored procedure results all go through the same replacement.



## Related

* [Use environment variables](https://docs.justcat.it/how-to-guides/organize-and-run-tests/use-environment-variables/ "Use environment variables") — defining a variable, quoting it in YAML, and checking that CAT can see it.
* [Work with passwords](https://docs.justcat.it/how-to-guides/organize-and-run-tests/work-with-secrets/ "Work with passwords") — keeping secrets out of the project file.

