From 6d0b5a6957f201875214222e2122709f7ab204a7 Mon Sep 17 00:00:00 2001 From: sylviamoss Date: Thu, 6 Aug 2020 14:40:02 +0200 Subject: [PATCH] skip post-processors when build is cancelled --- packer/build.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packer/build.go b/packer/build.go index ca900797f..201922995 100644 --- a/packer/build.go +++ b/packer/build.go @@ -305,6 +305,13 @@ func (b *CoreBuild) Run(ctx context.Context, originalUi Ui) ([]Artifact, error) errors := make([]error, 0) keepOriginalArtifact := len(b.PostProcessors) == 0 + select { + case <-ctx.Done(): + log.Println("Build was cancelled. Skipping post-processors.") + return nil, nil + default: + } + // Run the post-processors PostProcessorRunSeqLoop: for _, ppSeq := range b.PostProcessors {