File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -166,19 +166,20 @@ def build(self, **kwargs):
166166 if isinstance (resp , six .string_types ):
167167 return self .get (resp )
168168 last_event = None
169+ image_id = None
169170 for chunk in json_stream (resp ):
170171 if 'error' in chunk :
171172 raise BuildError (chunk ['error' ])
172173 if 'stream' in chunk :
173174 match = re .search (
174- r'(Successfully built |sha256:)([0-9a-f]+)' ,
175+ r'(^ Successfully built |sha256:)([0-9a-f]+)$ ' ,
175176 chunk ['stream' ]
176177 )
177178 if match :
178179 image_id = match .group (2 )
179- return self .get (image_id )
180180 last_event = chunk
181-
181+ if image_id :
182+ return self .get (image_id )
182183 raise BuildError (last_event or 'Unknown' )
183184
184185 def get (self , name ):
Original file line number Diff line number Diff line change @@ -39,6 +39,17 @@ def test_build_with_multiple_success(self):
3939 self .tmp_imgs .append (image .id )
4040 assert client .containers .run (image ) == b"hello world\n "
4141
42+ def test_build_with_success_build_output (self ):
43+ client = docker .from_env (version = TEST_API_VERSION )
44+ image = client .images .build (
45+ tag = 'dup-txt-tag' , fileobj = io .BytesIO (
46+ "FROM alpine\n "
47+ "CMD echo Successfully built abcd1234" .encode ('ascii' )
48+ )
49+ )
50+ self .tmp_imgs .append (image .id )
51+ assert client .containers .run (image ) == b"Successfully built abcd1234\n "
52+
4253 def test_list (self ):
4354 client = docker .from_env (version = TEST_API_VERSION )
4455 image = client .images .pull ('alpine:latest' )
You can’t perform that action at this time.
0 commit comments