core: CoreBuild.Run error on cancelled builds

When a build is cancelled by a user, the current implementation of
CoreBuild.Run does not return an error signifying that there was a
problem with the build.

This in turn causes the HCP code to attempt to update the status of the
build to DONE, but fails because there are no artifacts to push.

This commit changes this behaviour by returning the error provoked by
the cancellation to the caller, so it can be taken into account when
setting the status of the build.
pull/12185/head
Lucas Bajolet 3 years ago committed by Lucas Bajolet
parent ea1d32e456
commit f8bc240b02

@ -238,7 +238,7 @@ func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]packers
select {
case <-ctx.Done():
log.Println("Build was cancelled. Skipping post-processors.")
return nil, nil
return nil, ctx.Err()
default:
}

Loading…
Cancel
Save