Added clone-workspace publisher

Change-Id: I39c71d69b100206e09164f0b765bda14d6f428c6
This commit is contained in:
Eli Klein 2014-01-27 20:12:06 -07:00
parent a32288a573
commit dcfe7696d0
6 changed files with 104 additions and 0 deletions

View File

@ -254,6 +254,77 @@ def trigger(parser, xml_parent, data):
tcolor.text = thresholds[threshold]['color']
def clone_workspace(parser, xml_parent, data):
"""yaml: clone-workspace
Archive the workspace from builds of one project and reuse them as the SCM
source for another project.
Requires the Jenkins `Clone Workspace SCM Plugin.
<https://wiki.jenkins-ci.org/display/JENKINS/Clone+Workspace+SCM+Plugin>`_
:arg str workspace-glob: Files to include in cloned workspace
:arg str workspace-exclude-glob: Files to exclude from cloned workspace
:arg str criteria: Criteria for build to be archived. Can be 'any',
'not failed', or 'successful'. (default: any )
:arg str archive-method: Choose the method to use for archiving the
workspace. Can be 'tar' or 'zip'. (default: tar)
:arg bool override-default-excludes: Override default ant excludes.
(default: false)
Minimal example:
.. literalinclude::
/../../tests/publishers/fixtures/clone-workspace001.yaml
Full example:
.. literalinclude::
/../../tests/publishers/fixtures/clone-workspace002.yaml
"""
cloneworkspace = XML.SubElement(
xml_parent,
'hudson.plugins.cloneworkspace.CloneWorkspacePublisher',
{'plugin': 'clone-workspace-scm'})
XML.SubElement(
cloneworkspace,
'workspaceGlob').text = data.get('workspace-glob', None)
if 'workspace-exclude-glob' in data:
XML.SubElement(
cloneworkspace,
'workspaceExcludeGlob').text = data['workspace-exclude-glob']
criteria_list = ['Any', 'Not Failed', 'Successful']
criteria = data.get('criteria', 'Any').title()
if 'criteria' in data and criteria not in criteria_list:
raise JenkinsJobsException(
'clone-workspace criteria must be one of: '
+ ', '.join(criteria_list))
else:
XML.SubElement(cloneworkspace, 'criteria').text = criteria
archive_list = ['TAR', 'ZIP']
archive_method = data.get('archive-method', 'TAR').upper()
if 'archive-method' in data and archive_method not in archive_list:
raise JenkinsJobsException(
'clone-workspace archive-method must be one of: '
+ ', '.join(archive_list))
else:
XML.SubElement(cloneworkspace, 'archiveMethod').text = archive_method
XML.SubElement(
cloneworkspace,
'overrideDefaultExcludes').text = str(data.get(
'override-default-excludes',
False)).lower()
def cloverphp(parser, xml_parent, data):
"""yaml: cloverphp
Capture code coverage reports from PHPUnit

View File

@ -127,6 +127,7 @@ setuptools.setup(
'checkstyle=jenkins_jobs.modules.publishers:checkstyle',
'cifs=jenkins_jobs.modules.publishers:cifs',
'claim-build=jenkins_jobs.modules.publishers:claim_build',
'clone-workspace=jenkins_jobs.modules.publishers:clone_workspace',
'cloverphp=jenkins_jobs.modules.publishers:cloverphp',
'cobertura=jenkins_jobs.modules.publishers:cobertura',
'copy-to-master=jenkins_jobs.modules.publishers:copy_to_master',

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<hudson.plugins.cloneworkspace.CloneWorkspacePublisher plugin="clone-workspace-scm">
<workspaceGlob/>
<criteria>Any</criteria>
<archiveMethod>TAR</archiveMethod>
<overrideDefaultExcludes>false</overrideDefaultExcludes>
</hudson.plugins.cloneworkspace.CloneWorkspacePublisher>
</publishers>
</project>

View File

@ -0,0 +1,2 @@
publishers:
- clone-workspace

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<hudson.plugins.cloneworkspace.CloneWorkspacePublisher plugin="clone-workspace-scm">
<workspaceGlob>**/*.zip</workspaceGlob>
<workspaceExcludeGlob>**/*.tgz</workspaceExcludeGlob>
<criteria>Any</criteria>
<archiveMethod>TAR</archiveMethod>
<overrideDefaultExcludes>false</overrideDefaultExcludes>
</hudson.plugins.cloneworkspace.CloneWorkspacePublisher>
</publishers>
</project>

View File

@ -0,0 +1,7 @@
publishers:
- clone-workspace:
criteria: "any"
archive-method: "tar"
override-default-excludes: false
workspace-glob: "**/*.zip"
workspace-exclude-glob: "**/*.tgz"