Skip to content

Commit 71010f6

Browse files
author
Gauvain Pocentek
committed
feature: Implement artifacts deletion
Closes #744
1 parent 16de1b0 commit 71010f6

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
@@ -1342,6 +1342,21 @@ def keep_artifacts(self, **kwargs):
13421342
path = '%s/%s/artifacts/keep' % (self.manager.path, self.get_id())
13431343
self.manager.gitlab.http_post(path)
13441344

1345+
@cli.register_custom_action('ProjectJob')
1346+
@exc.on_http_error(exc.GitlabCreateError)
1347+
def delete_artifacts(self, **kwargs):
1348+
"""Delete artifacts of a job?
1349+
1350+
Args:
1351+
**kwargs: Extra options to send to the server (e.g. sudo)
1352+
1353+
Raises:
1354+
GitlabAuthenticationError: If authentication is not correct
1355+
GitlabDeleteError: If the request could not be performed
1356+
"""
1357+
path = '%s/%s/artifacts' % (self.manager.path, self.get_id())
1358+
self.manager.gitlab.http_delete(path)
1359+
13451360
@cli.register_custom_action('ProjectJob')
13461361
@exc.on_http_error(exc.GitlabGetError)
13471362
def artifacts(self, streamed=False, action=None, chunk_size=1024,

0 commit comments

Comments
 (0)