Fix multibyte character problem
Fixed problem that causes a UnicodeEncodeError when use multi-byte characters in the job.yml. Change-Id: Ie715c827a794e73fae11cdca079ea80cfb8c280d
This commit is contained in:
parent
777a29aa8a
commit
604d39305b
@ -381,7 +381,7 @@ class XmlJob(object):
|
||||
|
||||
def output(self):
|
||||
out = minidom.parseString(XML.tostring(self.xml))
|
||||
out = out.toprettyxml(indent=' ')
|
||||
out = out.toprettyxml(indent=' ', encoding='utf-8')
|
||||
return self.pretty_text_re.sub('>\g<1></', out)
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import codecs
|
||||
import os
|
||||
import re
|
||||
import doctest
|
||||
@ -61,7 +62,7 @@ class BaseTestCase(object):
|
||||
def __read_content(self):
|
||||
# Read XML content, assuming it is unicode encoded
|
||||
xml_filepath = os.path.join(self.fixtures_path, self.xml_filename)
|
||||
xml_content = u"%s" % open(xml_filepath, 'r').read()
|
||||
xml_content = u"%s" % codecs.open(xml_filepath, 'r', 'utf-8').read()
|
||||
|
||||
yaml_filepath = os.path.join(self.fixtures_path, self.yaml_filename)
|
||||
with file(yaml_filepath, 'r') as yaml_file:
|
||||
@ -83,7 +84,8 @@ class BaseTestCase(object):
|
||||
pub.gen_xml(parser, xml_project, yaml_content)
|
||||
|
||||
# Prettify generated XML
|
||||
pretty_xml = XmlJob(xml_project, 'fixturejob').output()
|
||||
pretty_xml = unicode(XmlJob(xml_project, 'fixturejob').output(),
|
||||
'utf-8')
|
||||
|
||||
self.assertThat(
|
||||
pretty_xml,
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<hudson.tasks.Maven>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<hudson.tasks.Maven>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<hudson.plugins.parameterizedtrigger.TriggerBuilder>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<com.tikal.hudson.plugins.notification.HudsonNotificationProperty>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<hudson.plugins.batch__task.BatchTaskProperty>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<hudson.plugins.throttleconcurrents.ThrottleJobProperty>
|
||||
|
@ -10,5 +10,5 @@ Each yaml file MUST have a corresponding xml file.
|
||||
|
||||
Once the YAML file has been parsed, it is prettify using python minidom
|
||||
which also means that:
|
||||
- your XML file must start with: <?xml version="1.0" ?>
|
||||
- your XML file must start with: <?xml version="1.0" encoding="utf-8"?>
|
||||
- self closing elements do not contains space eg: <element/>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.tasks.ArtifactArchiver>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.blame__upstream__commiters.BlameUpstreamCommitersPublisher/>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.build__publisher.BuildPublisher>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<org.jenkinsci.plugins.cloverphp.CloverPHPPublisher>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<org.jenkinsci.plugins.cloverphp.CloverPHPPublisher>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<org.jenkinsci.plugins.cloverphp.CloverPHPPublisher>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.descriptionsetter.DescriptionSetterPublisher>
|
12
tests/publishers/fixtures/description-setter002.xml
Normal file
12
tests/publishers/fixtures/description-setter002.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.descriptionsetter.DescriptionSetterPublisher>
|
||||
<regexp>.*(<a href=.*a>)</regexp>
|
||||
<regexpForFailed>.*(<a href=.*a>)</regexpForFailed>
|
||||
<description>こんにちは</description>
|
||||
<descriptionForFailed>さようなら</descriptionForFailed>
|
||||
<setForMatrix>true</setForMatrix>
|
||||
</hudson.plugins.descriptionsetter.DescriptionSetterPublisher>
|
||||
</publishers>
|
||||
</project>
|
7
tests/publishers/fixtures/description-setter002.yaml
Normal file
7
tests/publishers/fixtures/description-setter002.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
publishers:
|
||||
- description-setter:
|
||||
regexp: ".*(<a href=.*a>)"
|
||||
regexp-for-failed: ".*(<a href=.*a>)"
|
||||
description: "こんにちは"
|
||||
description-for-failed: "さようなら"
|
||||
set-for-matrix: true
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<org.jenkinsci.plugins.emotional__jenkins.EmotionalJenkinsPublisher/>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.git.GitPublisher>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<com.cloudbees.jenkins.GitHubCommitNotifier/>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.maven.RedeployPublisher>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<au.com.centrumsystems.hudson.plugin.buildpipeline.trigger.BuildPipelineTrigger>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<au.com.centrumsystems.hudson.plugin.buildpipeline.trigger.BuildPipelineTrigger>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.plot.PlotPublisher>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.plot.PlotPublisher>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.plot.PlotPublisher>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<be.certipost.hudson.plugin.SCPRepositoryPublisher>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<org.jenkinsci.plugins.stashNotifier.StashNotifier>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<xunit>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<scm class="hudson.plugins.git.GitSCM">
|
||||
<configVersion>2</configVersion>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<scm class="hudson.plugins.git.GitSCM">
|
||||
<configVersion>2</configVersion>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<scm class="hudson.plugins.git.GitSCM">
|
||||
<configVersion>2</configVersion>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<scm class="hudson.plugins.git.GitSCM">
|
||||
<configVersion>2</configVersion>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<scm class="hudson.plugins.repo.RepoScm">
|
||||
<manifestRepositoryUrl>https://example.com/project/</manifestRepositoryUrl>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<triggers class="vector">
|
||||
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<triggers class="vector">
|
||||
<org.jenkinsci.plugins.ghprb.GhprbTrigger>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<buildWrappers>
|
||||
<hudson.plugins.envfile.EnvFileBuildWrapper>
|
||||
|
Loading…
Reference in New Issue
Block a user