Environment variables
CAT replaces %VARIABLE_NAME% with the value of that environment variable.
On this page
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.
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:
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:
Query: |
SELECT COUNT(*) AS Count
FROM Operation.SecurityCheck
WHERE Terminal = %TERMINAL_NUMBER%
In test names, in descriptions, in the path a list points at, in root settings such as Threads — wherever a value is needed.
.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 — defining a variable, quoting it in YAML, and checking that CAT can see it.
- Work with passwords — keeping secrets out of the project file.