From f0cd23bcf17bb5bc28ba76be2c39c925981ec9cf Mon Sep 17 00:00:00 2001 From: William Rose Date: Tue, 9 Apr 2019 00:07:53 -0400 Subject: [PATCH] Issue #1185 Prevent docker:save failing when no images are defined. Signed-off-by: William Rose --- src/main/java/io/fabric8/maven/docker/SaveMojo.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/io/fabric8/maven/docker/SaveMojo.java b/src/main/java/io/fabric8/maven/docker/SaveMojo.java index 7a89c2b2e..2263d66fa 100644 --- a/src/main/java/io/fabric8/maven/docker/SaveMojo.java +++ b/src/main/java/io/fabric8/maven/docker/SaveMojo.java @@ -44,6 +44,9 @@ protected void executeInternal(ServiceHub serviceHub) throws DockerAccessExcepti return; } String imageName = getImageName(); + if(imageName == null) { + return; + } String fileName = getFileName(imageName); ensureSaveDir(fileName); log.info("Saving image %s to %s", imageName, fileName); @@ -101,6 +104,10 @@ private String getImageName() throws MojoExecutionException { // specify image by name or alias if (saveName == null && saveAlias == null) { List buildImages = getImagesWithBuildConfig(images); + if (buildImages.isEmpty()) { + log.info("No images have a build configuration defined: save skipped"); + return null; + } if (buildImages.size() == 1) { return buildImages.get(0).getName(); }