From 4e64f0f88098b8648709be43b83f99be1e8c6135 Mon Sep 17 00:00:00 2001 From: Richard Felkl Date: Tue, 10 Jul 2018 13:44:27 +0200 Subject: [PATCH] Fix run_script method. Existing code assumes the script sent by the user is terminated with a newline. Appending magic string without '\n' before print() command results in a syntactically incorrect Groovy code. This patch ensures that '\n' is added between user's provided script and appended magic string. Change-Id: I39021f1058e7434d487efb4bc7aca18416b2c08e --- jenkins/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jenkins/__init__.py b/jenkins/__init__.py index a027729..b881e7a 100755 --- a/jenkins/__init__.py +++ b/jenkins/__init__.py @@ -1299,8 +1299,8 @@ class Jenkins(object): Plugin:maven-plugin, Plugin:pam-auth]' ''' magic_str = ')]}.' - print_magic_str = 'println()\nprint("{}")'.format(magic_str) - data = {'script': script.encode('utf-8') + print_magic_str.encode('utf-8')} + print_magic_str = 'print("{}")'.format(magic_str) + data = {'script': "{0}\n{1}".format(script, print_magic_str).encode('utf-8')} if node: url = self._build_url(NODE_SCRIPT_TEXT, locals()) else: