diff --git a/docs/gl_objects/builds.rst b/docs/gl_objects/builds.rst index ee450905a..e46a2d0f3 100644 --- a/docs/gl_objects/builds.rst +++ b/docs/gl_objects/builds.rst @@ -305,6 +305,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() diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 16a3da8aa..84ed5c342 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -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):