From 08f76f724debfe1e977e427feac47cb0473ed37a Mon Sep 17 00:00:00 2001 From: Teemu Patja Date: Mon, 7 Mar 2016 12:47:49 +0200 Subject: [PATCH] Adds support for wiping out a job's workspace Support for wiping out a Jenkins job's workspace. Change-Id: I8daa4a6fe7976c90ca59c89bda775d83aff7b622 Signed-off-by: Sorin Sbarnea --- README.rst | 1 + jenkins/__init__.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/README.rst b/README.rst index 99cc404..5a7ceb2 100644 --- a/README.rst +++ b/README.rst @@ -24,6 +24,7 @@ the things you can use it for: * Put server in shutdown mode (quiet down) * List running builds * Delete builds +* Wipeout job workspace * Create/delete/update folders [#f1]_ * Set the next build number [#f2]_ * Install plugins diff --git a/jenkins/__init__.py b/jenkins/__init__.py index 5be7ba4..baa209a 100755 --- a/jenkins/__init__.py +++ b/jenkins/__init__.py @@ -116,6 +116,7 @@ BUILD_WITH_PARAMS_JOB = '%(folder_url)sjob/%(short_name)s/buildWithParameters' BUILD_INFO = '%(folder_url)sjob/%(short_name)s/%(number)d/api/json?depth=%(depth)s' BUILD_CONSOLE_OUTPUT = '%(folder_url)sjob/%(short_name)s/%(number)d/consoleText' DELETE_BUILD = '%(folder_url)sjob/%(short_name)s/%(number)s/doDelete' +WIPEOUT_JOB_WORKSPACE = '%(folder_url)sjob/%(short_name)s/doWipeOutWorkspace' NODE_LIST = 'computer/api/json' CREATE_NODE = 'computer/doCreateItem' DELETE_NODE = 'computer/%(name)s/doDelete' @@ -1239,6 +1240,16 @@ class Jenkins(object): self.jenkins_open(requests.Request('POST', self._build_url(DELETE_BUILD, locals()), b'')) + def wipeout_job_workspace(self, name): + """Wipe out workspace for given Jenkins job. + + :param name: Name of Jenkins job, ``str`` + """ + folder_url, short_name = self._get_job_folder(name) + self.jenkins_open(requests.Request('POST', + self._build_url(WIPEOUT_JOB_WORKSPACE, + locals()), b'')) + def get_running_builds(self): '''Return list of running builds.