install_plugin api throwing array index out of bound exception
Bug #1806381 reported by
rohan
This bug affects 2 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python Jenkins |
In Progress
|
Undecided
|
Kazuhiro Suzuki |
Bug Description
I am using python jenkins api for automation purpose.
following is sample code snippet.
server=
server.
error-
response = response_
IndexError: list index out of range
the response_str is actually ')]}'.
Changed in python-jenkins: | |
assignee: | nobody → rohan (rvadje) |
information type: | Public → Public Security |
information type: | Public Security → Public |
To post a comment you must log in.
I'm not sure how this ever worked, but the issue is that the code expects that Jenkins will return a string like "Result: <bool>" where the boolean is the result of the call to check whether a restart is needed. However, the Groovy script run for this neither gathers the result or prints it in the format expected. I guess maybe old versions of Jenkins took a boolean result of the script itself and printed "Result: <script result>".
The following patch seems to work for me:
--- __init__.py.orig 2019-04-04 10:13:50.728569000 -0500
time. sleep(2) instance. updateCenter' iredForCompleti on()') instance. updateCenter' iredForCompleti on();'
+++ __init__.py 2019-04-10 17:12:28.505247839 -0500
@@ -1347,8 +1347,9 @@
# run_script is an async call to run groovy. we need to wait a little
# before we can get a reliable response on whether a restart is needed
- is_restart_required = ('Jenkins.
- '.isRestartRequ
+ is_restart_required = ('boolean reboot = Jenkins.
+ '.isRestartRequ
+ 'println "Result: ${reboot}"')
# response is a string (i.e. u'Result: true\n'), return a bool instead
response_ str = self.run_ script( is_restart_ required)
However, since we're managing the returned string ourselves, it might be better to use JSON or something.