Skip to content

Commit

Permalink
Add ProjectBuild.erase()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JonathonReinhart committed Oct 2, 2016
1 parent 7d424ae commit c2f45e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gitlab/exceptions.py
Expand Up @@ -95,6 +95,10 @@ class GitlabBuildRetryError(GitlabRetryError):
pass


class GitlabBuildEraseError(GitlabRetryError):
pass


class GitlabPipelineRetryError(GitlabRetryError):
pass

Expand Down
6 changes: 6 additions & 0 deletions gitlab/objects.py
Expand Up @@ -961,6 +961,12 @@ def retry(self, **kwargs):
r = self.gitlab._raw_post(url)
raise_error_from_response(r, GitlabBuildRetryError, 201)

def erase(self, **kwargs):
"""Erase the build (remove build artifacts and trace)."""
url = '/projects/%s/builds/%s/erase' % (self.project_id, self.id)
r = self.gitlab._raw_post(url)
raise_error_from_response(r, GitlabBuildEraseError, 201)

def keep_artifacts(self, **kwargs):
"""Prevent artifacts from being delete when expiration is set.
Expand Down

0 comments on commit c2f45e9

Please sign in to comment.