diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index cf83b4fed..daf0f6675 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -391,6 +391,19 @@ def svn(self, xml_parent, data): (default '.') :arg str workspaceupdater: optional argument to specify how to update the workspace (default wipeworkspace) + :arg list(str) excluded-users: list of users to ignore revisions from + when polling for changes (if polling is enabled; parameter is optional) + :arg list(str) included-regions: list of file/folders to include + (optional) + :arg list(str) excluded-regions: list of file/folders to exclude (optional) + :arg list(str) excluded-commit-messages: list of commit messages to exclude + (optional) + :arg str exclusion-revprop-name: revision svn-property to ignore (optional) + :arg bool ignore-property-changes-on-directories: ignore svn-property only + changes of directories (default false) + :arg bool filter-changelog: If set Jenkins will apply the same inclusion + and exclusion patterns for displaying changelog entries as it does for + polling for changes (default false) :arg list repos: list of repositories to checkout (optional) :Repo: * **url** (`str`) -- URL for the repository @@ -403,16 +416,13 @@ def svn(self, xml_parent, data): :emulateclean: - delete unversioned/ignored files then update :update: - do an svn update as much as possible - Example:: + Multiple repos example: - scm: - - svn: - workspaceupdater: update - repos: - - url: http://svn.example.com/repo - basedir: . - - url: http://svn.example.com/repo2 - basedir: repo2 + .. literalinclude:: /../../tests/scm/fixtures/svn-multiple-repos-001.yaml + + Advanced commit filtering example: + + .. literalinclude:: /../../tests/scm/fixtures/svn-regions-001.yaml """ scm = XML.SubElement(xml_parent, 'scm', {'class': 'hudson.scm.SubversionSCM'}) @@ -443,6 +453,33 @@ def svn(self, xml_parent, data): XML.SubElement(scm, 'workspaceUpdater', {'class': 'hudson.scm.subversion.' + updaterclass}) + mapping = [ + # option, xml name, default value + ("excluded-regions", 'excludedRegions', []), + ("included-regions", 'includedRegions', []), + ("excluded-users", 'excludedUsers', []), + ("exclusion-revprop-name", 'excludedRevprop', ''), + ("excluded-commit-messages", 'excludedCommitMessages', []), + ("ignore-property-changes-on-directories", 'ignoreDirPropChanges', + False), + ("filter-changelog", 'filterChangelog', False), + ] + + for optname, xmlname, defvalue in mapping: + if isinstance(defvalue, list): + val = '\n'.join(data.get(optname, defvalue)) + else: + val = data.get(optname, defvalue) + # Skip adding xml entry if default is empty and no value given + if not val and (defvalue in ['', []]): + continue + + xe = XML.SubElement(scm, xmlname) + if isinstance(defvalue, bool): + xe.text = str(val).lower() + else: + xe.text = str(val) + def tfs(self, xml_parent, data): """yaml: tfs diff --git a/tests/scm/fixtures/svn-multiple-repos-001.xml b/tests/scm/fixtures/svn-multiple-repos-001.xml new file mode 100644 index 000000000..e7bf2968b --- /dev/null +++ b/tests/scm/fixtures/svn-multiple-repos-001.xml @@ -0,0 +1,18 @@ + + + + + + http://svn.example.com/repo + . + + + http://svn.example.com/repo2 + repo2 + + + + false + false + + diff --git a/tests/scm/fixtures/svn-multiple-repos-001.yaml b/tests/scm/fixtures/svn-multiple-repos-001.yaml new file mode 100644 index 000000000..90b205f6b --- /dev/null +++ b/tests/scm/fixtures/svn-multiple-repos-001.yaml @@ -0,0 +1,8 @@ +scm: + - svn: + workspaceupdater: update + repos: + - url: http://svn.example.com/repo + basedir: . + - url: http://svn.example.com/repo2 + basedir: repo2 diff --git a/tests/scm/fixtures/svn-regions-001.xml b/tests/scm/fixtures/svn-regions-001.xml new file mode 100644 index 000000000..229a34a92 --- /dev/null +++ b/tests/scm/fixtures/svn-regions-001.xml @@ -0,0 +1,23 @@ + + + + + + http://svn.apache.org/repos/asf/spamassassin/trunk + . + + + + /region3/.*\.jpg +/region4 + /region1/.*\.cpp +/region2 + user1 +user2 + propname + test-msg +test-msg2 + true + true + + diff --git a/tests/scm/fixtures/svn-regions-001.yaml b/tests/scm/fixtures/svn-regions-001.yaml new file mode 100644 index 000000000..c8c21c1bb --- /dev/null +++ b/tests/scm/fixtures/svn-regions-001.yaml @@ -0,0 +1,19 @@ +scm: + - svn: + url: http://svn.apache.org/repos/asf/spamassassin/trunk + workspaceupdater: wipeworkspace + included-regions: + - /region1/.*\.cpp + - /region2 + excluded-regions: + - /region3/.*\.jpg + - /region4 + excluded-users: + - user1 + - user2 + excluded-commit-messages: + - test-msg + - test-msg2 + exclusion-revprop-name: propname + filter-changelog: true + ignore-property-changes-on-directories: true