Skip to content

Commit e0cf1c2

Browse files
author
Gauvain Pocentek
committed
Implement ProjectBuild.keep_artifacts
1 parent b339ed9 commit e0cf1c2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

gitlab/objects.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,8 @@ class ProjectBranchManager(BaseManager):
858858
class ProjectBuild(GitlabObject):
859859
_url = '/projects/%(project_id)s/builds'
860860
_constructorTypes = {'user': 'User',
861-
'commit': 'ProjectCommit'}
861+
'commit': 'ProjectCommit',
862+
'runner': 'Runner'}
862863
requiredUrlAttrs = ['project_id']
863864
canDelete = False
864865
canUpdate = False
@@ -876,6 +877,18 @@ def retry(self, **kwargs):
876877
r = self.gitlab._raw_post(url)
877878
raise_error_from_response(r, GitlabBuildRetryError, 201)
878879

880+
def keep_artifacts(self, **kwargs):
881+
"""Prevent artifacts from being delete when expiration is set.
882+
883+
Raises:
884+
GitlabConnectionError: If the server cannot be reached.
885+
GitlabCreateError: If the request failed.
886+
"""
887+
url = ('/projects/%s/builds/%s/artifacts/keep' %
888+
(self.project_id, self.id))
889+
r = self.gitlab._raw_post(url)
890+
raise_error_from_response(r, GitlabGetError, 200)
891+
879892
def artifacts(self, **kwargs):
880893
"""Get the build artifacts.
881894

0 commit comments

Comments
 (0)