Skip to main content

Add an environment variable

A project's environment variables are written into a slot's settings when a task claims it. Use one for a setting the project's code reads, such as a service address. For a secret, read the value from a credential instead of typing it in, so it is never shown on the project.

Who can do this: anyone who can view the project can add a variable that applies only to them. A variable for everyone needs the permission to edit the project.

Add the variable​

  1. In the sidebar, select Directory, then the Projects tab.

  2. Select the project's name to open its settings.

  3. Settings opens. Select Variables in its list of sections.

  4. Select Add variable. The New variable page opens beside the list.

    The New variable page: Variable name, Applies to, Value from, Value and Description, with Cancel and Create

  1. Enter the Variable name.
  2. If you can edit the project, pick Everyone or Only me in Applies to. Otherwise the field isn't shown and the variable applies only to you. This can't be changed later.
  3. In Value from, pick where the value comes from:
    • A literal: type it in Value.
    • A credential: pick the Credential, then the Credential field to read from it. Only credentials you may use are listed.
    • Port: a free port the node picks for each slot. Keep Auto-assigned per slot, or pick Preferred port; see Give a service a fixed port in every slot. Offered for Everyone only.
  4. Optional: say what the variable is for in Description.
  5. Select Create. The variable saves at once and its page shows it, its title marked Project default or Your override, and Not resolved when it can't get a value; the project's own Save button isn't needed.

Check what your tasks get​

In the Variables table, ✓ marks the row whose value your slot gets, ! one that doesn't resolve, with why under its name, and – any other row. For everything your slot gets, select Show preview. Under What your slot gets, each line is your own Only me value where you have one, and the project's value otherwise. A variable that can't get a value is shown commented out, with the reason under it, and isn't written. A line marked ⚑ is only a warning: that variable is still written. Copy copies the lines, credential values masked. Select Hide preview to close it.

To change or remove a variable later, see Change or delete an environment variable.