Skip to main content
Environment variables give the agent and every command it runs access to values such as API keys, tokens, and service URLs. Use them when a tool, script, or test in your repo expects a value from the environment. Cake supports two scopes:
  • Organization variables apply to every session in your organization. Only users with the admin role can manage them.
  • Personal variables apply only to sessions you own.
When both scopes define the same key, your personal value overrides the organization value in your sessions.

Add a variable

  1. Go to Settings → User → Sessions for a personal variable. For an organization variable, go to Settings → Organization → Sessions.
  2. In the Environment Variables section, select Add Variable.
  3. Enter a Key and a Value.
  4. Toggle Secret on if the value is sensitive.
  5. Select Save.
Keys must start with a letter or underscore and contain only letters, digits, and underscores, up to 253 characters. Your personal Sessions page also lists organization variables. A personal variable with the same key replaces the organization one in that list.

Override an organization variable

Your personal Sessions page marks organization variables with a building icon. You can’t edit or remove them there, but you can replace them with your own value in your sessions.
  • To set your own value, select Create Override (pencil icon) next to the organization variable. Cake opens the variable for editing with the key already filled in. Enter your value and select Save.
  • To set the variable to an empty string in your sessions, select Create empty override (eraser icon). Cake saves a personal variable with the same key and an empty value.
To go back to the organization value, remove your personal variable.

Import variables from a .env file

  1. In the Environment Variables section, select Import.
  2. Paste the contents of your .env file, then select Import.
  3. Review the parsed keys and values. Remove any you don’t want, and mark sensitive values as Secret.
  4. Select Save.
.env

Secret variables

Cake hides secret values once you save them. You can’t view a secret value in the UI again, but you can replace it with a new value. Secret and non-secret variables reach the session the same way. Cake sends them to the session over an authenticated internal connection when the session container starts. Values aren’t stored in the Kubernetes pod spec or in any volume that outlives the pod.

When changes take effect

Cake loads your variables each time a session container starts. New sessions get your current variables. A running session keeps the variables it started with until its container restarts.

Reserved names

Cake sets the following variables itself and ignores any variable you add with these names:
  • CAKE_SERVICE_ACCOUNT_TOKEN_FILE
  • CAKE_AUTH_PROXY_PORT
  • CONTROL_PLANE_URL
  • SESSION_ID
  • CAKE_VOLUME_AUTOSCALING_ENABLED