Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Implement artifacts deletion #767

Merged
merged 1 commit into from Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/gl_objects/builds.rst
Expand Up @@ -319,6 +319,10 @@ Mark a job artifact as kept when expiration is set::

build_or_job.keep_artifacts()

Delete the artifacts of a job::

build_or_job.delete_artifacts()

Get a job trace::

build_or_job.trace()
Expand Down
15 changes: 15 additions & 0 deletions gitlab/v4/objects.py
Expand Up @@ -1584,6 +1584,21 @@ def keep_artifacts(self, **kwargs):
path = "%s/%s/artifacts/keep" % (self.manager.path, self.get_id())
self.manager.gitlab.http_post(path)

@cli.register_custom_action("ProjectJob")
@exc.on_http_error(exc.GitlabCreateError)
def delete_artifacts(self, **kwargs):
"""Delete artifacts of a job.

Args:
**kwargs: Extra options to send to the server (e.g. sudo)

Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabDeleteError: If the request could not be performed
"""
path = "%s/%s/artifacts" % (self.manager.path, self.get_id())
self.manager.gitlab.http_delete(path)

@cli.register_custom_action("ProjectJob")
@exc.on_http_error(exc.GitlabGetError)
def artifacts(self, streamed=False, action=None, chunk_size=1024, **kwargs):
Expand Down
3 changes: 2 additions & 1 deletion tools/python_test_v4.py
Expand Up @@ -421,8 +421,9 @@

# commit status
commit = admin_project.commits.list()[0]
size = len(commit.statuses.list())
status = commit.statuses.create({"state": "success", "sha": commit.id})
assert len(commit.statuses.list()) == 1
assert len(commit.statuses.list()) == size + 1

assert commit.refs()
assert commit.merge_requests() is not None
Expand Down