Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitebf36b8

Browse files
author
Gauvain Pocentek
committed
add support for project builds
1 parentfc8affd commitebf36b8

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

‎gitlab/exceptions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ class GitlabTransferProjectError(GitlabOperationError):
7575
pass
7676

7777

78+
classGitlabBuildCancelError(GitlabOperationError):
79+
pass
80+
81+
82+
classGitlabBuildRetryError(GitlabOperationError):
83+
pass
84+
85+
7886
defraise_error_from_response(response,error,expected_code=200):
7987
"""Tries to parse gitlab error message from response and raises error.
8088

‎gitlab/objects.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,30 @@ class ProjectBranchManager(BaseManager):
691691
obj_cls=ProjectBranch
692692

693693

694+
classProjectBuild(GitlabObject):
695+
_url='/projects/%(project_id)s/builds'
696+
_constructorTypes= {'user':'User',
697+
'commit':'ProjectCommit'}
698+
requiredUrlAttrs= ['project_id']
699+
canDelete=False
700+
canUpdate=False
701+
canCreate=False
702+
703+
defcancel(self):
704+
url='/projects/%s/builds/%s/cancel'% (self.project_id,self.id)
705+
r=self.gitlab._raw_post(url)
706+
raise_error_from_response(r,GitlabBuildCancelError,201)
707+
708+
defretry(self):
709+
url='/projects/%s/builds/%s/retry'% (self.project_id,self.id)
710+
r=self.gitlab._raw_post(url)
711+
raise_error_from_response(r,GitlabBuildRetryError,201)
712+
713+
714+
classProjectBuildManager(BaseManager):
715+
obj_cls=ProjectBuild
716+
717+
694718
classProjectCommit(GitlabObject):
695719
_url='/projects/%(project_id)s/repository/commits'
696720
canDelete=False
@@ -716,6 +740,20 @@ def blob(self, filepath, **kwargs):
716740

717741
returnr.content
718742

743+
defbuilds(self,**kwargs):
744+
url='/projects/%s/repository/commits/%s/builds'% (self.project_id,
745+
self.id)
746+
r=self.gitlab._raw_get(url,**kwargs)
747+
raise_error_from_response(r,GitlabListError)
748+
749+
l= []
750+
forjinr.json():
751+
o=ProjectBuild(self,j)
752+
o._from_api=True
753+
l.append(o)
754+
755+
returnl
756+
719757

720758
classProjectCommitManager(BaseManager):
721759
obj_cls=ProjectCommit
@@ -1088,6 +1126,7 @@ class Project(GitlabObject):
10881126
shortPrintAttr='path'
10891127
managers= [
10901128
('branches',ProjectBranchManager, [('project_id','id')]),
1129+
('builds',ProjectBuildManager, [('project_id','id')]),
10911130
('commits',ProjectCommitManager, [('project_id','id')]),
10921131
('commitstatuses',ProjectCommitStatusManager, [('project_id','id')]),
10931132
('events',ProjectEventManager, [('project_id','id')]),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp