Order component retrieval to favour user defined
Prefer user defined macros over inbuilt entry points, as JJB may accidentally use a name that has already been used by an end-user to define a custom macro. Warn users when they have a macro defined that masks an in-built component to avoid accidentally changing XML generated with new releases. Change-Id: I6cae62d7cc40be6c4a5636a74f151fcce4cdd856
This commit is contained in:
parent
449bb24f8f
commit
0cafeba626
@ -223,20 +223,24 @@ class ModuleRegistry(object):
|
||||
logger.debug("Cached entry point group %s = %s",
|
||||
component_list_type, eps)
|
||||
|
||||
if name in eps:
|
||||
# check for macro first
|
||||
component = parser.data.get(component_type, {}).get(name)
|
||||
if component:
|
||||
if name in eps:
|
||||
logger.warn("You have a macro ('%s') defined for '%s' "
|
||||
"component type that is masking an inbuilt "
|
||||
"definition" % (name, component_type))
|
||||
|
||||
for b in component[component_list_type]:
|
||||
# Pass component_data in as template data to this function
|
||||
# so that if the macro is invoked with arguments,
|
||||
# the arguments are interpolated into the real defn.
|
||||
self.dispatch(component_type,
|
||||
parser, xml_parent, b, component_data)
|
||||
elif name in eps:
|
||||
func = eps[name].load()
|
||||
func(parser, xml_parent, component_data)
|
||||
else:
|
||||
# Otherwise, see if it's defined as a macro
|
||||
component = parser.data.get(component_type, {}).get(name)
|
||||
if component:
|
||||
for b in component[component_list_type]:
|
||||
# Pass component_data in as template data to this function
|
||||
# so that if the macro is invoked with arguments,
|
||||
# the arguments are interpolated into the real defn.
|
||||
self.dispatch(component_type,
|
||||
parser, xml_parent, b, component_data)
|
||||
else:
|
||||
raise JenkinsJobsException("Unknown entry point or macro '{0}'"
|
||||
" for component type: '{1}'.".
|
||||
format(name, component_type))
|
||||
raise JenkinsJobsException("Unknown entry point or macro '{0}' "
|
||||
"for component type: '{1}'.".
|
||||
format(name, component_type))
|
||||
|
19
tests/yamlparser/fixtures/mask_internal_component.xml
Normal file
19
tests/yamlparser/fixtures/mask_internal_component.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description><!-- Managed by Jenkins Job Builder --></description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
<properties/>
|
||||
<scm class="hudson.scm.NullSCM"/>
|
||||
<builders>
|
||||
<hudson.tasks.Shell>
|
||||
<command>bash /opt/bin/run_python.sh</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
11
tests/yamlparser/fixtures/mask_internal_component.yaml
Normal file
11
tests/yamlparser/fixtures/mask_internal_component.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
- builder:
|
||||
name: python
|
||||
builders:
|
||||
- shell:
|
||||
bash {file}
|
||||
|
||||
- job:
|
||||
name: mask-internal-module
|
||||
builders:
|
||||
- python:
|
||||
file: '/opt/bin/run_python.sh'
|
Loading…
Reference in New Issue
Block a user