From b3e0974451b49ab64866dc131bff59e5471ea620 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Tue, 7 Jun 2016 21:39:15 +0200 Subject: Add support for build artifacts and trace Fixes #122 --- gitlab/objects.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'gitlab/objects.py') diff --git a/gitlab/objects.py b/gitlab/objects.py index 313ed96..e522acc 100644 --- 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 -- cgit v1.2.1