Skip to content

Commit 2e0ac3f

Browse files
author
Gauvain Pocentek
committed
Merge branch 'master' of github.com:gpocentek/python-gitlab
2 parents c85276a + 80a1908 commit 2e0ac3f

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

gitlab/cli.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
gitlab.ProjectBranch: {'protect': {'required': ['id', 'project-id']},
3737
'unprotect': {'required': ['id', 'project-id']}},
3838
gitlab.ProjectBuild: {'cancel': {'required': ['id', 'project-id']},
39-
'retry': {'required': ['id', 'project-id']}},
39+
'retry': {'required': ['id', 'project-id']},
40+
'artifacts': {'required': ['id', 'project-id']},
41+
'trace': {'required': ['id', 'project-id']}},
4042
gitlab.ProjectCommit: {'diff': {'required': ['id', 'project-id']},
4143
'blob': {'required': ['id', 'project-id',
4244
'filepath']},
@@ -250,6 +252,20 @@ def do_project_build_retry(self, cls, gl, what, args):
250252
except Exception as e:
251253
_die("Impossible to retry project build (%s)" % str(e))
252254

255+
def do_project_build_artifacts(self, cls, gl, what, args):
256+
try:
257+
o = self.do_get(cls, gl, what, args)
258+
return o.artifacts()
259+
except Exception as e:
260+
_die("Impossible to get project build artifacts (%s)" % str(e))
261+
262+
def do_project_build_trace(self, cls, gl, what, args):
263+
try:
264+
o = self.do_get(cls, gl, what, args)
265+
return o.trace()
266+
except Exception as e:
267+
_die("Impossible to get project build trace (%s)" % str(e))
268+
253269
def do_project_issue_subscribe(self, cls, gl, what, args):
254270
try:
255271
o = self.do_get(cls, gl, what, args)

gitlab/objects.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,18 +822,48 @@ class ProjectBuild(GitlabObject):
822822
canUpdate = False
823823
canCreate = False
824824

825-
def cancel(self):
825+
def cancel(self, **kwargs):
826826
"""Cancel the build."""
827827
url = '/projects/%s/builds/%s/cancel' % (self.project_id, self.id)
828828
r = self.gitlab._raw_post(url)
829829
raise_error_from_response(r, GitlabBuildCancelError, 201)
830830

831-
def retry(self):
831+
def retry(self, **kwargs):
832832
"""Retry the build."""
833833
url = '/projects/%s/builds/%s/retry' % (self.project_id, self.id)
834834
r = self.gitlab._raw_post(url)
835835
raise_error_from_response(r, GitlabBuildRetryError, 201)
836836

837+
def artifacts(self, **kwargs):
838+
"""Get the build artifacts.
839+
840+
Returns:
841+
str: The artifacts.
842+
843+
Raises:
844+
GitlabConnectionError: If the server cannot be reached.
845+
GitlabGetError: If the artifacts are not available.
846+
"""
847+
url = '/projects/%s/builds/%s/artifacts' % (self.project_id, self.id)
848+
r = self.gitlab._raw_get(url)
849+
raise_error_from_response(r, GitlabGetError, 200)
850+
return r.content
851+
852+
def trace(self, **kwargs):
853+
"""Get the build trace.
854+
855+
Returns:
856+
str: The trace.
857+
858+
Raises:
859+
GitlabConnectionError: If the server cannot be reached.
860+
GitlabGetError: If the trace is not available.
861+
"""
862+
url = '/projects/%s/builds/%s/trace' % (self.project_id, self.id)
863+
r = self.gitlab._raw_get(url)
864+
raise_error_from_response(r, GitlabGetError, 200)
865+
return r.content
866+
837867

838868
class ProjectBuildManager(BaseManager):
839869
obj_cls = ProjectBuild

0 commit comments

Comments
 (0)