@@ -691,6 +691,30 @@ class ProjectBranchManager(BaseManager):
691
691
obj_cls = ProjectBranch
692
692
693
693
694
+ class ProjectBuild (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
+ def cancel (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
+ def retry (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
+ class ProjectBuildManager (BaseManager ):
715
+ obj_cls = ProjectBuild
716
+
717
+
694
718
class ProjectCommit (GitlabObject ):
695
719
_url = '/projects/%(project_id)s/repository/commits'
696
720
canDelete = False
@@ -716,6 +740,20 @@ def blob(self, filepath, **kwargs):
716
740
717
741
return r .content
718
742
743
+ def builds (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
+ for j in r .json ():
751
+ o = ProjectBuild (self , j )
752
+ o ._from_api = True
753
+ l .append (o )
754
+
755
+ return l
756
+
719
757
720
758
class ProjectCommitManager (BaseManager ):
721
759
obj_cls = ProjectCommit
@@ -1088,6 +1126,7 @@ class Project(GitlabObject):
1088
1126
shortPrintAttr = 'path'
1089
1127
managers = [
1090
1128
('branches' , ProjectBranchManager , [('project_id' , 'id' )]),
1129
+ ('builds' , ProjectBuildManager , [('project_id' , 'id' )]),
1091
1130
('commits' , ProjectCommitManager , [('project_id' , 'id' )]),
1092
1131
('commitstatuses' , ProjectCommitStatusManager , [('project_id' , 'id' )]),
1093
1132
('events' , ProjectEventManager , [('project_id' , 'id' )]),
0 commit comments