Skip to content

Commit 68b3d51

Browse files
committed
Fix interactive console output
The interactive console output command was returning one line less for each update. This was probably caused by Jenkins returning an extra newline at the end of each console output. This commit fixes this by replacing str.split by str.splitlines function. Note the difference between these two functions: >>> '\na\nb\nc\n'.split('\n') ['', 'a', 'b', 'c', ''] >>> '\na\nb\nc\n'.splitlines() ['', 'a', 'b', 'c']
1 parent b1a5965 commit 68b3d51

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

jenkins_cli/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def console(self, args):
294294
print("Cannot show console output. %(job_name)s has no builds" % {'job_name': job_name})
295295
else:
296296
console_out = self.jenkins.get_build_console_output(job_name, build_number)
297-
console_out = console_out.split('\n')
297+
console_out = console_out.splitlines()
298298
last_line_num = len(console_out)
299299
if args.n:
300300
console_out = console_out[args.n:] if args.n < 0 else console_out[:args.n]
@@ -303,7 +303,7 @@ def console(self, args):
303303
build_info = self.jenkins.get_build_info(job_name, build_number)
304304
while build_info['building']:
305305
console_out = self.jenkins.get_build_console_output(job_name, build_number)
306-
console_out = console_out.split('\n')
306+
console_out = console_out.splitlines()
307307
new_line_num = len(console_out)
308308
if new_line_num > last_line_num:
309309
print("\n".join(console_out[last_line_num:]))

0 commit comments

Comments
 (0)