diff options
| author | Gauvain Pocentek <gauvain@pocentek.net> | 2018-02-05 15:05:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-05 15:05:35 +0100 |
| commit | 6ea7ab73eb6be20c4e8c092044bf0efe421ce4f5 (patch) | |
| tree | 315bd4ae6a7ad73f0f07595d31a6e72d6d8dd052 /docs | |
| parent | f276f13df50132554984f989b1d3d6c5fa8cdc01 (diff) | |
| parent | faeb1c140637ce25209e5553cab6a488c363a912 (diff) | |
| download | gitlab-6ea7ab73eb6be20c4e8c092044bf0efe421ce4f5.tar.gz | |
Merge pull request #419 from tardyp/patch-1
Simplify the example for streamed artifacts
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/gl_objects/builds.py | 12 | ||||
| -rw-r--r-- | docs/gl_objects/builds.rst | 10 |
2 files changed, 18 insertions, 4 deletions
diff --git a/docs/gl_objects/builds.py b/docs/gl_objects/builds.py index a5d2005..0f616e8 100644 --- a/docs/gl_objects/builds.py +++ b/docs/gl_objects/builds.py @@ -72,7 +72,7 @@ project.jobs.get(job_id) # v4 build_or_job.artifacts() # end artifacts -# stream artifacts +# stream artifacts with class class Foo(object): def __init__(self): self._fd = open('artifacts.zip', 'wb') @@ -83,7 +83,15 @@ class Foo(object): target = Foo() build_or_job.artifacts(streamed=True, action=target) del(target) # flushes data on disk -# end stream artifacts +# end stream artifacts with class + +# stream artifacts with unzip +zipfn = "___artifacts.zip" +with open(zipfn, "wb") as f: + build_or_job.artifacts(streamed=True, action=f.write) +subprocess.run(["unzip", "-bo", zipfn]) +os.unlink(zipfn) +# end stream artifacts with unzip # keep artifacts build_or_job.keep_artifacts() diff --git a/docs/gl_objects/builds.rst b/docs/gl_objects/builds.rst index b0f3e22..9d68736 100644 --- a/docs/gl_objects/builds.rst +++ b/docs/gl_objects/builds.rst @@ -201,8 +201,14 @@ You can download artifacts as a stream. Provide a callable to handle the stream: .. literalinclude:: builds.py - :start-after: # stream artifacts - :end-before: # end stream artifacts + :start-after: # stream artifacts with class + :end-before: # end stream artifacts with class + +In this second example, you can directly stream the output into a file, and unzip it afterwards: + +.. literalinclude:: builds.py + :start-after: # stream artifacts with unzip + :end-before: # end stream artifacts with unzip Mark a job artifact as kept when expiration is set: |
