Files
triggerdotdev--trigger.dev/docs/sdk/job.mdx
T
Eric Allam 17f6f29d05
🚀 Publish Trigger.dev Docker / e2e (push) Failing after 0s
🚀 Publish Trigger.dev Docker / units (push) Failing after 5s
🚀 Publish Trigger.dev Docker / typecheck (push) Failing after 5s
🚀 Publish Trigger.dev Docker / publish (push) Has been skipped
Feature: Support multiple runtimes other than Node.js (#774)
2023-12-06 10:23:37 +00:00

63 lines
1.4 KiB
Plaintext

---
title: "Job"
description: "Job is used to create and configure a Job"
---
A [Job](/documentation/concepts/jobs) is used to define the [Trigger](/documentation/concepts/triggers), metadata, and what happens when it runs.
You can define a job by using the `TriggerClient.defineJob` instance method:
<RequestExample>
```ts Example
new Job({
id: "github-integration-on-issue",
name: "GitHub Integration - On Issue",
version: "0.1.0",
trigger: github.triggers.repo({
event: events.onIssue,
owner: "triggerdotdev",
repo: "empty",
}),
run: async (payload, io, ctx) => {
await io.logger.info("This is a simple log info message");
return { payload, ctx };
},
}).attachToClient(client);
```
```ts notifications
new Job({
id: "github-integration-on-issue",
name: "GitHub Integration - On Issue",
version: "0.1.0",
trigger: github.triggers.repo({
event: events.onIssue,
owner: "triggerdotdev",
repo: "empty",
}),
onSuccess: async (notification) => {
console.log("Job succeeded", notification);
},
onFailure: async (notification) => {
console.log("Job failed", notification);
},
run: async (payload, io, ctx) => {
await io.logger.info("This is a simple log info message");
return { payload, ctx };
},
}).attachToClient(client);
```
</RequestExample>
# Constructor
## Parameters
<Snippet file="jobs/options.mdx" />
## Returns
<ResponseField name="Job instance" type="Job" />