Skip to content

Commit deac5a8

Browse files
author
Gauvain Pocentek
committed
[v4] Builds have been renamed to Jobs
1 parent 29e735d commit deac5a8

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed

gitlab/exceptions.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ class GitlabCancelError(GitlabOperationError):
8383
pass
8484

8585

86-
class GitlabBuildCancelError(GitlabCancelError):
86+
class GitlabPipelineCancelError(GitlabCancelError):
8787
pass
8888

8989

90-
class GitlabPipelineCancelError(GitlabCancelError):
90+
class GitlabRetryError(GitlabOperationError):
9191
pass
9292

9393

94-
class GitlabRetryError(GitlabOperationError):
94+
class GitlabBuildCancelError(GitlabCancelError):
9595
pass
9696

9797

@@ -107,6 +107,22 @@ class GitlabBuildEraseError(GitlabRetryError):
107107
pass
108108

109109

110+
class GitlabJobCancelError(GitlabCancelError):
111+
pass
112+
113+
114+
class GitlabJobRetryError(GitlabRetryError):
115+
pass
116+
117+
118+
class GitlabJobPlayError(GitlabRetryError):
119+
pass
120+
121+
122+
class GitlabJobEraseError(GitlabRetryError):
123+
pass
124+
125+
110126
class GitlabPipelineRetryError(GitlabRetryError):
111127
pass
112128

gitlab/v4/objects.py

+22-38
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ class ProjectBranchManager(BaseManager):
563563
obj_cls = ProjectBranch
564564

565565

566-
class ProjectBuild(GitlabObject):
567-
_url = '/projects/%(project_id)s/builds'
566+
class ProjectJob(GitlabObject):
567+
_url = '/projects/%(project_id)s/jobs'
568568
_constructorTypes = {'user': 'User',
569569
'commit': 'ProjectCommit',
570570
'runner': 'Runner'}
@@ -574,28 +574,28 @@ class ProjectBuild(GitlabObject):
574574
canCreate = False
575575

576576
def cancel(self, **kwargs):
577-
"""Cancel the build."""
578-
url = '/projects/%s/builds/%s/cancel' % (self.project_id, self.id)
577+
"""Cancel the job."""
578+
url = '/projects/%s/jobs/%s/cancel' % (self.project_id, self.id)
579579
r = self.gitlab._raw_post(url)
580-
raise_error_from_response(r, GitlabBuildCancelError, 201)
580+
raise_error_from_response(r, GitlabJobCancelError, 201)
581581

582582
def retry(self, **kwargs):
583-
"""Retry the build."""
584-
url = '/projects/%s/builds/%s/retry' % (self.project_id, self.id)
583+
"""Retry the job."""
584+
url = '/projects/%s/jobs/%s/retry' % (self.project_id, self.id)
585585
r = self.gitlab._raw_post(url)
586-
raise_error_from_response(r, GitlabBuildRetryError, 201)
586+
raise_error_from_response(r, GitlabJobRetryError, 201)
587587

588588
def play(self, **kwargs):
589-
"""Trigger a build explicitly."""
590-
url = '/projects/%s/builds/%s/play' % (self.project_id, self.id)
589+
"""Trigger a job explicitly."""
590+
url = '/projects/%s/jobs/%s/play' % (self.project_id, self.id)
591591
r = self.gitlab._raw_post(url)
592-
raise_error_from_response(r, GitlabBuildPlayError)
592+
raise_error_from_response(r, GitlabJobPlayError)
593593

594594
def erase(self, **kwargs):
595-
"""Erase the build (remove build artifacts and trace)."""
596-
url = '/projects/%s/builds/%s/erase' % (self.project_id, self.id)
595+
"""Erase the job (remove job artifacts and trace)."""
596+
url = '/projects/%s/jobs/%s/erase' % (self.project_id, self.id)
597597
r = self.gitlab._raw_post(url)
598-
raise_error_from_response(r, GitlabBuildEraseError, 201)
598+
raise_error_from_response(r, GitlabJobEraseError, 201)
599599

