Repository: python-gitlab/python-gitlab

Issue:
Get artifacts files
It seems library is not able to download artifacts (by [/projects/:id/builds/:build_id/artifacts](http://docs.gitlab.com/ce/api/builds.html#get-build-artifacts)), only list them:

```
>>> import gitlab
>>> GITLAB_SERVER = 'https://gitlab.com'
>>> 
>>> gl = gitlab.Gitlab(GITLAB_SERVER, 'xxx')
>>> project = gl.projects.get(123)
>>> build = project.builds.get(12345)               
>>> build.artifacts_file
{'filename': 'artifacts.zip', 'size': 2420515}
```



Discussion:

Resolving patch:
diff --git a/gitlab/cli.py b/gitlab/cli.py
--- a/gitlab/cli.py
+++ b/gitlab/cli.py
@@ -36,7 +36,9 @@
     gitlab.ProjectBranch: {'protect': {'required': ['id', 'project-id']},
                            'unprotect': {'required': ['id', 'project-id']}},
     gitlab.ProjectBuild: {'cancel': {'required': ['id', 'project-id']},
-                          'retry': {'required': ['id', 'project-id']}},
+                          'retry': {'required': ['id', 'project-id']},
+                          'artifacts': {'required': ['id', 'project-id']},
+                          'trace': {'required': ['id', 'project-id']}},
     gitlab.ProjectCommit: {'diff': {'required': ['id', 'project-id']},
                            'blob': {'required': ['id', 'project-id',
                                                  'filepath']},
@@ -250,6 +252,20 @@ def do_project_build_retry(self, cls, gl, what, args):
         except Exception as e:
             _die("Impossible to retry project build (%s)" % str(e))
 
+    def do_project_build_artifacts(self, cls, gl, what, args):
+        try:
+            o = self.do_get(cls, gl, what, args)
+            return o.artifacts()
+        except Exception as e:
+            _die("Impossible to get project build artifacts (%s)" % str(e))
+
+    def do_project_build_trace(self, cls, gl, what, args):
+        try:
+            o = self.do_get(cls, gl, what, args)
+            return o.trace()
+        except Exception as e:
+            _die("Impossible to get project build trace (%s)" % str(e))
+
     def do_project_issue_subscribe(self, cls, gl, what, args):
         try:
             o = self.do_get(cls, gl, what, args)
diff --git a/gitlab/objects.py b/gitlab/objects.py
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -806,18 +806,48 @@ class ProjectBuild(GitlabObject):
     canUpdate = False
     canCreate = False
 
-    def cancel(self):
+    def cancel(self, **kwargs):
         """Cancel the build."""
         url = '/projects/%s/builds/%s/cancel' % (self.project_id, self.id)
         r = self.gitlab._raw_post(url)
         raise_error_from_response(r, GitlabBuildCancelError, 201)
 
-    def retry(self):
+    def retry(self, **kwargs):
         """Retry the build."""
         url = '/projects/%s/builds/%s/retry' % (self.project_id, self.id)
         r = self.gitlab._raw_post(url)
         raise_error_from_response(r, GitlabBuildRetryError, 201)
 
+    def artifacts(self, **kwargs):
+        """Get the build artifacts.
+
+        Returns:
+            str: The artifacts.
+
+        Raises:
+            GitlabConnectionError: If the server cannot be reached.
+            GitlabGetError: If the artifacts are not available.
+        """
+        url = '/projects/%s/builds/%s/artifacts' % (self.project_id, self.id)
+        r = self.gitlab._raw_get(url)
+        raise_error_from_response(r, GitlabGetError, 200)
+        return r.content
+
+    def trace(self, **kwargs):
+        """Get the build trace.
+
+        Returns:
+            str: The trace.
+
+        Raises:
+            GitlabConnectionError: If the server cannot be reached.
+            GitlabGetError: If the trace is not available.
+        """
+        url = '/projects/%s/builds/%s/trace' % (self.project_id, self.id)
+        r = self.gitlab._raw_get(url)
+        raise_error_from_response(r, GitlabGetError, 200)
+        return r.content
+
 
 class ProjectBuildManager(BaseManager):
     obj_cls = ProjectBuild


Test patch: