packer-cn/website/content/docs/post-processors/checksum.mdx

82 lines
2.4 KiB
Plaintext
Raw Normal View History

2020-03-18 18:46:47 -04:00
---
description: >
The checksum post-processor computes specified checksum for the artifact list
2020-12-04 16:02:29 -05:00
from an upstream builder or post-processor. All downstream post-processors
will see the new artifacts. The primary use-case is compute checksum for
artifacts allows to verify it later. So firstly this post-processor get
artifact, compute it checksum and pass to next post-processor original
artifacts and checksum files.
2020-03-18 18:46:47 -04:00
page_title: Checksum - Post-Processors
sidebar_title: Checksum
2020-03-18 18:46:47 -04:00
---
# Checksum Post-Processor
Type: `checksum`
The checksum post-processor computes specified checksum for the artifact list
from an upstream builder or post-processor. All downstream post-processors will
see the new artifacts. The primary use-case is compute checksum for artifact to
verify it later.
After computes checksum for artifacts, you can use new artifacts with other
post-processors like
2020-03-31 17:40:07 -04:00
[artifice](/docs/post-processors/artifice),
[compress](/docs/post-processors/compress),
[docker-push](/docs/post-processors/docker-push), or
2020-03-18 18:46:47 -04:00
a third-party post-processor.
## Basic example
2020-08-05 13:41:58 -04:00
<Tabs>
<Tab heading="JSON">
2020-03-18 18:46:47 -04:00
```json
{
2020-08-05 13:41:58 -04:00
"type": "checksum",
"checksum_types": ["sha1", "sha256"],
"output": "packer_{{.BuildName}}_{{.ChecksumType}}.checksum"
2020-03-18 18:46:47 -04:00
}
```
2020-08-05 13:41:58 -04:00
</Tab>
<Tab heading="HCL2">
```hcl
2020-12-21 11:01:39 -05:00
post-processors "checksum" {
2020-08-05 13:41:58 -04:00
checksum_types = ["sha1", "sha256"]
output = "packer_{{.BuildName}}_{{.ChecksumType}}.checksum"
}
```
</Tab>
</Tabs>
2020-03-18 18:46:47 -04:00
## Configuration Reference
Optional parameters:
- `checksum_types` (array of strings) - An array of strings of checksum types
2020-08-05 13:41:58 -04:00
to compute. If empty, Defaults to md5. Allowed values are:
2020-12-04 16:00:53 -05:00
- md5
- sha1
- sha224
- sha256
- sha384
- sha512
2020-03-18 18:46:47 -04:00
- `output` (string) - Specify filename to store checksums. This defaults to
`packer_{{.BuildName}}_{{.BuilderType}}_{{.ChecksumType}}.checksum`. For
example, if you had a builder named `database`, you might see the file
written as `packer_database_docker_md5.checksum`. This is treated as a
2020-03-31 17:40:07 -04:00
[template engine](/docs/templates/engine). Therefore, you
2020-03-18 18:46:47 -04:00
may use user variables and template functions in this field.
The following special variables are also available to use in the output
template:
- `BuildName`: The name of the builder that produced the artifact.
- `BuilderType`: The type of builder used to produce the artifact.
- `ChecksumType`: The type of checksums the file contains. This should be
used if you have more than one value in `checksum_types`.