@@ -129,6 +129,19 @@ for instance, `"#datasetOwner"` requires that a dataset be passed.
129129> services to external users. Please consider the security model carefully when
130130> configuring jobs.
131131
132+ # ## Templates
133+
134+ Many actions can be configured using templates, which get filled when the action runs.
135+ Template strings use [Handlebars](https://handlebarsjs.com/) syntax. The following
136+ top-level variables are availabe in the handlebars context :
137+
138+ | Top-level variable | Type | Examples | Description |
139+ |---|---|---|---|
140+ | `request` | `CreateJobDto` or<br/>`UpdateJobDto` | `{{request.type}}`<br/>`{{request.jobParams}}` | HTTP Request body |
141+ | `job` | `JobClass` | `{{job.id}}` | The job, as stored in the database. Not available for validate actions. |
142+ | `datasets` | `DatasetClass[]` | `{{#each datasets}}{{pid}}{{/each}}` | All datasets referenced in `job.jobParams.datasetsList`. |
143+ | `env` | `object` | `{{env.SECRET_TOKEN}}` | Access environmental variables |
144+
132145# ## Actions Configuration
133146
134147The following actions are built-in to SciCat and can be included in the `actions` array.
@@ -145,7 +158,7 @@ For example:
145158
146159` ` ` yaml
147160- actionType: url
148- url: http://localhost:3000/api/v3/health?jobid={{id}}
161+ url: http://localhost:3000/api/v3/health?jobid={{request. id}}
149162 method: GET
150163 headers:
151164 accept: application/json
@@ -212,8 +225,8 @@ jobs:
212225 jobParams.subject:
213226 type: string
214227 - actionType: email
215- to: "{{contactEmail}}"
216- subject: "[SciCat] {{jobParams.subject}}"
228+ to: "{{job. contactEmail}}"
229+ subject: "[SciCat] {{job. jobParams.subject}}"
217230 bodyTemplate: demo_email.html
218231 update:
219232 auth: admin
@@ -344,9 +357,9 @@ Example:
344357
345358` ` ` yaml
346359- actionType: email
347- to: "{{contactEmail}}"
360+ to: "{{job. contactEmail}}"
348361349- subject: "[SciCat] Your {{type}} job was submitted successfully."
362+ subject: "[SciCat] Your {{job. type}} job was submitted successfully."
350363 bodyTemplateFile: "path/to/job-template-file.html"
351364` ` `
352365
@@ -368,7 +381,7 @@ You can create your own template for the email's body, which should be a valid h
368381</head>
369382 <body>
370383 <p>
371- Your {{type}} job with id {{id}} has been submitted ...
384+ Your {{job. type}} job with id {{job. id}} has been submitted ...
372385 </p>
373386 </body>
374387</html>
0 commit comments