Update Repo plugin to use convert_mapping_to_xml

- Update doc options to have default values
- Update mapping to use single quote syntax

Change-Id: I6d06f7120eaec81c785230dd524de0178be88c00
Signed-off-by: Kien Ha <kienha9922@gmail.com>
This commit is contained in:
Kien Ha 2016-07-13 02:16:15 -04:00
parent 12cab0e30f
commit a34bd67ef7
2 changed files with 28 additions and 43 deletions

View File

@ -611,19 +611,19 @@ def repo(parser, xml_parent, data):
Specifies the repo SCM repository for this job.
Requires the Jenkins :jenkins-wiki:`Repo Plugin <Repo+Plugin>`.
:arg str manifest-url: URL of the repo manifest
:arg str manifest-branch: The branch of the manifest to use (optional)
:arg str manifest-url: URL of the repo manifest (required)
:arg str manifest-branch: The branch of the manifest to use (default '')
:arg str manifest-file: Initial manifest file to use when initialising
(optional)
(default '')
:arg str manifest-group: Only retrieve those projects in the manifest
tagged with the provided group name (optional)
tagged with the provided group name (default '')
:arg list(str) ignore-projects: a list of projects in which changes would
not be considered to trigger a build when pooling (optional)
not be considered to trigger a build when pooling (default '')
:arg str destination-dir: Location relative to the workspace root to clone
under (optional)
:arg str repo-url: custom url to retrieve the repo application (optional)
under (default '')
:arg str repo-url: custom url to retrieve the repo application (default '')
:arg str mirror-dir: Path to mirror directory to reference when
initialising (optional)
initialising (default '')
:arg int jobs: Number of projects to fetch simultaneously (default 0)
:arg int depth: Specify the depth in history to sync from the source. The
default is to sync all of the history. Use 1 to just sync the most
@ -643,7 +643,7 @@ def repo(parser, xml_parent, data):
:arg bool show-all-changes: When this is checked --first-parent is no
longer passed to git log when determining changesets (default false)
:arg str local-manifest: Contents of .repo/local_manifest.xml, written
prior to calling sync (optional)
prior to calling sync (default '')
Example:
@ -653,43 +653,27 @@ def repo(parser, xml_parent, data):
scm = XML.SubElement(xml_parent,
'scm', {'class': 'hudson.plugins.repo.RepoScm'})
if 'manifest-url' in data:
XML.SubElement(scm, 'manifestRepositoryUrl').text = \
data['manifest-url']
else:
raise JenkinsJobsException("Must specify a manifest url")
mapping = [
# option, xml name, default value
("manifest-branch", 'manifestBranch', ''),
("manifest-file", 'manifestFile', ''),
("manifest-group", 'manifestGroup', ''),
("destination-dir", 'destinationDir', ''),
("repo-url", 'repoUrl', ''),
("mirror-dir", 'mirrorDir', ''),
("jobs", 'jobs', 0),
("depth", 'depth', 0),
("current-branch", 'currentBranch', True),
("reset-first", 'resetFirst', False),
("quiet", 'quiet', True),
("force-sync", 'forceSync', False),
("no-tags", 'noTags', False),
("trace", 'trace', False),
("show-all-changes", 'showAllChanges', False),
("local-manifest", 'localManifest', ''),
('manifest-url', 'manifestRepositoryUrl', None),
('manifest-branch', 'manifestBranch', ''),
('manifest-file', 'manifestFile', ''),
('manifest-group', 'manifestGroup', ''),
('destination-dir', 'destinationDir', ''),
('repo-url', 'repoUrl', ''),
('mirror-dir', 'mirrorDir', ''),
('jobs', 'jobs', 0),
('depth', 'depth', 0),
('current-branch', 'currentBranch', True),
('reset-first', 'resetFirst', False),
('quiet', 'quiet', True),
('force-sync', 'forceSync', False),
('no-tags', 'noTags', False),
('trace', 'trace', False),
('show-all-changes', 'showAllChanges', False),
('local-manifest', 'localManifest', ''),
]
for elem in mapping:
(optname, xmlname, val) = elem
val = data.get(optname, val)
# Skip adding xml entry if default is empty string and no value given
if not val and elem[2] is '':
continue
xe = XML.SubElement(scm, xmlname)
if type(elem[2]) == bool:
xe.text = str(val).lower()
else:
xe.text = str(val)
convert_mapping_to_xml(scm, data, mapping, fail_required=True)
# ignore-projects does not follow the same pattern of the other parameters,
# so process it here:

View File

@ -27,6 +27,7 @@
<noTags>false</noTags>
<trace>false</trace>
<showAllChanges>false</showAllChanges>
<localManifest/>
<ignoreProjects class="linked-hash-set">
<string/>
</ignoreProjects>