Source: jenkins-job-builder Version: 1.4.0-1 Severity: normal Tags: fixed-upstream patch
I work with someone who cares about correct Unicode typography, including in the output of the scripts we !include into Jenkins jobs. Unfortunately, jenkins-job-builder 1.4 doesn't appear to be fully Unicode-clean: if the (scripts !include'd into the) job I am replacing contains non-ASCII, python2-jenkins-job-builder crashes with return hashlib.md5(xml).hexdigest() UnicodeEncodeError: 'ascii' codec can't encode character u'\xb4' in position 2967: ordinal not in range (128) while python3-jenkins-job-builder crashes with a different exception: return hashlib.md5(xml).hexdigest() TypeError: Unicode-objects must be encoded before hashing This upstream commit seems to be the right solution: https://git.openstack.org/cgit/openstack-infra/jenkins-job-builder/commit/?id=aa3bf5cc195b1e36e5aa8eda2cd7bfc4f192a0d9 Please consider applying the patch, or updating to an upstream release >= 1.5.0 to get it included. Thanks, S
>From aa3bf5cc195b1e36e5aa8eda2cd7bfc4f192a0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20L=C3=B6fgren?= <joakim.lofg...@gmail.com> Date: Mon, 22 Feb 2016 12:50:47 +0100 Subject: Fix issue with non-ascii characters in get_job_md5 The xml string needs to be encoded to utf-8 before passing it to the hash function. Change-Id: I4b6ca7ef459b48a2ba56f788fe37307ee381ced4 Story: 2000488 --- jenkins_jobs/builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins_jobs/builder.py b/jenkins_jobs/builder.py index 6e257bb..28901b5 100644 --- a/jenkins_jobs/builder.py +++ b/jenkins_jobs/builder.py @@ -158,7 +158,7 @@ class Jenkins(object): def get_job_md5(self, job_name): xml = self.jenkins.get_job_config(job_name) - return hashlib.md5(xml).hexdigest() + return hashlib.md5(xml.encode('utf-8')).hexdigest() def delete_job(self, job_name): if self.is_job(job_name): -- cgit v0.12