Adding ability to checkout from subversion and use the list tags parameter with the parameterized build plugin
Change-Id: Iad9c60d052c85bfb60794e6d2a9d80a915e7d1a8 Reviewed-on: https://review.openstack.org/14675 Reviewed-by: Clark Boylan <clark.boylan@gmail.com> Approved: James E. Blair <corvus@inaugust.com> Reviewed-by: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
This commit is contained in:
parent
a9e2a2bd9b
commit
156c4990f9
@ -206,6 +206,38 @@ def validating_string_param(parser, xml_parent, data):
|
|||||||
XML.SubElement(pdef, 'failedValidationMessage').text = data['msg']
|
XML.SubElement(pdef, 'failedValidationMessage').text = data['msg']
|
||||||
|
|
||||||
|
|
||||||
|
def svn_tags_param(parser, xml_parent, data):
|
||||||
|
"""yaml: svn-tags
|
||||||
|
A svn tag parameter
|
||||||
|
Requires the Jenkins `Parameterized Trigger Plugin.
|
||||||
|
<https://wiki.jenkins-ci.org/display/JENKINS/
|
||||||
|
Parameterized+Trigger+Plugin>`_
|
||||||
|
|
||||||
|
:arg str name: the name of the parameter
|
||||||
|
:arg str default: the default value of the parameter (optional)
|
||||||
|
:arg str description: a description of the parameter (optional)
|
||||||
|
:arg str url: the url to list tags from
|
||||||
|
:arg str filter: the regular expression to filter tags
|
||||||
|
|
||||||
|
Example::
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
- svn-tags:
|
||||||
|
name: BRANCH_NAME
|
||||||
|
default: release
|
||||||
|
description: A parameter named BRANCH_NAME default is release
|
||||||
|
url: http://svn.example.com/repo
|
||||||
|
filter: [A-za-z0-9]*
|
||||||
|
"""
|
||||||
|
pdef = base_param(parser, xml_parent, data, True,
|
||||||
|
'hudson.scm.listtagsparameter.ListSubversionTagsParameterDefinition')
|
||||||
|
XML.SubElement(pdef, 'tagsDir').text = data['url']
|
||||||
|
XML.SubElement(pdef, 'tagsFilter').text = data.get('filter', None)
|
||||||
|
XML.SubElement(pdef, 'reverseByDate').text = "true"
|
||||||
|
XML.SubElement(pdef, 'reverseByName').text = "false"
|
||||||
|
XML.SubElement(pdef, 'maxTags').text = "100"
|
||||||
|
|
||||||
|
|
||||||
class Parameters(jenkins_jobs.modules.base.Base):
|
class Parameters(jenkins_jobs.modules.base.Base):
|
||||||
sequence = 21
|
sequence = 21
|
||||||
|
|
||||||
|
@ -91,6 +91,50 @@ def git(self, xml_parent, data):
|
|||||||
XML.SubElement(scm, 'scmName')
|
XML.SubElement(scm, 'scmName')
|
||||||
|
|
||||||
|
|
||||||
|
def svn(self, xml_parent, data):
|
||||||
|
"""yaml: svn
|
||||||
|
Specifies the svn SCM repository for this job.
|
||||||
|
|
||||||
|
:arg str url: URL of the svn repository
|
||||||
|
:arg str basedir: location relative to the workspace root to checkout to
|
||||||
|
:arg str workspaceupdater: optional argument to specify
|
||||||
|
how to update the workspace
|
||||||
|
|
||||||
|
:workspaceupdater values:
|
||||||
|
:wipeworkspace: - deletes the workspace before checking out
|
||||||
|
:revertupdate: - do an svn revert then an svn update
|
||||||
|
:emulateclean: - delete unversioned/ignored files then update
|
||||||
|
:update: - do an svn update as much as possible
|
||||||
|
|
||||||
|
Example::
|
||||||
|
|
||||||
|
scm:
|
||||||
|
- svn:
|
||||||
|
url: http://svn.example.com/repo
|
||||||
|
basedir: .
|
||||||
|
workspaceupdater: update
|
||||||
|
"""
|
||||||
|
|
||||||
|
scm = XML.SubElement(xml_parent, 'scm', {'class':
|
||||||
|
'hudson.scm.SubversionSCM'})
|
||||||
|
locations = XML.SubElement(scm, 'locations')
|
||||||
|
module = XML.SubElement(locations,
|
||||||
|
'hudson.scm.SubversionSCM_-ModuleLocation')
|
||||||
|
XML.SubElement(module, 'remote').text = data['url']
|
||||||
|
XML.SubElement(module, 'local').text = data['basedir']
|
||||||
|
updater = data.get('workspaceupdater', 'wipeworkspace')
|
||||||
|
if updater == 'wipeworkspace':
|
||||||
|
updaterclass = 'CheckoutUpdater'
|
||||||
|
elif updater == 'revertupdate':
|
||||||
|
updaterclass = 'UpdateWithRevertUpdater'
|
||||||
|
elif updater == 'emulateclean':
|
||||||
|
updaterclass = 'UpdateWithCleanUpdater'
|
||||||
|
elif updater == 'update':
|
||||||
|
updaterclass = 'UpdateUpdater'
|
||||||
|
XML.SubElement(scm, 'workspaceUpdater', {'class':
|
||||||
|
'hudson.scm.subversion.' + updaterclass})
|
||||||
|
|
||||||
|
|
||||||
class SCM(jenkins_jobs.modules.base.Base):
|
class SCM(jenkins_jobs.modules.base.Base):
|
||||||
sequence = 30
|
sequence = 30
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -56,6 +56,7 @@ setup(name='jenkins_job_builder',
|
|||||||
'choice=jenkins_jobs.modules.parameters:choice_param',
|
'choice=jenkins_jobs.modules.parameters:choice_param',
|
||||||
'validating-string=jenkins_jobs.modules.parameters:'
|
'validating-string=jenkins_jobs.modules.parameters:'
|
||||||
'validating_string_param',
|
'validating_string_param',
|
||||||
|
'svn-tags=jenkins_jobs.modules.parameters:svn_tags_param',
|
||||||
],
|
],
|
||||||
'jenkins_jobs.notifications': [
|
'jenkins_jobs.notifications': [
|
||||||
'http=jenkins_jobs.modules.notifications:http_endpoint',
|
'http=jenkins_jobs.modules.notifications:http_endpoint',
|
||||||
@ -77,6 +78,7 @@ setup(name='jenkins_job_builder',
|
|||||||
],
|
],
|
||||||
'jenkins_jobs.scm': [
|
'jenkins_jobs.scm': [
|
||||||
'git=jenkins_jobs.modules.scm:git',
|
'git=jenkins_jobs.modules.scm:git',
|
||||||
|
'svn=jenkins_jobs.modules.scm:svn',
|
||||||
],
|
],
|
||||||
'jenkins_jobs.triggers': [
|
'jenkins_jobs.triggers': [
|
||||||
'gerrit=jenkins_jobs.modules.triggers:gerrit',
|
'gerrit=jenkins_jobs.modules.triggers:gerrit',
|
||||||
|
Loading…
Reference in New Issue
Block a user