File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 7272build_or_job .artifacts ()
7373# end artifacts
7474
75- # stream artifacts
75+ # stream artifacts with class
7676class Foo (object ):
7777 def __init__ (self ):
7878 self ._fd = open ('artifacts.zip' , 'wb' )
@@ -83,7 +83,15 @@ def __call__(self, chunk):
8383target = Foo ()
8484build_or_job .artifacts (streamed = True , action = target )
8585del (target ) # flushes data on disk
86- # end stream artifacts
86+ # end stream artifacts with class
87+
88+ # stream artifacts with unzip
89+ zipfn = "___artifacts.zip"
90+ with open (zipfn , "wb" ) as f :
91+ build_or_job .artifacts (streamed = True , action = f .write )
92+ subprocess .run (["unzip" , "-bo" , zipfn ])
93+ os .unlink (zipfn )
94+ # end stream artifacts with unzip
8795
8896# keep artifacts
8997build_or_job .keep_artifacts ()
Original file line number Diff line number Diff line change @@ -201,8 +201,14 @@ You can download artifacts as a stream. Provide a callable to handle the
201201stream:
202202
203203.. literalinclude :: builds.py
204- :start-after: # stream artifacts
205- :end-before: # end stream artifacts
204+ :start-after: # stream artifacts with class
205+ :end-before: # end stream artifacts with class
206+
207+ In this second example, you can directly stream the output into a file, and unzip it afterwards:
208+
209+ .. literalinclude :: builds.py
210+ :start-after: # stream artifacts with unzip
211+ :end-before: # end stream artifacts with unzip
206212
207213Mark a job artifact as kept when expiration is set:
208214
You can’t perform that action at this time.
0 commit comments