2017-01-26 04:49:06 +00:00
|
|
|
---
|
2020-02-06 23:45:31 +00:00
|
|
|
layout: docs
|
|
|
|
page_title: dispatch_payload Stanza - Job Specification
|
|
|
|
sidebar_title: dispatch_payload
|
2017-01-26 04:49:06 +00:00
|
|
|
description: |-
|
|
|
|
The "dispatch_payload" stanza allows a task to access dispatch payloads.
|
|
|
|
to
|
|
|
|
---
|
|
|
|
|
|
|
|
# `dispatch_payload` Stanza
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
<Placement groups={['job', 'group', 'task', 'dispatch_payload']} />
|
2017-01-26 04:49:06 +00:00
|
|
|
|
2017-07-17 18:41:50 +00:00
|
|
|
The `dispatch_payload` stanza is used in conjunction with a [`parameterized`][parameterized] job
|
2017-01-26 04:49:06 +00:00
|
|
|
that expects a payload. When the job is dispatched with a payload, the payload
|
|
|
|
will be made available to any task that has a `dispatch_payload` stanza. The
|
|
|
|
payload will be written to the configured file before the task is started. This
|
|
|
|
allows the task to use the payload as input or configuration.
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
job "docs" {
|
|
|
|
group "example" {
|
|
|
|
task "server" {
|
|
|
|
dispatch_payload {
|
|
|
|
file = "config.json"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## `dispatch_payload` Parameters
|
|
|
|
|
|
|
|
- `file` `(string: "")` - Specifies the file name to write the content of
|
2017-01-26 06:15:00 +00:00
|
|
|
dispatch payload to. The file is written relative to the [task's local
|
2017-01-26 04:49:06 +00:00
|
|
|
directory][localdir].
|
|
|
|
|
|
|
|
## `dispatch_payload` Examples
|
|
|
|
|
|
|
|
The following examples only show the `dispatch_payload` stanzas. Remember that the
|
|
|
|
`dispatch_payload` stanza is only valid in the placements listed above.
|
|
|
|
|
|
|
|
### Write Payload to a File
|
|
|
|
|
|
|
|
This example shows a `dispatch_payload` block in a parameterized job that writes
|
|
|
|
the payload to a `config.json` file.
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
dispatch_payload {
|
|
|
|
file = "config.json"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-03-26 20:21:24 +00:00
|
|
|
[localdir]: /docs/runtime/environment#local 'Task Local Directory'
|
2020-02-06 23:45:31 +00:00
|
|
|
[parameterized]: /docs/job-specification/parameterized 'Nomad parameterized Job Specification'
|