Skip to content

Commit c2f45e9

Browse files
Add ProjectBuild.erase()
We can't use the existing delete() functionality, because GitLab uses `POST /projects/:id/builds/:build_id/erase` to erase a build. Instead of overriding delete(), we add a separate erase() method to keep the naming consistent, and allow potentially more fine-grained operations in the future. - https://docs.gitlab.com/ce/api/builds.html#erase-a-build
1 parent 7d424ae commit c2f45e9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

gitlab/exceptions.py

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ class GitlabBuildRetryError(GitlabRetryError):
9595
pass
9696

9797

98+
class GitlabBuildEraseError(GitlabRetryError):
99+
pass
100+
101+
98102
class GitlabPipelineRetryError(GitlabRetryError):
99103
pass
100104

gitlab/objects.py

+6
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,12 @@ def retry(self, **kwargs):
961961
r = self.gitlab._raw_post(url)
962962
raise_error_from_response(r, GitlabBuildRetryError, 201)
963963

964+
def erase(self, **kwargs):
965+
"""Erase the build (remove build artifacts and trace)."""
966+
url = '/projects/%s/builds/%s/erase' % (self.project_id, self.id)
967+
r = self.gitlab._raw_post(url)
968+
raise_error_from_response(r, GitlabBuildEraseError, 201)
969+
964970
def keep_artifacts(self, **kwargs):
965971
"""Prevent artifacts from being delete when expiration is set.
966972

0 commit comments

Comments
 (0)