Watch it first

Why use variables

Scripts and pages often need values that differ from person to person, or from one environment to the next: an API address, a database name, an access token. Variables keep those values out of the script, so:

Open Tools, the toolbox at the top right, and choose its Variables tab, the $. Its button shows how many variables the current page has.

1. Define a project variable

  1. Open the Project tab.
  2. Type the variable's name in Key, and click Add.
  3. Type its value in the box beside its name.

The name is saved in .taskproxy/Variables.json, so your teammates see it too once you commit. The value you typed stays on your computer.

Each row also has buttons to copy the value to the clipboard, clear it, or delete the variable.

2. Add environments

The Environment dropdown on the Project tab holds a separate set of values for each environment. Every project starts with dev.

  1. Click Manage to add, rename, or delete environments, for example staging and prod.
  2. Choose an environment in the dropdown, and enter its values.

From then on, choosing an environment swaps in all of its values at once. Anything the environment leaves blank falls back to your global value of the same name.

3. Keep personal secrets global

The Global tab holds values for every project, such as your personal access token. Task Proxy reads your git token from a variable named github_pat or git_pat, from the project first and then from global.

4. Use variables in a script

In a page script, write the variable as an ordinary PowerShell variable with a placeholder value:

$apiBaseUrl = 'https://dev.api.acme.test'
Invoke-RestMethod "$apiBaseUrl/health"

When it runs, Task Proxy puts the value of the apiBaseUrl variable in place of 'https://dev.api.acme.test'. Variables with no value set leave the script as written, so the placeholder doubles as a default.

The Page tab lists the variables the current page's scripts use, so you can set a value for this page only.

When Task Proxy shows a script before running it, values longer than six characters are masked, such as htt***est, so secrets aren't shown on screen.

Which value wins

When the same name is set in more than one place, Task Proxy uses the first it finds:

  1. Page
  2. Project, from the active environment
  3. Global

The Enabled switches at the top of the Variables tab turn a whole scope off for a while. It's a quick way to test what a script does without your page or project values.

Variables can also have a default value, which is saved in Variables.json and committed. Never use a password or token as a default.

See also

How Task Proxy works

Continue to Edit your project's docs

Use Variables, Secrets, and Environments

Tutorial: about 10 minutes

You can also come chat with us on the Stoic Dreams discord server.

About Task Proxy Contact Stoic Dreams Privacy Terms & Conditions