how to reliably installing plugins?

90 views
Skip to first unread message

Rui Lopes

unread,
Nov 14, 2016, 6:21:19 PM11/14/16
to Jenkins Users
I'm having a hard time trying to reliably install plugins from an shell script. I'm trying this at [0]:

JCLI="java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080"

function jcli {
    $JCLI -noKeyAuth "$@"
}

jcli install-plugin git -deploy
jcli install-plugin powershell -deploy

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)                                                                                                                                                                                                
Caused by: java.io.IOException: Failed to load http://updates.jenkins-ci.org/download/plugins/display-url-api/0.5/display-url-api.hpi to /var/lib/jenkins/plugins/display-url-api.jpi.tmp                                                       
        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?

-- RGL

Rui Lopes

unread,
Nov 15, 2016, 2:09:38 PM11/15/16
to Jenkins Users
I was able to workaround this... https://github.com/rgl/jenkins-vagrant/commit/c032bdfcefee9472b1269f681844808287323356

Essentially, I had to keep reinstalling the plugins (and restarting jenkins) until their installation succeeded. If you have a better solution, please speak up!
Reply all
Reply to author
Forward
0 new messages