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                                   
                                                                            
                                                                            
            
hudson.util.IOException2: Failed to download from 
http://updates.jenkins-ci.org/download/plugins/display-url-api/0.5/display-url-api.hpi
 
(redirected to: 
http://ftp.icm.edu.pl/packages/jenkins/plugins/display-url-api/0.5/display-url-api.hpi)
        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

[0] https://github.com/rgl/jenkins-vagrant/blob/master/provision.sh#L214

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/01fbee06-fd41-4626-be31-5c6a10357fef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to