| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ef2dbf7 commit 8257400
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -382,3 +382,23 @@ | |||
| 382 | 382 | # service delete | |
| 383 | 383 | service.delete() | |
| 384 | 384 | # end service delete | |
| 385 | + | ||
| 386 | + # pipeline list | ||
| 387 | + pipelines = gl.project_pipelines.list(project_id=1) | ||
| 388 | + # or | ||
| 389 | + pipelines = project.pipelines.list() | ||
| 390 | + # end pipeline list | ||
| 391 | + | ||
| 392 | + # pipeline get | ||
| 393 | + pipeline = gl.project_pipelines.get(pipeline_id, project_id=1) | ||
| 394 | + # or | ||
| 395 | + pipeline = project.pipelines.get(pipeline_id) | ||
| 396 | + # end pipeline get | ||
| 397 | + | ||
| 398 | + # pipeline retry | ||
| 399 | + pipeline.retry() | ||
| 400 | + # end pipeline retry | ||
| 401 | + | ||
| 402 | + # pipeline cancel | ||
| 403 | + pipeline.cancel() | ||
| 404 | + # end pipeline cancel | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -395,6 +395,37 @@ Delete a project hook: | |||
| 395 | 395 | :start-after: # hook delete | |
| 396 | 396 | :end-before: # end hook delete | |
| 397 | 397 | ||
| 398 | + Pipelines | ||
| 399 | + --------- | ||
| 400 | + | ||
| 401 | + Use :class:`~gitlab.objects.ProjectPipeline` objects to manipulate projects | ||
| 402 | + pipelines. The :attr:`gitlab.Gitlab.project_pipelines` and | ||
| 403 | + :attr:`Project.services <gitlab.objects.Projects.pipelines>` manager objects | ||
| 404 | + provide helper functions. | ||
| 405 | + | ||
| 406 | + List pipelines for a project: | ||
| 407 | + | ||
| 408 | + .. literalinclude:: projects.py | ||
| 409 | + :start-after: # pipeline list | ||
| 410 | + :end-before: # end pipeline list | ||
| 411 | + | ||
| 412 | + Get a pipeline for a project: | ||
| 413 | + | ||
| 414 | + .. literalinclude:: projects.py | ||
| 415 | + :start-after: # pipeline get | ||
| 416 | + :end-before: # end pipeline get | ||
| 417 | + | ||
| 418 | + Retry the failed builds for a pipeline: | ||
| 419 | + | ||
| 420 | + .. literalinclude:: projects.py | ||
| 421 | + :start-after: # pipeline retry | ||
| 422 | + :end-before: # end pipeline retry | ||
| 423 | + | ||
| 424 | + Cancel builds in a pipeline: | ||
| 425 | + | ||
| 426 | + .. literalinclude:: projects.py | ||
| 427 | + :start-after: # pipeline cancel | ||
| 428 | + :end-before: # end pipeline cancel | ||
| 398 | 429 | Services | |
| 399 | 430 | -------- | |
| 400 | 431 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -102,6 +102,8 @@ class Gitlab(object): | |||
| 102 | 102 | project_members (ProjectMemberManager): Manager for GitLab projects | |
| 103 | 103 | members | |
| 104 | 104 | project_notes (ProjectNoteManager): Manager for GitLab projects notes | |
| 105 | + project_pipelines (ProjectPipelineManager): Manager for GitLab projects | ||
| 106 | + pipelines | ||
| 105 | 107 | project_tags (ProjectTagManager): Manager for GitLab projects tags | |
| 106 | 108 | project_mergerequest_notes (ProjectMergeRequestNoteManager): Manager | |
| 107 | 109 | for GitLab notes on merge requests | |
@@ -179,6 +181,7 @@ def __init__(self, url, private_token=None, email=None, password=None, | |||
| 179 | 181 | self.project_issues = ProjectIssueManager(self) | |
| 180 | 182 | self.project_members = ProjectMemberManager(self) | |
| 181 | 183 | self.project_notes = ProjectNoteManager(self) | |
| 184 | + self.project_pipelines = ProjectPipelineManager(self) | ||
| 182 | 185 | self.project_tags = ProjectTagManager(self) | |
| 183 | 186 | self.project_mergerequest_notes = ProjectMergeRequestNoteManager(self) | |
| 184 | 187 | self.project_mergerequests = ProjectMergeRequestManager(self) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,11 +75,27 @@ class GitlabTransferProjectError(GitlabOperationError): | |||
| 75 | 75 | pass | |
| 76 | 76 | ||
| 77 | 77 | ||
| 78 | - class GitlabBuildCancelError(GitlabOperationError): | ||
| 78 | + class GitlabCancelError(GitlabOperationError): | ||
| 79 | 79 | pass | |
| 80 | 80 | ||
| 81 | 81 | ||
| 82 | - class GitlabBuildRetryError(GitlabOperationError): | ||
| 82 | + class GitlabBuildCancelError(GitlabCancelError): | ||
| 83 | + pass | ||
| 84 | + | ||
| 85 | + | ||
| 86 | + class GitlabPipelineCancelError(GitlabCancelError): | ||
| 87 | + pass | ||
| 88 | + | ||
| 89 | + | ||
| 90 | + class GitlabRetryError(GitlabOperationError): | ||
| 91 | + pass | ||
| 92 | + | ||
| 93 | + | ||
| 94 | + class GitlabBuildRetryError(GitlabRetryError): | ||
| 95 | + pass | ||
| 96 | + | ||
| 97 | + | ||
| 98 | + class GitlabPipelineRetryError(GitlabRetryError): | ||
| 83 | 99 | pass | |
| 84 | 100 | ||
| 85 | 101 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1610,6 +1610,43 @@ class ProjectFileManager(BaseManager): | |||
| 1610 | 1610 | obj_cls = ProjectFile | |
| 1611 | 1611 | ||
| 1612 | 1612 | ||
| 1613 | + class ProjectPipeline(GitlabObject): | ||
| 1614 | + _url = '/projects/%(project_id)s/pipelines' | ||
| 1615 | + canCreate = False | ||
| 1616 | + canUpdate = False | ||
| 1617 | + canDelete = False | ||
| 1618 | + | ||
| 1619 | + def retry(self, **kwargs): | ||
| 1620 | + """Retries failed builds in a pipeline. | ||
| 1621 | + | ||
| 1622 | + Raises: | ||
| 1623 | + GitlabConnectionError: If the server cannot be reached. | ||
| 1624 | + GitlabPipelineRetryError: If the retry cannot be done. | ||
| 1625 | + """ | ||
| 1626 | + url = ('/projects/%(project_id)s/pipelines/%(id)s/retry' % | ||
| 1627 | + {'project_id': self.project_id, 'id': self.id}) | ||
| 1628 | + r = self.gitlab._raw_post(url, data=None, content_type=None, **kwargs) | ||
| 1629 | + raise_error_from_response(r, GitlabPipelineRetryError, 201) | ||
| 1630 | + self._set_from_dict(r.json()) | ||
| 1631 | + | ||
| 1632 | + def cancel(self, **kwargs): | ||
| 1633 | + """Cancel builds in a pipeline. | ||
| 1634 | + | ||
| 1635 | + Raises: | ||
| 1636 | + GitlabConnectionError: If the server cannot be reached. | ||
| 1637 | + GitlabPipelineCancelError: If the retry cannot be done. | ||
| 1638 | + """ | ||
| 1639 | + url = ('/projects/%(project_id)s/pipelines/%(id)s/cancel' % | ||
| 1640 | + {'project_id': self.project_id, 'id': self.id}) | ||
| 1641 | + r = self.gitlab._raw_post(url, data=None, content_type=None, **kwargs) | ||
| 1642 | + raise_error_from_response(r, GitlabPipelineRetryError, 200) | ||
| 1643 | + self._set_from_dict(r.json()) | ||
| 1644 | + | ||
| 1645 | + | ||
| 1646 | + class ProjectPipelineManager(BaseManager): | ||
| 1647 | + obj_cls = ProjectPipeline | ||
| 1648 | + | ||
| 1649 | + | ||
| 1613 | 1650 | class ProjectSnippetNote(GitlabObject): | |
| 1614 | 1651 | _url = '/projects/%(project_id)s/snippets/%(snippet_id)s/notes' | |
| 1615 | 1652 | _constructorTypes = {'author': 'User'} | |
@@ -1804,6 +1841,7 @@ class Project(GitlabObject): | |||
| 1804 | 1841 | ('mergerequests', ProjectMergeRequestManager, [('project_id', 'id')]), | |
| 1805 | 1842 | ('milestones', ProjectMilestoneManager, [('project_id', 'id')]), | |
| 1806 | 1843 | ('notes', ProjectNoteManager, [('project_id', 'id')]), | |
| 1844 | + ('pipelines', ProjectPipelineManager, [('project_id', 'id')]), | ||
| 1807 | 1845 | ('services', ProjectServiceManager, [('project_id', 'id')]), | |
| 1808 | 1846 | ('snippets', ProjectSnippetManager, [('project_id', 'id')]), | |
| 1809 | 1847 | ('tags', ProjectTagManager, [('project_id', 'id')]), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments