I'm having a hard time trying to reliably install plugins from an shell script. I'm trying this at [0]:
but it randomly fails at different places while downloading the plugin .hpi files, which is quite frustrating... e.g.: this time it happened with display-url-api.hpi:
SEVERE: Failed to install Display URL API
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1169)
at hudson.model.UpdateCenter$DownloadJob._run(UpdateCenter.java:1666)
at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:1864)
at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1640)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:110)
at java.lang.Thread.run(Thread.java:745)
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1142)
... 7 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
at sun.net.www.MeteredStream.read(MeteredStream.java:134)
at java.io.FilterInputStream.read(FilterInputStream.java:133)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3375)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3368)
at org.apache.commons.io.input.ProxyInputStream.read(ProxyInputStream.java:77)
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1137)
... 7 more
I'm also trying a different approach... using groovy:
function jgroovy {
jcli groovy "$@"
}
jgroovy = <<'EOF'import jenkins.model.Jenkins
updateCenter = Jenkins.instance.updateCenter
updateCenter.updateAllSites()
[
'git',
'powershell',
'xcode-plugin',
].each {
updateCenter.getPlugin(it).deploy()
}
// NB deploy is asynchronous. as such, without knowing much more about jenkins,
// just wait a bit and hope it had time to install them all...
sleep(3*60*1000)
Jenkins.instance.save()
Jenkins.instance.safeRestart()
EOF
# wait for the restart.
sleep $((5*60))
which is somewhat ugly with those sleep; and worse, it also randomly fails to download .hpi and install all the plugin and their dependencies. but I'm kinda lost in finding a reliable solution... can you help?