Skip to content

Commit 0f38671

Browse files
committed
fix setbranch command for python2
1 parent f984c49 commit 0f38671

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

jenkins_cli/cli.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from __future__ import print_function
22
import os
3-
from time import time, sleep
3+
import sys
44
import datetime
5+
from time import time, sleep
56
import jenkins
67
import socket
78
from xml.etree import ElementTree
@@ -64,6 +65,10 @@ def get_jobs_legend():
6465
return legend
6566

6667

68+
def xml_to_string(root):
69+
return ElementTree.tostring(root, encoding=('unicode' if sys.version_info[0] == 3 else None))
70+
71+
6772
class CliException(Exception):
6873
pass
6974

@@ -192,7 +197,7 @@ def setbranch(self, args):
192197
scm_name, branch_node = self._get_scm_name_and_node(root)
193198
if branch_node is not None:
194199
branch_node.text = args.branch_name
195-
new_xml = ElementTree.tostring(root, encoding='unicode')
200+
new_xml = xml_to_string(root)
196201
self.jenkins.reconfig_job(job_name, new_xml)
197202
print('Done')
198203
else:

0 commit comments

Comments
 (0)