Update workspace-cleanup to support newer options
This commit adds support for controlling whether cleanup runs via a job parameter and using an external deletion command. Change-Id: Ib80317c0e4cf95526ed59b719a1fd8df9c5e3f4f
This commit is contained in:
parent
915a36f449
commit
13fa71cd82
@ -2567,6 +2567,8 @@ def workspace_cleanup(parser, xml_parent, data):
|
||||
* **not-built** (`bool`) (default: true)
|
||||
:arg bool fail-build: Fail the build if the cleanup fails (default: true)
|
||||
:arg bool clean-parent: Cleanup matrix parent workspace (default: false)
|
||||
:arg str external-deletion-command: external deletion command to run
|
||||
against files and directories
|
||||
|
||||
Example:
|
||||
|
||||
@ -2577,7 +2579,7 @@ def workspace_cleanup(parser, xml_parent, data):
|
||||
|
||||
p = XML.SubElement(xml_parent,
|
||||
'hudson.plugins.ws__cleanup.WsCleanup')
|
||||
p.set("plugin", "ws-cleanup@0.14")
|
||||
p.set("plugin", "ws-cleanup")
|
||||
if "include" in data or "exclude" in data:
|
||||
patterns = XML.SubElement(p, 'patterns')
|
||||
|
||||
@ -2595,6 +2597,8 @@ def workspace_cleanup(parser, xml_parent, data):
|
||||
str(data.get("dirmatch", False)).lower()
|
||||
XML.SubElement(p, 'cleanupMatrixParent').text = \
|
||||
str(data.get("clean-parent", False)).lower()
|
||||
XML.SubElement(p, 'externalDelete').text = \
|
||||
str(data.get('external-deletion-command', ''))
|
||||
|
||||
mask = [('success', 'cleanWhenSuccess'),
|
||||
('unstable', 'cleanWhenUnstable'),
|
||||
|
@ -571,18 +571,21 @@ def workspace_cleanup(parser, xml_parent, data):
|
||||
:arg list include: list of files to be included
|
||||
:arg list exclude: list of files to be excluded
|
||||
:arg bool dirmatch: Apply pattern to directories too (default: false)
|
||||
:arg str check-parameter: boolean environment variable to check to
|
||||
determine whether to actually clean up
|
||||
:arg str external-deletion-command: external deletion command to run
|
||||
against files and directories
|
||||
|
||||
Example::
|
||||
|
||||
wrappers:
|
||||
- workspace-cleanup:
|
||||
include:
|
||||
- "*.zip"
|
||||
.. literalinclude::
|
||||
/../../tests/wrappers/fixtures/workspace-cleanup001.yaml
|
||||
:language: yaml
|
||||
"""
|
||||
|
||||
p = XML.SubElement(xml_parent,
|
||||
'hudson.plugins.ws__cleanup.PreBuildCleanup')
|
||||
p.set("plugin", "ws-cleanup@0.14")
|
||||
p.set("plugin", "ws-cleanup")
|
||||
if "include" in data or "exclude" in data:
|
||||
patterns = XML.SubElement(p, 'patterns')
|
||||
|
||||
@ -599,6 +602,12 @@ def workspace_cleanup(parser, xml_parent, data):
|
||||
deldirs = XML.SubElement(p, 'deleteDirs')
|
||||
deldirs.text = str(data.get("dirmatch", False)).lower()
|
||||
|
||||
XML.SubElement(p, 'cleanupParameter').text = str(
|
||||
data.get('check-parameter', ''))
|
||||
|
||||
XML.SubElement(p, 'externalDelete').text = str(
|
||||
data.get('external-deletion-command', ''))
|
||||
|
||||
|
||||
def m2_repository_cleanup(parser, xml_parent, data):
|
||||
"""yaml: m2-repository-cleanup
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup@0.14">
|
||||
<hudson.plugins.ws__cleanup.WsCleanup plugin="ws-cleanup">
|
||||
<patterns>
|
||||
<hudson.plugins.ws__cleanup.Pattern>
|
||||
<pattern>*.zip</pattern>
|
||||
@ -10,6 +10,7 @@
|
||||
</patterns>
|
||||
<deleteDirs>false</deleteDirs>
|
||||
<cleanupMatrixParent>false</cleanupMatrixParent>
|
||||
<externalDelete/>
|
||||
<cleanWhenSuccess>true</cleanWhenSuccess>
|
||||
<cleanWhenUnstable>true</cleanWhenUnstable>
|
||||
<cleanWhenFailure>true</cleanWhenFailure>
|
||||
|
16
tests/wrappers/fixtures/workspace-cleanup001.xml
Normal file
16
tests/wrappers/fixtures/workspace-cleanup001.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<buildWrappers>
|
||||
<hudson.plugins.ws__cleanup.PreBuildCleanup plugin="ws-cleanup">
|
||||
<patterns>
|
||||
<hudson.plugins.ws__cleanup.Pattern>
|
||||
<pattern>*.py</pattern>
|
||||
<type>EXCLUDE</type>
|
||||
</hudson.plugins.ws__cleanup.Pattern>
|
||||
</patterns>
|
||||
<deleteDirs>false</deleteDirs>
|
||||
<cleanupParameter>DO_WS_CLEANUP</cleanupParameter>
|
||||
<externalDelete>shred -u %s</externalDelete>
|
||||
</hudson.plugins.ws__cleanup.PreBuildCleanup>
|
||||
</buildWrappers>
|
||||
</project>
|
6
tests/wrappers/fixtures/workspace-cleanup001.yaml
Normal file
6
tests/wrappers/fixtures/workspace-cleanup001.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
wrappers:
|
||||
- workspace-cleanup:
|
||||
exclude:
|
||||
- "*.py"
|
||||
check-parameter: "DO_WS_CLEANUP"
|
||||
external-deletion-command: "shred -u %s"
|
Loading…
Reference in New Issue
Block a user