Skip to content

Commit 84edb12

Browse files
committed
Added preview stuff to the Context docs
1 parent 93fd184 commit 84edb12

File tree

1 file changed

+45
-7
lines changed

1 file changed

+45
-7
lines changed

docs/context.mdx

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ title: "Context"
33
description: "Get the context of a task run."
44
---
55

6-
Context (`ctx`) is a way to get information about a run.
6+
Context (`ctx`) is a way to get information about a run.
77

88
<Note>
9-
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.
9+
The context object does not change whilst your code is executing. This means values like
10+
`ctx.run.durationMs` will be fixed at the moment the `run()` function is called.
1011
</Note>
1112

1213
<RequestExample>
@@ -17,7 +18,6 @@ import { task } from "@trigger.dev/sdk/v3";
1718
export const parentTask = task({
1819
id: "parent-task",
1920
run: async (payload: { message: string }, { ctx }) => {
20-
2121
if (ctx.environment.type === "DEVELOPMENT") {
2222
return;
2323
}
@@ -32,7 +32,8 @@ export const parentTask = task({
3232
<ResponseField name="task" type="object">
3333
<Expandable title="properties" defaultOpen={true}>
3434
<ResponseField name="exportName" type="string">
35-
The exported function name of the task e.g. `myTask` if you defined it like this: `export const myTask = task(...)`.
35+
The exported function name of the task e.g. `myTask` if you defined it like this: `export
36+
const myTask = task(...)`.
3637
</ResponseField>
3738
<ResponseField name="id" type="string">
3839
The ID of the task.
@@ -93,13 +94,16 @@ export const parentTask = task({
9394
The [maximum number of attempts](/triggering#maxattempts) allowed for this task run.
9495
</ResponseField>
9596
<ResponseField name="durationMs" type="number">
96-
The duration of the task run in milliseconds when the `run()` function is called. For live values use the [usage SDK functions](/run-usage).
97+
The duration of the task run in milliseconds when the `run()` function is called. For live
98+
values use the [usage SDK functions](/run-usage).
9799
</ResponseField>
98100
<ResponseField name="costInCents" type="number">
99-
The cost of the task run in cents when the `run()` function is called. For live values use the [usage SDK functions](/run-usage).
101+
The cost of the task run in cents when the `run()` function is called. For live values use the
102+
[usage SDK functions](/run-usage).
100103
</ResponseField>
101104
<ResponseField name="baseCostInCents" type="number">
102-
The base cost of the task run in cents when the `run()` function is called. For live values use the [usage SDK functions](/run-usage).
105+
The base cost of the task run in cents when the `run()` function is called. For live values
106+
use the [usage SDK functions](/run-usage).
103107
</ResponseField>
104108
<ResponseField name="version" type="string" optional>
105109
The [version](/versioning) of the task run.
@@ -132,6 +136,40 @@ export const parentTask = task({
132136
<ResponseField name="type" type="string">
133137
The type of the environment (PRODUCTION, STAGING, DEVELOPMENT, or PREVIEW).
134138
</ResponseField>
139+
<ResponseField name="branchName" type="string" optional>
140+
If the environment is `PREVIEW` then this will be the branch name.
141+
</ResponseField>
142+
<ResponseField name="git" type="object">
143+
<Expandable title="properties">
144+
<ResponseField name="commitAuthorName" type="string" optional>
145+
The name of the commit author.
146+
</ResponseField>
147+
<ResponseField name="commitMessage" type="string" optional>
148+
The message of the commit.
149+
</ResponseField>
150+
<ResponseField name="commitRef" type="string" optional>
151+
The ref of the commit.
152+
</ResponseField>
153+
<ResponseField name="commitSha" type="string" optional>
154+
The SHA of the commit.
155+
</ResponseField>
156+
<ResponseField name="dirty" type="boolean" optional>
157+
Whether the commit is dirty, i.e. there are uncommitted changes.
158+
</ResponseField>
159+
<ResponseField name="remoteUrl" type="string" optional>
160+
The remote URL of the repository.
161+
</ResponseField>
162+
<ResponseField name="pullRequestNumber" type="number" optional>
163+
The number of the pull request.
164+
</ResponseField>
165+
<ResponseField name="pullRequestTitle" type="string" optional>
166+
The title of the pull request.
167+
</ResponseField>
168+
<ResponseField name="pullRequestState" type="string" optional>
169+
The state of the pull request (open, closed, or merged).
170+
</ResponseField>
171+
</Expandable>
172+
</ResponseField>
135173
</Expandable>
136174
</ResponseField>
137175

0 commit comments

Comments
 (0)