Configure Station Variables

Last updated on November 23, 2026

Run one procedure on several benches, each with its own DMM address, and talk to a different MES per environment. The values live in TofuPilot, not in your repository.

KeyTypeSet per
DMM_RESOURCEConfigStation
MES_URLConfigEnvironment
MES_TOKENSecretEnvironment

Prerequisites

  • A procedure linked to TofuPilot and deployed with git deployments
  • Two stations running it, here bench-1 and bench-2
  • The Admin or Owner role, and the CLI logged in as yourself (tofupilot login)

Step 1: Declare the Keys

Declare the keys in procedure.yaml, then pass them to the plug and the phase with with:.

procedure.yaml
config:
  DMM_RESOURCE:
    required: true
  MES_URL:
    required: true

secrets:
  MES_TOKEN:
    required: true

plugs:
  - name: DMM
    python: plugs.dmm:Dmm
    with:
      resource: "{config.DMM_RESOURCE}"

main:
  - name: Report to MES
    python: phases.mes:report
    with:
      url: "{config.MES_URL}"
      token: "{secrets.MES_TOKEN}"
phases/mes.py
import requests

def report(unit, url, token):
    # url and token are resolved for this run's environment
    response = requests.post(
        f"{url}/results",
        headers={"Authorization": f"Bearer {token}"},
        json={"serial": unit.serial_number},
        timeout=10,
    )
    response.raise_for_status()

Step 2: Run Locally

Local runs read .env.local next to procedure.yaml, never the values stored in TofuPilot.

.env.local
DMM_RESOURCE="TCPIP0::192.168.1.50::INSTR"
MES_URL="https://mes-sandbox.example.com"
MES_TOKEN="sandbox-token"
Terminal
echo ".env*" >> .gitignore
tofupilot run .

Step 3: Set the Values

Set the DMM address on each station as a Config:

Terminal
tofupilot env add DMM_RESOURCE --station bench-1 --no-sensitive --value "TCPIP0::10.0.1.21::INSTR"
tofupilot env add DMM_RESOURCE --station bench-2 --no-sensitive --value "TCPIP0::10.0.1.22::INSTR"

Set the MES URL per environment on the procedure:

Terminal
tofupilot env add MES_URL production --no-sensitive --value https://mes.example.com
tofupilot env add MES_URL preview,development --no-sensitive --value https://mes-sandbox.example.com

Set the token per environment. The CLI asks for each value at a hidden prompt:

Terminal
tofupilot env add MES_TOKEN production --note "Rotate in the MES admin console"
tofupilot env add MES_TOKEN preview,development

You can also set them in the dashboard, on the station page and the procedure's Environment Variables tab.

Step 4: Check Each Station

Terminal
tofupilot env resolve production --station bench-2
Output
Key            Value                       Wins       Shadows
DMM_RESOURCE   TCPIP0::10.0.1.22::INSTR    station    -
MES_URL        https://mes.example.com     procedure  -

The station value wins over the procedure, which wins over Shared.

Step 5: Deploy and Run

Merge to your production branch. Each station pulls the build and fetches its values before the run.

A station missing a required value does not start the run. The operator sees the missing keys:

Kiosk
Station not configured: config.DMM_RESOURCE missing

Each run records the values it used: the DMM address and MES URL, and the version of MES_TOKEN, never its value.

A preview build on a line station receives the preview token, and no secret set on the station. Production credentials only reach production builds. See Environment Variables Security.

Step 6: Rotate the Token

Terminal
tofupilot env update MES_TOKEN production

Or use Rotate in the dashboard. The version increases, so you can tell which runs used which token.

How is this guide?

On this page