diff --git a/CHANGELOG.md b/CHANGELOG.md index 0022e1a0e..27fe5f0ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ IMPROVEMENTS: * core: Output message when Ctrl-C received that we're cleaning up. [GH-338] * builder/amazon: Tagging now works with all amazon builder types. +* command/build: Machine-readable output now contains build errors, if any. BUG FIXES: diff --git a/command/build/command.go b/command/build/command.go index f6df6309e..69d809927 100644 --- a/command/build/command.go +++ b/command/build/command.go @@ -187,8 +187,10 @@ func (c Command) Run(env packer.Environment, args []string) int { } if len(errors) > 0 { + env.Ui().Machine("error-count", strconv.FormatInt(int64(len(errors)), 10)) env.Ui().Error("\n==> Some builds didn't complete successfully and had errors:") for name, err := range errors { + env.Ui().Machine("error", name, err.Error()) env.Ui().Error(fmt.Sprintf("--> %s: %s", name, err)) } } diff --git a/website/source/docs/machine-readable/command-build.html.markdown b/website/source/docs/machine-readable/command-build.html.markdown index 115133285..6e56ba63d 100644 --- a/website/source/docs/machine-readable/command-build.html.markdown +++ b/website/source/docs/machine-readable/command-build.html.markdown @@ -39,7 +39,9 @@ of `packer build`.
artifact-count (1)

- The number of artifacts associated with the given target. + The number of artifacts associated with the given target. This + will always be outputted _before_ any other artifact information, + so you're able to know how many upcoming artifacts to look for.

@@ -122,4 +124,32 @@ of `packer build`. Data 1: string - The string output for the artifact.

+ +
error-count (1)
+
+

+ The number of errors that occurred during the build. This will + always be outputted before any errors so you know how many are coming. +

+ +

+ Data 1: count - The number of build errors as + a base 10 integer. +

+
+ +
error (2)
+
+

+ A build error that occurred. +

+ +

+ Data 1: name - The name of the build that had an error. +

+ +

+ Data 2: error - The error message as a string. +

+