summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2019-05-01 07:45:19 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2019-06-10 15:05:46 +0200
commit76b6e1fc0f42ad00f21d284b4ca2c45d6020fd19 (patch)
tree08a3cab6460bcb26eb6bde7122b004a7a16ee59e
parente45a6e2618db30834f732c5a7bc9f1c038c45c31 (diff)
downloadgitlab-fix/744/delete_artifacts.tar.gz
feat: implement artifacts deletionfix/744/delete_artifacts
Closes #744
-rw-r--r--docs/gl_objects/builds.rst4
-rw-r--r--gitlab/v4/objects.py15
-rw-r--r--tools/python_test_v4.py3
3 files changed, 21 insertions, 1 deletions
diff --git a/docs/gl_objects/builds.rst b/docs/gl_objects/builds.rst
index d74d9d6..eab4735 100644
--- a/docs/gl_objects/builds.rst
+++ b/docs/gl_objects/builds.rst
@@ -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()
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 8fc7150..d15bc5d 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -1585,6 +1585,21 @@ class ProjectJob(RESTObject, RefreshMixin):
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):
"""Get the job artifacts.
diff --git a/tools/python_test_v4.py b/tools/python_test_v4.py
index b8dae28..07f3589 100644
--- a/tools/python_test_v4.py
+++ b/tools/python_test_v4.py
@@ -421,8 +421,9 @@ assert "@@" in admin_project.commits.list()[0].diff()[0]["diff"]
# 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