command/build: put build errors in machine readable output

This commit is contained in:
Mitchell Hashimoto 2013-08-27 13:37:31 -07:00
parent 87dde46413
commit 84d91c5f1a
3 changed files with 34 additions and 1 deletions

View File

@ -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:

View File

@ -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))
}
}

View File

@ -39,7 +39,9 @@ of `packer build`.
<dt>artifact-count (1)</dt>
<dd>
<p>
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.
</p>
<p>
@ -122,4 +124,32 @@ of `packer build`.
<strong>Data 1: string</strong> - The string output for the artifact.
</p>
</dd>
<dt>error-count (1)</dt>
<dd>
<p>
The number of errors that occurred during the build. This will
always be outputted before any errors so you know how many are coming.
</p>
<p>
<strong>Data 1: count</strong> - The number of build errors as
a base 10 integer.
</p>
</dd>
<dt>error (2)</dt>
<dd>
<p>
A build error that occurred.
</p>
<p>
<strong>Data 1: name</strong> - The name of the build that had an error.
</p>
<p>
<strong>Data 2: error</strong> - The error message as a string.
</p>
</dd>
</dl>