hipchat_notif: Fix compatibility dispatch
This fixes the following error message that is produced when using the old hipchat module in a real world scenario (as opposed to a synthetic test): jenkins_jobs.errors.JenkinsJobsException: Unknown entry point or macro 'name' for component type: 'publisher'. It works in the tests/hipchat/fixtures/hipchat005.yaml test because the `data` dict contains only the 'hipchat' key, but when used in a job-template, the dict contains a lot more, e.g. 'name', 'project-type', 'description' etc. To make testing more difficult, `data` is not an OrderedDict, but dict (see YamlParser._applyDefaults), so it behaves differently across python versions, due to different order of dict.items (hash randomization, ...). Therefore the test contains seemingly unnecessary fields like 'project-type', 'scm' and 'description'. Without these, it would pass without the fix on at least one of py27, py35, py36, and it's rather likely I haven't covered all possible scenarios (different platforms?). Change-Id: Ie45084f1a4d6405d7e60dde5fce619a66dc026db
This commit is contained in:
parent
f30179db4a
commit
cd651c4b80
@ -145,7 +145,8 @@ class HipChat(jenkins_jobs.modules.base.Base):
|
||||
"'hipchat' module supports the old plugin versions <1.9, "
|
||||
"newer versions are supported via the 'publishers' module. "
|
||||
"Please upgrade you job definition")
|
||||
return self.registry.dispatch('publisher', publishers, data)
|
||||
component = {'hipchat': hipchat}
|
||||
return self.registry.dispatch('publisher', publishers, component)
|
||||
else:
|
||||
properties = xml_parent.find('properties')
|
||||
if properties is None:
|
||||
|
3
tests/yamlparser/fixtures/hipchat1.plugins_info.yaml
Normal file
3
tests/yamlparser/fixtures/hipchat1.plugins_info.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
- longName: 'Jenkins HipChat Plugin'
|
||||
shortName: 'hipchat'
|
||||
version: "2.1.1"
|
27
tests/yamlparser/fixtures/hipchat1.xml
Normal file
27
tests/yamlparser/fixtures/hipchat1.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description>desc<!-- 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/>
|
||||
<publishers>
|
||||
<jenkins.plugins.hipchat.HipChatNotifier>
|
||||
<token/>
|
||||
<room>room1</room>
|
||||
<startNotification>true</startNotification>
|
||||
<notifySuccess>false</notifySuccess>
|
||||
<notifyAborted>false</notifyAborted>
|
||||
<notifyNotBuilt>false</notifyNotBuilt>
|
||||
<notifyUnstable>false</notifyUnstable>
|
||||
<notifyFailure>false</notifyFailure>
|
||||
<notifyBackToNormal>false</notifyBackToNormal>
|
||||
</jenkins.plugins.hipchat.HipChatNotifier>
|
||||
</publishers>
|
||||
<buildWrappers/>
|
||||
</project>
|
17
tests/yamlparser/fixtures/hipchat1.yaml
Normal file
17
tests/yamlparser/fixtures/hipchat1.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
- defaults:
|
||||
name: global
|
||||
project-type: freestyle
|
||||
description: desc
|
||||
|
||||
- project:
|
||||
name: hipchat1
|
||||
jobs:
|
||||
- 'hipchat1-tpl'
|
||||
|
||||
- job-template:
|
||||
name: 'hipchat1-tpl'
|
||||
scm: []
|
||||
hipchat:
|
||||
enabled: true
|
||||
rooms: [room1]
|
||||
notify-start: true
|
Loading…
Reference in New Issue
Block a user