Skip to content

Commit 4d8c436

Browse files
authored
If BuildImage fails but logs something about success, don't succeed (#2305)
This patch ensures that if the docker build commands result in logging the string "Successfully built", the callback from that build will still fail if there was an error in building. Fixes #2184
1 parent 129f786 commit 4d8c436

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docker-java-api/src/main/java/com/github/dockerjava/api/command/BuildImageResultCallback.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ public String awaitImageId(long timeout, TimeUnit timeUnit) {
6767
}
6868

6969
private String getImageId() {
70-
if (imageId != null) {
71-
return imageId;
70+
if (error != null) {
71+
throw new DockerClientException("Could not build image: " + error);
7272
}
7373

74-
if (error == null) {
75-
throw new DockerClientException("Could not build image");
74+
if (imageId != null) {
75+
return imageId;
7676
}
7777

78-
throw new DockerClientException("Could not build image: " + error);
78+
throw new DockerClientException("Could not build image");
7979
}
8080
}

0 commit comments

Comments
 (0)