Janet Carson
11/12/2025, 12:44 AMMarvin
11/12/2025, 12:44 AMNate
11/12/2025, 12:45 AMJanet Carson
11/12/2025, 12:45 AMNate
11/12/2025, 12:45 AMenv on the one work pool, all workers will use that base job templateJanet Carson
11/12/2025, 12:47 AMJanet Carson
11/12/2025, 12:47 AMNate
11/12/2025, 12:49 AMprefect.yaml, you can put it in here and mutate it via UI or SDK at any timeJanet Carson
11/12/2025, 12:49 AMNate
11/12/2025, 12:56 AMenv instead of the plaintext valueMarvin
11/12/2025, 12:56 AMexport MY_VAR="foo"
prefect worker start -p my-process-pool
or
MY_VAR="foo" prefect worker start -p my-process-pool
- If you use a service manager (e.g., systemd), set it there so every worker inherits it:
[Service]
Environment=MY_VAR=foo
ExecStart=/usr/local/bin/prefect worker start -p my-process-pool
2) Ensure every flow run launched by the process workers gets the variable
- Define it in the pool/deployment job variables so the worker passes it into each subprocess:
- In prefect.yaml:
deployments:
- name: my-deployment
entrypoint: flows/my_flow.py:flow
work_pool:
name: my-process-pool
job_variables:
env:
MY_VAR: "{{ $MY_VAR }}"
This “copies” the worker’s environment variable MY_VAR into the flow run environment. The {{ $ENV_VAR }} syntax references environment variables at runtime. See prefect.yaml guide and customize job variables.
- Or set it at the work pool level by editing the base job template to include a default env:
1) Get the default template:
prefect work-pool get-default-base-job-template --type process --file base-job-template.json
2) Edit base-job-template.json to add:
{
"job_configuration": {
"env": {
"MY_VAR": "{{ $MY_VAR }}"
}
}
}
3) Update the pool:
prefect work-pool update "my-process-pool" --base-job-template base-job-template.json
Docs: prefect work-pool CLI
Notes
- Using {{ $MY_VAR }} lets you “copy” the worker host’s environment variable into the flow run’s environment at runtime.
- If you just need a constant value for all runs, you can set env.MY_VAR: "foo" instead of templating.
Quick check: Do you want the variable set on the worker processes themselves, on every flow run they execute, or both? I can tailor the exact steps based on your setup (local shell, systemd, containers, etc.).