@@ -246,9 +246,9 @@ def build(self, stream=False, timestamp=False, **kwargs):
246
246
custom_context (bool): Optional if using ``fileobj``
247
247
encoding (str): The encoding for a stream. Set to ``gzip`` for
248
248
compressing
249
- stream (bool): Print the build output to stdout and stderr while
249
+ stream (bool): Print the build output to stdout and stderr while
250
250
the build runs
251
- timestamp (bool): Prefix build output stream with a timestamp
251
+ timestamp (bool): Prefix build output stream with a timestamp
252
252
"%Y-%m-%d %H:%M:%S"
253
253
pull (bool): Downloads any updates to the FROM image in Dockerfiles
254
254
forcerm (bool): Always remove intermediate containers, even after
@@ -309,16 +309,18 @@ def build(self, stream=False, timestamp=False, **kwargs):
309
309
timestamp_str = datetime .datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" )
310
310
if 'error' in chunk :
311
311
if stream :
312
- if timestamp :
313
- print (timestamp_str , "- " , end = '' , file = sys .stderr )
314
- print ("Error:" , chunk ['error' ].strip (), flush = True , file = sys .stderr )
312
+ if len (chunk ['error' ].strip ()) > 0 :
313
+ if timestamp :
314
+ print (timestamp_str , "- " , end = '' , file = sys .stderr )
315
+ print ("Error:" , chunk ['error' ].strip (), flush = True , file = sys .stderr )
315
316
raise BuildError (chunk ['error' ], result_stream )
316
317
if 'stream' in chunk :
317
318
if stream :
318
319
for line in chunk ["stream" ].splitlines ():
319
- if timestamp :
320
- print (timestamp_str , "- " , end = '' )
321
- print (line .strip (), flush = True )
320
+ if len (line .strip ()) > 0 :
321
+ if timestamp :
322
+ print (timestamp_str , "- " , end = '' )
323
+ print (line .strip (), flush = True )
322
324
match = re .search (
323
325
r'(^Successfully built |sha256:)([0-9a-f]+)$' ,
324
326
chunk ['stream' ]
0 commit comments