summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects.py
diff options
context:
space:
mode:
authorJeff Groom <jgroom@ciena.com>2019-07-04 10:13:17 -0600
committerMax Wittig <max.wittig95@gmail.com>2019-07-11 18:53:32 +0200
commitcda117456791977ad300a1dd26dec56009dac55e (patch)
treeb75edec3c039a3c5b06021e95e7693c492d49c29 /gitlab/v4/objects.py
parentad1c0dda37f573673beaf9f25187f51751a5a484 (diff)
downloadgitlab-cda117456791977ad300a1dd26dec56009dac55e.tar.gz
feat: get artifact by ref and job
Diffstat (limited to 'gitlab/v4/objects.py')
-rw-r--r--gitlab/v4/objects.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index f452aa7..c598a9a 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -4263,6 +4263,38 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
)
+ @cli.register_custom_action("Project", ("ref_name", "artifact_path", "job"))
+ @exc.on_http_error(exc.GitlabGetError)
+ def artifact(self, ref_name, artifact_path, job, streamed=False, action=None, chunk_size=1024, **kwargs):
+ """Download a single artifact file from a specific tag or branch from within the job’s artifacts archive.
+
+ Args:
+ ref_name (str): Branch or tag name in repository. HEAD or SHA references are not supported.
+ artifact_path (str): Path to a file inside the artifacts archive.
+ job (str): The name of the job.
+ 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 = "/projects/%s/jobs/artifacts/%s/raw/%s?job=%s" % (self.get_id(), ref_name, artifact_path, job)
+ result = self.manager.gitlab.http_get(
+ path, streamed=streamed, raw=True, **kwargs
+ )
+ return utils.response_content(result, streamed, action, chunk_size)
+
+
class ProjectManager(CRUDMixin, RESTManager):
_path = "/projects"
_obj_cls = Project