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