summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2018-03-17 07:15:35 +0100
committerGauvain Pocentek <gauvain@pocentek.net>2018-03-17 07:15:35 +0100
commit9080f69d6c9242c1131ca7ff84489f2bb26bc867 (patch)
treee4077228e81683d7df2dba95a535385661bbdb61 /gitlab
parent9cb6bbedd350a2241113fe1d731b4cfe56c19d4f (diff)
downloadgitlab-9080f69d6c9242c1131ca7ff84489f2bb26bc867.tar.gz
Support downloading a single artifact file
Fixes #432
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/v4/objects.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 4ca9dea..e1763a5 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -1014,6 +1014,34 @@ class ProjectJob(RESTObject, RefreshMixin):
@cli.register_custom_action('ProjectJob')
@exc.on_http_error(exc.GitlabGetError)
+ def artifact(self, path, streamed=False, action=None, chunk_size=1024,
+ **kwargs):
+ """Get a single artifact file from within the job's artifacts archive.
+
+ Args:
+ path (str): Path of the artifact
+ streamed (bool): If True the data will be processed by chunks of
+ `chunk_size` and each chunk is passed to `action` for
+ treatment
+ action (callable): Callable responsible of dealing with chunk of
+ data
+ chunk_size (int): Size of each chunk
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabGetError: If the artifacts could not be retrieved
+
+ Returns:
+ str: The artifacts if `streamed` is False, None otherwise.
+ """
+ path = '%s/%s/artifacts/%s' % (self.manager.path, self.get_id(), path)
+ result = self.manager.gitlab.http_get(path, streamed=streamed,
+ **kwargs)
+ return utils.response_content(result, streamed, action, chunk_size)
+
+ @cli.register_custom_action('ProjectJob')
+ @exc.on_http_error(exc.GitlabGetError)
def trace(self, streamed=False, action=None, chunk_size=1024, **kwargs):
"""Get the job trace.