tasks/. Run them locally with veryfront task <name> or in the cloud as task runs.
Prerequisites
- A Veryfront project with the
tasks/directory available (see Create project). - For cloud execution: a
VERYFRONT_API_TOKENand a project reference (see Configuration).
Quick start
Create a task file:Task definition
A task file exports aTaskDefinition object as its default export:
Task context
Therun function receives a TaskContext:
env: filtered environment variables (useenvAllowlistto restrict)config: run configuration (passed when run in the cloud)projectId: project identifier (available in cloud context)environmentId: runtime-target environment identifier, when selectedsignal: optional cooperative cancellation signal
ctx.env: every variable
prefixed TENANT_ and a fixed set of framework VERYFRONT_ control keys (API
token, API URLs, project identity, branch ref, and the injected-payload
variable itself). Other project-defined VERYFRONT_ names are not filtered
solely because of that prefix. Cloud project variables are carried through the
VERYFRONT_TASK_ENV_JSON payload and merged over visible host variables. That
payload must be a JSON object; if it is malformed, execution fails before the
task function runs instead of continuing with missing configuration.
envAllowlist applies to both visible host variables and injected project
variables. Without an allowlist, local tasks receive non-reserved host
variables; use an allowlist when a task should see only a minimal set.
When execution is tied to an HTTP request or another cancellable runtime,
Veryfront passes that cancellation signal through ctx.signal. A signal that
is already aborted prevents the task from starting. Long-running task code
should pass the signal to cancellable operations such as fetch; JavaScript
functions that ignore the signal cannot be forcibly terminated by the task
runner.
Discovery
Tasks are discovered automatically from thetasks/ directory:
.ts and .tsx task modules.
The deprecated standalone discoverTasks helper also accepts .js and
.jsx and skips test files and node_modules. Task IDs preserve nested path
segments and use / on every supported operating system.
Running tasks
CLI
tasks/.
As a cloud run
Setschedulable: true when a task should be presented as eligible for
schedule targeting. Runs and schedules identify it with the same stable task
ID:
Verify it worked
Run the task locally first:console.log output, exits with status 0, and
returns the value you returned from run as the final JSON line.
For cloud execution, create a run that targets the task and check Studio for
a completed status. See the verification block in Runs for the
SDK-driven check.