Add workspace scm

Add support for the 'Clone Workspace SCM' plugin that allows to use the workspace
of a project as the SCM of an other project.

Change-Id: I8467ace24665855dab606d6e52a1c130cd2929af
This commit is contained in:
Sylvain Baubeau 2014-03-10 16:14:47 +01:00 committed by Antoine Musso
parent d2ff8c098f
commit e8cace6d4d
4 changed files with 50 additions and 0 deletions

View File

@ -470,6 +470,44 @@ def tfs(self, xml_parent, data):
'Browser'})
def workspace(self, xml_parent, data):
"""yaml: workspace
Specifies the cloned workspace for this job to use as a SCM source.
Requires the Jenkins `Clone Workspace SCM Plugin.
<https://wiki.jenkins-ci.org/display/JENKINS/Clone+Workspace+SCM+Plugin>`_
The job the workspace is cloned from must be configured with an
clone-workspace publisher
:arg str parent-job: The name of the parent job to clone the
workspace from.
:arg str criteria: Set the criteria to determine what build of the parent
project to use. Can be one of 'Any', 'Not Failed' or 'Successful'.
(default: Any)
Example:
.. literalinclude:: /../../tests/scm/fixtures/workspace001.yaml
"""
workspace = XML.SubElement(xml_parent, 'scm', {'class': 'hudson.plugins.'
'cloneworkspace.CloneWorkspaceSCM'})
XML.SubElement(workspace, 'parentJobName').text = str(
data.get('parent-job', ''))
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(workspace, 'criteria').text = criteria
class SCM(jenkins_jobs.modules.base.Base):
sequence = 30

View File

@ -148,6 +148,7 @@ jenkins_jobs.scm =
repo=jenkins_jobs.modules.scm:repo
svn=jenkins_jobs.modules.scm:svn
tfs=jenkins_jobs.modules.scm:tfs
workspace=jenkins_jobs.modules.scm:workspace
jenkins_jobs.triggers =
build-result=jenkins_jobs.modules.triggers:build_result
gerrit=jenkins_jobs.modules.triggers:gerrit

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<scm class="hudson.plugins.cloneworkspace.CloneWorkspaceSCM">
<parentJobName>my-upstream-job</parentJobName>
<criteria>Any</criteria>
</scm>
</project>

View File

@ -0,0 +1,4 @@
scm:
- workspace:
parent-job: my-upstream-job
criteria: Any