600600
def keep_artifacts(self, **kwargs):
601601
"""Prevent artifacts from being delete when expiration is set.
@@ -604,14 +604,14 @@ def keep_artifacts(self, **kwargs):
604604
GitlabConnectionError: If the server cannot be reached.
605605
GitlabCreateError: If the request failed.
606606
"""
607-
url = ('/projects/%s/builds/%s/artifacts/keep' %
607+
url = ('/projects/%s/jobs/%s/artifacts/keep' %
608608
(self.project_id, self.id))
609609
r = self.gitlab._raw_post(url)
610610
raise_error_from_response(r, GitlabGetError, 200)
611611

612612
def artifacts(self, streamed=False, action=None, chunk_size=1024,
613613
**kwargs):
614-
"""Get the build artifacts.
614+
"""Get the job artifacts.
615615
616616
Args:
617617
streamed (bool): If True the data will be processed by chunks of
@@ -628,13 +628,13 @@ def artifacts(self, streamed=False, action=None, chunk_size=1024,
628628
GitlabConnectionError: If the server cannot be reached.
629629
GitlabGetError: If the artifacts are not available.
630630
"""
631-
url = '/projects/%s/builds/%s/artifacts' % (self.project_id, self.id)
631+
url = '/projects/%s/jobs/%s/artifacts' % (self.project_id, self.id)
632632
r = self.gitlab._raw_get(url, streamed=streamed, **kwargs)
633633
raise_error_from_response(r, GitlabGetError, 200)
634634
return utils.response_content(r, streamed, action, chunk_size)
635635

636636
def trace(self, streamed=False, action=None, chunk_size=1024, **kwargs):
637-
"""Get the build trace.
637+
"""Get the job trace.
638638
639639
Args:
640640
streamed (bool): If True the data will be processed by chunks of
@@ -651,14 +651,14 @@ def trace(self, streamed=False, action=None, chunk_size=1024, **kwargs):
651651
GitlabConnectionError: If the server cannot be reached.
652652
GitlabGetError: If the trace is not available.
653653
"""
654-
url = '/projects/%s/builds/%s/trace' % (self.project_id, self.id)
654+
url = '/projects/%s/jobs/%s/trace' % (self.project_id, self.id)
655655
r = self.gitlab._raw_get(url, streamed=streamed, **kwargs)
656656
raise_error_from_response(r, GitlabGetError, 200)
657657
return utils.response_content(r, streamed, action, chunk_size)
658658

659659

660-
class ProjectBuildManager(BaseManager):
661-
obj_cls = ProjectBuild
660+
class ProjectJobManager(BaseManager):
661+
obj_cls = ProjectJob
662662

663663

664664
class ProjectCommitStatus(GitlabObject):
@@ -742,22 +742,6 @@ def blob(self, filepath, streamed=False, action=None, chunk_size=1024,
742742
raise_error_from_response(r, GitlabGetError)
743743
return utils.response_content(r, streamed, action, chunk_size)
744744

745-
def builds(self, **kwargs):
746-
"""List the build for this commit.
747-
748-
Returns:
749-
list(ProjectBuild): A list of builds.
750-
751-
Raises:
752-
GitlabConnectionError: If the server cannot be reached.
753-
GitlabListError: If the server fails to perform the request.
754-
"""
755-
url = '/projects/%s/repository/commits/%s/builds' % (self.project_id,
756-
self.id)
757-
return self.gitlab._raw_list(url, ProjectBuild,
758-
{'project_id': self.project_id},
759-
**kwargs)
760-
761745
def cherry_pick(self, branch, **kwargs):
762746
"""Cherry-pick a commit into a branch.
763747
@@ -1794,7 +1778,7 @@ class Project(GitlabObject):
17941778
('boards', 'ProjectBoardManager', [('project_id', 'id')]),
17951779
('board_lists', 'ProjectBoardListManager', [('project_id', 'id')]),
17961780
('branches', 'ProjectBranchManager', [('project_id', 'id')]),
1797-
('builds', 'ProjectBuildManager', [('project_id', 'id')]),
1781+
('builds', 'ProjectJobManager', [('project_id', 'id')]),
17981782
('commits', 'ProjectCommitManager', [('project_id', 'id')]),
17991783
('deployments', 'ProjectDeploymentManager', [('project_id', 'id')]),
18001784
('environments', 'ProjectEnvironmentManager', [('project_id', 'id')]),

0 commit comments

Comments
 (0)