github.com/smintz/nomad@v0.8.3/website/source/docs/job-specification/env.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "env Stanza - Job Specification" 4 sidebar_current: "docs-job-specification-env" 5 description: |- 6 The "env" stanza configures a list of environment variables to populate the 7 task's environment before starting. 8 --- 9 10 # `env` Stanza 11 12 <table class="table table-bordered table-striped"> 13 <tr> 14 <th width="120">Placement</th> 15 <td> 16 <code>job -> group -> task -> **env**</code> 17 </td> 18 </tr> 19 </table> 20 21 The `env` stanza configures a list of environment variables to populate the 22 task's environment before starting. 23 24 ```hcl 25 job "docs" { 26 group "example" { 27 task "server" { 28 env { 29 my_key = "my-value" 30 } 31 } 32 } 33 } 34 ``` 35 36 ## `env` Parameters 37 38 The "parameters" for the `env` stanza can be any key-value. The keys and values 39 are both of type `string`, but they can be specified as other types. They will 40 automatically be converted to strings. Invalid characters such as dashes (`-`) 41 will be converted to underscores. 42 43 ## `env` Examples 44 45 The following examples only show the `env` stanzas. Remember that the 46 `env` stanza is only valid in the placements listed above. 47 48 ### Coercion 49 50 This example shows the different ways to specify key-value pairs. Internally, 51 these values will be stored as their string representation. No type information 52 is preserved. 53 54 ```hcl 55 env { 56 key = "true" 57 key = true 58 59 "key" = true 60 61 key = 1.4 62 key = "1.4" 63 } 64 ``` 65 66 ### Interpolation 67 68 This example shows using [Nomad interpolation][interpolation] to populate 69 environment variables. 70 71 ```hcl 72 env { 73 NODE_CLASS = "${nomad.class}" 74 } 75 ``` 76 77 ### Dynamic Environment Variables 78 79 Nomad also supports populating dynamic environment variables from data stored in 80 HashiCorp Consul and Vault. To use this feature please see the documentation on 81 the [`template` stanza][template-env]. 82 83 [interpolation]: /docs/runtime/interpolation.html "Nomad interpolation" 84 [template-env]: /docs/job-specification/template.html#environment-variables "Nomad template Stanza"