add jq example for basic manifest parsing (#8677)

fix #5413
This commit is contained in:
Megan Marsh 2020-01-31 07:43:52 -08:00 committed by GitHub
parent 69fe131571
commit 3b5780f98c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 2 deletions

View File

@ -38,8 +38,9 @@ post-processors such as Docker and Artifice.
to `packer-manifest.json`.
- `strip_path` (boolean) Write only filename without the path to the manifest
file. This defaults to false.
- `custom_data` (map of strings) Arbitrary data to add to the manifest.
- `custom_data` (map of strings) Arbitrary data to add to the manifest. This
is a [template engine](/docs/templates/engine.html); see
[Build template data](#build-template-data) for more information.
- `keep_input_artifact` (boolean) - Unlike most other post-processors, the
keep_input_artifact option will have no effect for the manifest
post-processor. We will always retain the input artifact for manifest,
@ -136,3 +137,20 @@ The above manifest was generated with this packer.json:
]
}
```
Example usage:
The manifest can be very useful for cleaning up old artifacts, or printing
important values to logs. The following example uses jq, a command-line tool for
parsing json output, to find and echo the AWS ami-id of an ami created by a
build.
``` bash
#!/bin/bash
AMI_ID=$(jq -r '.builds[-1].artifact_id' manifest.json | cut -d ":" -f2)
echo $AMI_ID
```