github.com/maier/nomad@v0.4.1-0.20161110003312-a9e3d0b8549d/website/source/docs/job-specification/artifact.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "artifact Stanza - Job Specification"
     4  sidebar_current: "docs-job-specification-artifact"
     5  description: |-
     6    The "artifact" stanza instructs Nomad to fetch and unpack a remote resource,
     7    such as a file, tarball, or binary, and permits downloading artifacts from a
     8    variety of locations using a URL as the input source.
     9  ---
    10  
    11  # `artifact` Stanza
    12  
    13  <table class="table table-bordered table-striped">
    14    <tr>
    15      <th width="120">Placement</th>
    16      <td>
    17        <code>job -> group -> task -> **artifact**</code>
    18      </td>
    19    </tr>
    20  </table>
    21  
    22  The `artifact` stanza instructs Nomad to fetch and unpack a remote resource,
    23  such as a file, tarball, or binary. Nomad downloads artifacts using the popular
    24  [`go-getter`][go-getter] library, which permits downloading artifacts from a
    25  variety of locations using a URL as the input source.
    26  
    27  ```hcl
    28  job "docs" {
    29    group "example" {
    30      task "server" {
    31        artifact {
    32          source      = "https://example.com/file.tar.gz"
    33          destination = "/tmp/file"
    34          options {
    35            checksum = "md5:df6a4178aec9fbdc1d6d7e3634d1bc33"
    36          }
    37        }
    38      }
    39    }
    40  }
    41  ```
    42  
    43  Nomad supports downloading `http`, `https`, and `S3` artifacts. If these
    44  artifacts are archived (`zip`, `tgz`, `bz2`), they are automatically unarchived
    45  before the starting the task.
    46  
    47  ## `artifact` Parameters
    48  
    49  - `destination` `(string: "local/$1")` - Specifies the path to download the
    50    artifact, relative to the root of the task's directory. If omitted, the
    51    default value is to place the binary in `local/`.
    52  
    53  - `source` `(string: <required>)` - Specifies the URL of the artifact to download.
    54   The can be any URL as defined by the [`go-getter`][go-getter] library.
    55  
    56  - `options` `(map<string|string>: nil)` - Specifies configuration parameters to
    57    fetch the artifact. The key-value pairs map directly to parameters appended to
    58    the supplied `source` URL. Please see the [`go-getter`
    59    documentation][go-getter] for a complete list of options and examples
    60  
    61  ## `artifact` Examples
    62  
    63  The following examples only show the `artifact` stanzas. Remember that the
    64  `artifact` stanza is only valid in the placements listed above.
    65  
    66  ### Download File
    67  
    68  This example downloads the artifact from the provided URL and places it in
    69  `local/file.txt`. The `local/` path is relative to the task's directory.
    70  
    71  ```hcl
    72  artifact {
    73    source = "https://example.com/file.txt"
    74  }
    75  ```
    76  
    77  ### Download with Custom Destination
    78  
    79  This example downloads the artifact from the provided URL and places it at
    80  `/tmp/example.txt`, as specified by the optional `destination` parameter.
    81  
    82  ```hcl
    83  artifact {
    84    source      = "https://example.com/file.txt"
    85    destination = "/tmp/example.txt"
    86  }
    87  ```
    88  
    89  ### Download and Unarchive
    90  
    91  This example downloads and unarchives the result in `local/file`. Because the
    92  source URL is an archive extension, Nomad will automatically decompress it:
    93  
    94  ```hcl
    95  artifact {
    96    source = "https://example.com/file.tar.gz"
    97  }
    98  ```
    99  
   100  To disable automatic unarchiving, set the `archive` option to false:
   101  
   102  ```hcl
   103  artifact {
   104    source = "https://example.com/file.tar.gz"
   105    options {
   106      archive = false
   107    }
   108  }
   109  ```
   110  
   111  ### Download and Verify Checksums
   112  
   113  This example downloads an artifact and verifies the resulting artifact's
   114  checksum before proceeding. If the checksum is invalid, an error will be
   115  returned.
   116  
   117  ```hcl
   118  artifact {
   119    source = "https://example.com/file.zip"
   120  
   121    options {
   122      checksum = "md5:df6a4178aec9fbdc1d6d7e3634d1bc33"
   123    }
   124  }
   125  ```
   126  
   127  ### Download from an S3 Bucket
   128  
   129  These examples download artifacts from Amazon S3. There are several different
   130  types of [S3 bucket addressing][s3-bucket-addr] and [S3 region-specific
   131  endpoints][s3-region-endpoints].
   132  
   133  This example uses path-based notation on a publicly-accessible bucket:
   134  
   135  ```hcl
   136  artifact {
   137    source = "https://s3-us-west-2.amazonaws.com/my-bucket-example/my_app.tar.gz"
   138  }
   139  ```
   140  
   141  If a bucket requires authentication, it may be supplied via the `options`
   142  parameter:
   143  
   144  ```hcl
   145  artifact {
   146    options {
   147      aws_access_key_id     = "<id>"
   148      aws_access_key_secret = "<secret>"
   149      aws_access_token      = "<token>"
   150    }
   151  }
   152  ```
   153  
   154  To force the S3-specific syntax, use the `s3::` prefix:
   155  
   156  ```hcl
   157  artifact {
   158    source = "s3::https://s3-eu-west-1.amazonaws.com/my-bucket-example/my_app.tar.gz"
   159  }
   160  ```
   161  
   162  Alternatively you can use virtual hosted style:
   163  
   164  ```hcl
   165  artifact {
   166    source = "https://my-bucket-example.s3-eu-west-1.amazonaws.com/my_app.tar.gz"
   167  }
   168  ```
   169  
   170  [go-getter]: https://github.com/hashicorp/go-getter "HashiCorp go-getter Library"
   171  [s3-bucket-addr]: http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro "Amazon S3 Bucket Addressing"
   172  [s3-region-endpoints]: http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region "Amazon S3 Region Endpoints"