github.com/ncodes/nomad@v0.5.7-0.20170403112158-97adf4a74fb3/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.
    41  
    42  ## `env` Examples
    43  
    44  The following examples only show the `env` stanzas. Remember that the
    45  `env` stanza is only valid in the placements listed above.
    46  
    47  ### Coercion
    48  
    49  This example shows the different ways to specify key-value pairs. Internally,
    50  these values will be stored as their string representation. No type information
    51  is preserved.
    52  
    53  ```hcl
    54  env {
    55    key = "true"
    56    key = true
    57  
    58    "key" = true
    59  
    60    key = 1.4
    61    key = "1.4"
    62  }
    63  ```
    64  
    65  ### Interpolation
    66  
    67  This example shows using [Nomad interpolation][interpolation] to populate
    68  environment variables.
    69  
    70  ```hcl
    71  env {
    72    NODE_CLASS = "${nomad.class}"
    73  }
    74  ```
    75  
    76  [interpolation]: /docs/runtime/interpolation.html "Nomad interpolation"