Skip to content

Commit

Permalink
Merge pull request #767 from python-gitlab/fix/744/delete_artifacts
Browse files Browse the repository at this point in the history
feature: Implement artifacts deletion
  • Loading branch information
max-wittig committed Jun 17, 2019
2 parents e45a6e2 + 76b6e1f commit 4e1dd27
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
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

0 comments on commit 4e1dd27

Please sign in to comment.