diff options
| author | Gauvain Pocentek <gauvain@pocentek.net> | 2016-08-27 22:21:49 +0200 |
|---|---|---|
| committer | Gauvain Pocentek <gauvain@pocentek.net> | 2016-08-27 22:21:49 +0200 |
| commit | 8257400fd78e0fdc26fdcb207dbc6e923332e209 (patch) | |
| tree | 5984672107fc68f0f9b6f7889b3b26f2393efe23 /gitlab | |
| parent | ef2dbf7034aee21ecf225be5cfefee8ab4379bbe (diff) | |
| download | gitlab-8257400fd78e0fdc26fdcb207dbc6e923332e209.tar.gz | |
Add support for project pipelines
Diffstat (limited to 'gitlab')
| -rw-r--r-- | gitlab/__init__.py | 3 | ||||
| -rw-r--r-- | gitlab/exceptions.py | 20 | ||||
| -rw-r--r-- | gitlab/objects.py | 38 |
3 files changed, 59 insertions, 2 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 70991b2..82f4918 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -102,6 +102,8 @@ class Gitlab(object): project_members (ProjectMemberManager): Manager for GitLab projects members project_notes (ProjectNoteManager): Manager for GitLab projects notes + project_pipelines (ProjectPipelineManager): Manager for GitLab projects + pipelines project_tags (ProjectTagManager): Manager for GitLab projects tags project_mergerequest_notes (ProjectMergeRequestNoteManager): Manager for GitLab notes on merge requests @@ -179,6 +181,7 @@ class Gitlab(object): self.project_issues = ProjectIssueManager(self) self.project_members = ProjectMemberManager(self) self.project_notes = ProjectNoteManager(self) + self.project_pipelines = ProjectPipelineManager(self) self.project_tags = ProjectTagManager(self) self.project_mergerequest_notes = ProjectMergeRequestNoteManager(self) self.project_mergerequests = ProjectMergeRequestManager(self) diff --git a/gitlab/exceptions.py b/gitlab/exceptions.py index e07f0cc..7b0f7f0 100644 --- a/gitlab/exceptions.py +++ b/gitlab/exceptions.py @@ -75,11 +75,27 @@ class GitlabTransferProjectError(GitlabOperationError): pass -class GitlabBuildCancelError(GitlabOperationError): +class GitlabCancelError(GitlabOperationError): pass -class GitlabBuildRetryError(GitlabOperationError): +class GitlabBuildCancelError(GitlabCancelError): + pass + + +class GitlabPipelineCancelError(GitlabCancelError): + pass + + +class GitlabRetryError(GitlabOperationError): + pass + + +class GitlabBuildRetryError(GitlabRetryError): + pass + + +class GitlabPipelineRetryError(GitlabRetryError): pass 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')]), |
