python-jenkins-developers team mailing list archive
-
python-jenkins-developers team
-
Mailing list archive
-
Message #00571
[Bug 1806381] Re: install_plugin api throwing array index out of bound exception
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
+++ __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
time.sleep(2)
- is_restart_required = ('Jenkins.instance.updateCenter'
- '.isRestartRequiredForCompletion()')
+ is_restart_required = ('boolean reboot = Jenkins.instance.updateCenter'
+ '.isRestartRequiredForCompletion();'
+ '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.
--
You received this bug notification because you are a member of Python
Jenkins Developers, which is subscribed to Python Jenkins.
https://bugs.launchpad.net/bugs/1806381
Title:
install_plugin api throwing array index out of bound exception
Status in Python Jenkins:
New
Bug description:
I am using python jenkins api for automation purpose.
following is sample code snippet.
server=jenkins.Jenkins('http://127.0.0.1', username='admin', password='admin')
server.install_plugin("windows-slaves")
error-
response = response_str.split(':')[1].strip().lower() == 'true'
IndexError: list index out of range
the response_str is actually ')]}'.
To manage notifications about this bug go to:
https://bugs.launchpad.net/python-jenkins/+bug/1806381/+subscriptions
References