diff --git a/jenkins_jobs/modules/parameters.py b/jenkins_jobs/modules/parameters.py index f33196c04..c20784306 100644 --- a/jenkins_jobs/modules/parameters.py +++ b/jenkins_jobs/modules/parameters.py @@ -206,6 +206,38 @@ def validating_string_param(parser, xml_parent, data): 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. + `_ + + :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): sequence = 21 diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index 113b0a701..613912a8a 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -91,6 +91,50 @@ def git(self, xml_parent, data): 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): sequence = 30 diff --git a/setup.py b/setup.py index 99108941b..6a1be30e3 100644 --- a/setup.py +++ b/setup.py @@ -56,6 +56,7 @@ setup(name='jenkins_job_builder', 'choice=jenkins_jobs.modules.parameters:choice_param', 'validating-string=jenkins_jobs.modules.parameters:' 'validating_string_param', + 'svn-tags=jenkins_jobs.modules.parameters:svn_tags_param', ], 'jenkins_jobs.notifications': [ 'http=jenkins_jobs.modules.notifications:http_endpoint', @@ -77,6 +78,7 @@ setup(name='jenkins_job_builder', ], 'jenkins_jobs.scm': [ 'git=jenkins_jobs.modules.scm:git', + 'svn=jenkins_jobs.modules.scm:svn', ], 'jenkins_jobs.triggers': [ 'gerrit=jenkins_jobs.modules.triggers:gerrit',