diff --git a/command/build.go b/command/build.go index 58b548b008f..3caa0b9d842 100644 --- a/command/build.go +++ b/command/build.go @@ -315,6 +315,15 @@ Check that you are using an HCP Ready integration before trying again: artifacts.Unlock() } } + + // If the build succeeded but uploading to HCP failed, + // Packer should exit non-zero, so we re-assign the + // error to account for this case. + if hcperr != nil && err == nil { + errs.Lock() + errs.m[name] = hcperr + errs.Unlock() + } }() if cla.Debug {