Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9080f69

Browse files
author
Gauvain Pocentek
committed
Support downloading a single artifact file
Fixes#432
1 parent9cb6bbe commit9080f69

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

‎docs/gl_objects/builds.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ Get a job:
297297
:start-after: # get job
298298
:end-before: # end get job
299299

300-
Get a job artifact:
300+
Getthe artifacts ofa job:
301301

302302
..literalinclude::builds.py
303303
:start-after: # artifacts
@@ -316,12 +316,17 @@ stream:
316316
:start-after: # stream artifacts with class
317317
:end-before: # end stream artifacts with class
318318

319-
In this second example, you can directly stream the output into a file, and unzip it afterwards:
319+
In this second example, you can directly stream the output into a file, and
320+
unzip it afterwards:
320321

321322
..literalinclude::builds.py
322323
:start-after: # stream artifacts with unzip
323324
:end-before: # end stream artifacts with unzip
324325

326+
Get a single artifact file::
327+
328+
build_or_job.artifact('path/to/file')
329+
325330
Mark a job artifact as kept when expiration is set:
326331

327332
..literalinclude::builds.py

‎gitlab/v4/objects.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,34 @@ def artifacts(self, streamed=False, action=None, chunk_size=1024,
10121012
**kwargs)
10131013
returnutils.response_content(result,streamed,action,chunk_size)
10141014

1015+
@cli.register_custom_action('ProjectJob')
1016+
@exc.on_http_error(exc.GitlabGetError)
1017+
defartifact(self,path,streamed=False,action=None,chunk_size=1024,
1018+
**kwargs):
1019+
"""Get a single artifact file from within the job's artifacts archive.
1020+
1021+
Args:
1022+
path (str): Path of the artifact
1023+
streamed (bool): If True the data will be processed by chunks of
1024+
`chunk_size` and each chunk is passed to `action` for
1025+
treatment
1026+
action (callable): Callable responsible of dealing with chunk of
1027+
data
1028+
chunk_size (int): Size of each chunk
1029+
**kwargs: Extra options to send to the server (e.g. sudo)
1030+
1031+
Raises:
1032+
GitlabAuthenticationError: If authentication is not correct
1033+
GitlabGetError: If the artifacts could not be retrieved
1034+
1035+
Returns:
1036+
str: The artifacts if `streamed` is False, None otherwise.
1037+
"""
1038+
path='%s/%s/artifacts/%s'% (self.manager.path,self.get_id(),path)
1039+
result=self.manager.gitlab.http_get(path,streamed=streamed,
1040+
**kwargs)
1041+
returnutils.response_content(result,streamed,action,chunk_size)
1042+
10151043
@cli.register_custom_action('ProjectJob')
10161044
@exc.on_http_error(exc.GitlabGetError)
10171045
deftrace(self,streamed=False,action=None,chunk_size=1024,**kwargs):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp