summaryrefslogtreecommitdiff
path: root/gitlab/objects.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2016-08-27 22:21:49 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2016-08-27 22:21:49 +0200
commit8257400fd78e0fdc26fdcb207dbc6e923332e209 (patch)
tree5984672107fc68f0f9b6f7889b3b26f2393efe23 /gitlab/objects.py
parentef2dbf7034aee21ecf225be5cfefee8ab4379bbe (diff)
downloadgitlab-8257400fd78e0fdc26fdcb207dbc6e923332e209.tar.gz
Add support for project pipelines
Diffstat (limited to 'gitlab/objects.py')
-rw-r--r--gitlab/objects.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py
index 96eab66..a3f5277 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -1610,6 +1610,43 @@ class ProjectFileManager(BaseManager):
obj_cls = ProjectFile
+class ProjectPipeline(GitlabObject):
+ _url = '/projects/%(project_id)s/pipelines'
+ canCreate = False
+ canUpdate = False
+ canDelete = False
+
+ def retry(self, **kwargs):
+ """Retries failed builds in a pipeline.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ GitlabPipelineRetryError: If the retry cannot be done.
+ """
+ url = ('/projects/%(project_id)s/pipelines/%(id)s/retry' %
+ {'project_id': self.project_id, 'id': self.id})
+ r = self.gitlab._raw_post(url, data=None, content_type=None, **kwargs)
+ raise_error_from_response(r, GitlabPipelineRetryError, 201)
+ self._set_from_dict(r.json())
+
+ def cancel(self, **kwargs):
+ """Cancel builds in a pipeline.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ GitlabPipelineCancelError: If the retry cannot be done.
+ """
+ url = ('/projects/%(project_id)s/pipelines/%(id)s/cancel' %
+ {'project_id': self.project_id, 'id': self.id})
+ r = self.gitlab._raw_post(url, data=None, content_type=None, **kwargs)
+ raise_error_from_response(r, GitlabPipelineRetryError, 200)
+ self._set_from_dict(r.json())
+
+
+class ProjectPipelineManager(BaseManager):
+ obj_cls = ProjectPipeline
+
+
class ProjectSnippetNote(GitlabObject):
_url = '/projects/%(project_id)s/snippets/%(snippet_id)s/notes'
_constructorTypes = {'author': 'User'}
@@ -1804,6 +1841,7 @@ class Project(GitlabObject):
('mergerequests', ProjectMergeRequestManager, [('project_id', 'id')]),
('milestones', ProjectMilestoneManager, [('project_id', 'id')]),
('notes', ProjectNoteManager, [('project_id', 'id')]),
+ ('pipelines', ProjectPipelineManager, [('project_id', 'id')]),
('services', ProjectServiceManager, [('project_id', 'id')]),
('snippets', ProjectSnippetManager, [('project_id', 'id')]),
('tags', ProjectTagManager, [('project_id', 'id')]),