Skip to content

Commit 3371008

Browse files
author
Colin D Bennett
committed
Support setting commit status
Support commit status updates. Commit status can be set by a POST to the appropriate commit URL. The status can be updated by a subsequent POST to the same URL with the same `name` and `ref`, but different values for `state`, `description`, etc. Note: Listing the commit statuses is not yet supported. This is done through a different path on the server, under the `repository` path. Example of use from the CLI: # add a build status to a commit gitlab project-commit-status create --project-id 2 \ --commit-id a43290c --state success --name ci/jenkins \ --target-url http://server/build/123 \ --description "Jenkins build succeeded"
1 parent 1d7ebea commit 3371008

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

gitlab/objects.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,22 @@ class ProjectCommitManager(BaseManager):
681681
obj_cls = ProjectCommit
682682

683683

684+
class ProjectCommitStatus(GitlabObject):
685+
_url = '/projects/%(project_id)s/statuses/%(commit_id)s'
686+
canUpdate = False
687+
canDelete = False
688+
requiredUrlAttrs = ['project_id', 'commit_id']
689+
requiredCreateAttrs = ['state']
690+
optionalCreateAttrs = ['description', 'name', 'ref', 'target_url']
691+
requiredGetAttrs = []
692+
requiredUpdateAttrs = []
693+
requiredDeleteAttrs = []
694+
695+
696+
class ProjectCommitStatusManager(BaseManager):
697+
obj_cls = ProjectCommitStatus
698+
699+
684700
class ProjectKey(GitlabObject):
685701
_url = '/projects/%(project_id)s/keys'
686702
canUpdate = False
@@ -961,6 +977,7 @@ class Project(GitlabObject):
961977
managers = [
962978
('branches', ProjectBranchManager, [('project_id', 'id')]),
963979
('commits', ProjectCommitManager, [('project_id', 'id')]),
980+
('commitstatuses', ProjectCommitStatusManager, [('project_id', 'id')]),
964981
('events', ProjectEventManager, [('project_id', 'id')]),
965982
('files', ProjectFileManager, [('project_id', 'id')]),
966983
('forks', ProjectForkManager, [('project_id', 'id')]),

0 commit comments

Comments
 (0)