ctx) is a way to get information about a run.
The context object does not change whilst your code is executing. This means values like
ctx.run.durationMs will be fixed at the moment the run() function is called.import { task } from "@trigger.dev/sdk";
export const parentTask = task({
id: "parent-task",
run: async (payload: { message: string }, { ctx }) => {
if (ctx.environment.type === "DEVELOPMENT") {
return;
}
},
});
Context properties
object
object
object
Show properties
Show properties
string
The ID of the task run.
any
The context of the task run.
date
The creation time of the task run.
date
The start time of the task run.
string
An optional idempotency key for the task run.
number
The maximum number of attempts allowed for this task run.
number
The duration of the task run in milliseconds when the
run() function is called. For live
values use the usage SDK functions.number
The cost of the task run in cents when the
run() function is called. For live values use the
usage SDK functions.number
The base cost of the task run in cents when the
run() function is called. For live values
use the usage SDK functions.number
The maximum allowed duration for the task run.
object
Show properties
Show properties
string
The ID of the environment.
string
The slug of the environment.
string
The type of the environment (PRODUCTION, STAGING, DEVELOPMENT, or PREVIEW).
string
If the environment is
PREVIEW then this will be the branch name.object
Show properties
Show properties
string
The name of the commit author.
string
The message of the commit.
string
The ref of the commit.
string
The SHA of the commit.
boolean
Whether the commit is dirty, i.e. there are uncommitted changes.
string
The remote URL of the repository.
number
The number of the pull request.
string
The title of the pull request.
string
The state of the pull request (open, closed, or merged).
object
object
object
Optional information about the batch, if applicable.
Show properties
Show properties
string
The ID of the batch.

