@@ -4263,6 +4263,38 @@ def transfer_project(self, to_namespace, **kwargs):
42634263 )
42644264
42654265
4266+ @cli .register_custom_action ("Project" , ("ref_name" , "artifact_path" , "job" ))
4267+ @exc .on_http_error (exc .GitlabGetError )
4268+ def artifact (self , ref_name , artifact_path , job , streamed = False , action = None , chunk_size = 1024 , ** kwargs ):
4269+ """Download a single artifact file from a specific tag or branch from within the job’s artifacts archive.
4270+
4271+ Args:
4272+ ref_name (str): Branch or tag name in repository. HEAD or SHA references are not supported.
4273+ artifact_path (str): Path to a file inside the artifacts archive.
4274+ job (str): The name of the job.
4275+ streamed (bool): If True the data will be processed by chunks of
4276+ `chunk_size` and each chunk is passed to `action` for
4277+ treatment
4278+ action (callable): Callable responsible of dealing with chunk of
4279+ data
4280+ chunk_size (int): Size of each chunk
4281+ **kwargs: Extra options to send to the server (e.g. sudo)
4282+
4283+ Raises:
4284+ GitlabAuthenticationError: If authentication is not correct
4285+ GitlabGetError: If the artifacts could not be retrieved
4286+
4287+ Returns:
4288+ str: The artifacts if `streamed` is False, None otherwise.
4289+ """
4290+
4291+ path = "/projects/%s/jobs/artifacts/%s/raw/%s?job=%s" % (self .get_id (), ref_name , artifact_path , job )
4292+ result = self .manager .gitlab .http_get (
4293+ path , streamed = streamed , raw = True , ** kwargs
4294+ )
4295+ return utils .response_content (result , streamed , action , chunk_size )
4296+
4297+
42664298class ProjectManager (CRUDMixin , RESTManager ):
42674299 _path = "/projects"
42684300 _obj_cls = Project
0 commit comments