Skip to content

Commit b148a2b

Browse files
author
Gauvain Pocentek
committed
feat: implement artifacts deletion
Closes #744
1 parent 794d64c commit b148a2b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

docs/gl_objects/builds.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ Mark a job artifact as kept when expiration is set::
305305

306306
build_or_job.keep_artifacts()
307307

308+
Delete the artifacts of a job::
309+
310+
build_or_job.delete_artifacts()
311+
308312
Get a job trace::
309313

310314
build_or_job.trace()

gitlab/v4/objects.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,21 @@ def keep_artifacts(self, **kwargs):
15841584
path = "%s/%s/artifacts/keep" % (self.manager.path, self.get_id())
15851585
self.manager.gitlab.http_post(path)
15861586

1587+
@cli.register_custom_action("ProjectJob")
1588+
@exc.on_http_error(exc.GitlabCreateError)
1589+
def delete_artifacts(self, **kwargs):
1590+
"""Delete artifacts of a job?
1591+
1592+
Args:
1593+
**kwargs: Extra options to send to the server (e.g. sudo)
1594+
1595+
Raises:
1596+
GitlabAuthenticationError: If authentication is not correct
1597+
GitlabDeleteError: If the request could not be performed
1598+
"""
1599+
path = "%s/%s/artifacts" % (self.manager.path, self.get_id())
1600+
self.manager.gitlab.http_delete(path)
1601+
15871602
@cli.register_custom_action("ProjectJob")
15881603
@exc.on_http_error(exc.GitlabGetError)
15891604
def artifacts(self, streamed=False, action=None, chunk_size=1024, **kwargs):

0 commit comments

Comments
 (0)