@@ -1012,6 +1012,34 @@ def artifacts(self, streamed=False, action=None, chunk_size=1024,
1012
1012
** kwargs )
1013
1013
return utils .response_content (result , streamed , action , chunk_size )
1014
1014
1015
+ @cli .register_custom_action ('ProjectJob' )
1016
+ @exc .on_http_error (exc .GitlabGetError )
1017
+ def artifact (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
+ return utils .response_content (result , streamed , action , chunk_size )
1042
+
1015
1043
@cli .register_custom_action ('ProjectJob' )
1016
1044
@exc .on_http_error (exc .GitlabGetError )
1017
1045
def trace (self , streamed = False , action = None , chunk_size = 1024 , ** kwargs ):
0 commit comments