Docs
Environment Variables

Environment variables

You can use environment variables to dynamically populate Hashboard configuration files with different values across deployments.

Using environment variables

Environment variable substitution happens at build-time, when you create a Preview or Deploy build. The syntax for substituting an environment variable is $ENV_VAR_NAME or ${ENV_VAR_NAME}.

For example, if your model file contains:

hb_version: "1.0"
name: My Data Model
source:
  connectionName: ${DATABASE_CONNECTION_NAME}
  physicalName: test_table

...then you can preview a Build against your dev database by running:

$ DATABASE_CONNECTION_NAME=dev hb build

Environment variables are resolved in the following order:

  1. Local environment variables in your shell, if using the Hashboard CLI
  2. Default environment variables set on the project you are deploying to. This applies to builds triggered both through the CLI and through the Hashboard Git integration.

If after both steps, there are still unresolved environment variables in any of your config files, an error will be raised and your build will not succeed.

⚠️

Do not use Hashboard environment variables to store secrets or sensitive values.

Environment variable values are substituted directly into your yml configurations, which will be visible by anybody that has access to that resource in Hashboard. This means you should not use environment variable substitution for anything that you wouldn't be comfortable directly adding to your yml file.

Setting default environment variables

You can use the Hashboard UI to configure default environment variables for your project. These values will be used by default for variable substitution in any Preview and Deploy builds deployed to that project.

To set project environment variables:

  1. Navigate to the DataOps (opens in a new tab) page using the link in the "More" menu of the navigation bar.
  2. Scroll down to the Environment Variables (opens in a new tab) section.
  3. Configure the name and value for each of your environment variables, and then click Save.

Escaping dollar signs

If you want to include a literal '$' in your configuration file (i.e. not as a placeholder for an environment variable), you can escape it by doubling it up. For example:

hb_version: "1.0"
name: Revenue
description: This year's revenue in $$

...will create a resource with description This year's revenue in $.