Skip to content

Commit 431f7c6

Browse files
committed
Improve build result detection
Signed-off-by: Joffrey F <[email protected]>
1 parent e19aad8 commit 431f7c6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

docker/models/images.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,21 @@ def build(self, **kwargs):
166166
resp = self.client.api.build(**kwargs)
167167
if isinstance(resp, six.string_types):
168168
return self.get(resp)
169+
last_event = None
169170
for chunk in json_stream(resp):
170171
if 'error' in chunk:
171172
raise BuildError(chunk['error'])
172-
break
173173
if 'stream' in chunk:
174-
match = re.search(r'(Successfully built |sha256:)([0-9a-f]+)',
175-
chunk['stream'])
174+
match = re.search(
175+
r'(Successfully built |sha256:)([0-9a-f]+)',
176+
chunk['stream']
177+
)
176178
if match:
177179
image_id = match.group(2)
178180
return self.get(image_id)
181+
last_event = chunk
179182

180-
return BuildError('Unknown')
183+
raise BuildError(last_event or 'Unknown')
181184

182185
def get(self, name):
183186
"""

0 commit comments

Comments
 (0)