github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/dispatch_payload.mdx (about) 1 --- 2 layout: docs 3 page_title: dispatch_payload Stanza - Job Specification 4 description: |- 5 The "dispatch_payload" stanza allows a task to access dispatch payloads. 6 to 7 --- 8 9 # `dispatch_payload` Stanza 10 11 <Placement groups={['job', 'group', 'task', 'dispatch_payload']} /> 12 13 The `dispatch_payload` stanza is used in conjunction with a [`parameterized`][parameterized] job 14 that expects a payload. When the job is dispatched with a payload, the payload 15 will be made available to any task that has a `dispatch_payload` stanza. The 16 payload will be written to the configured file before the task is started. This 17 allows the task to use the payload as input or configuration. 18 19 ```hcl 20 job "docs" { 21 group "example" { 22 task "server" { 23 dispatch_payload { 24 file = "config.json" 25 } 26 } 27 } 28 } 29 ``` 30 31 ## `dispatch_payload` Parameters 32 33 - `file` `(string: "")` - Specifies the file name to write the content of 34 dispatch payload to. The file is written relative to the [task's local 35 directory][localdir]. 36 37 ## `dispatch_payload` Examples 38 39 The following examples only show the `dispatch_payload` stanzas. Remember that the 40 `dispatch_payload` stanza is only valid in the placements listed above. 41 42 ### Write Payload to a File 43 44 This example shows a `dispatch_payload` block in a parameterized job that writes 45 the payload to a `config.json` file. 46 47 ```hcl 48 dispatch_payload { 49 file = "config.json" 50 } 51 ``` 52 53 [localdir]: /docs/runtime/environment#local 'Task Local Directory' 54 [parameterized]: /docs/job-specification/parameterized 'Nomad parameterized Job Specification'