TriggerClient.defineJob instance method:
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);
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);
Constructor
Parameters
object
required
Hide properties
Hide properties
string
required
The
id property is used to uniquely identify the Job. Only change this if you want to create a new Job.string
required
The
name of the Job that you want to appear in the dashboard and logs. You can change this without creating a new Job.string
required
The
version property is used to version your Job. A new version will be created if you change this property. We recommend using semantic versioning, e.g. 1.0.3.object
required
The
trigger property is used to define when the Job should run. There are currently the following Trigger types:- invokeTrigger
- cronTrigger
- intervalTrigger
- eventTrigger
- DynamicTrigger
- DynamicSchedule
- integration Triggers, like webhooks. See the integrations page for more information.
function
required
This function gets called automatically when a Run is Triggered. It has three parameters:
payload– The payload that was sent to the Trigger API.- io – An object that contains the integrations that you specified in the
integrationsproperty and other useful functions like delays and running Tasks. - context – An object that contains information about the Organization, Job, Run and more.
object
Imports the specified integrations into the Job. The integrations will be available on the
io object in the run() function with the same name as the key. For example:client.defineJob({
//... other options
integrations: {
slack,
gh: github,
},
run: async (payload, io, ctx) => {
//slack is available on io.slack
io.slack.postMessage(...);
//github is available on io.gh
io.gh.addIssueLabels(...);
}
});
boolean
The
enabled property is an optional property that specifies whether the Job is enabled or not. The Job will be enabled by default if you omit this property. When a job is disabled, no new runs will be triggered or resumed. In progress runs will continue to run until they are finished or delayed by using io.wait.number | ConcurrencyLimit
The
concurrencyLimit property is an optional property that specifies the maximum number of concurrent run executions. If this property is omitted, the job can potentially use up the full concurrency of an environment. You can also create a limit on a group of jobs by defining a ConcurrencyLimit object.function
The
onSuccess property is an optional property that specifies a callback function to run when the Job finishes successfully. The callback function receives a Run Notification object as it's only parameter.function
The
onFailure property is an optional property that specifies a callback function to run when the Job fails to complete successfully. The callback function receives a Run Notification object as it's only parameter.log | error | warn | info | debug
The
logLevel property is an optional property that specifies the level of
logging for the Job. The level is inherited from the client if you omit this property.log- logs only essential messageserror- logs error messageswarn- logs errors and warning messagesinfo- logs errors, warnings and info messagesdebug- logs everything with full verbosity
Returns
Job

