Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-10057

install-plugin CLI does not indicate failures & return code 0

XMLWordPrintable

      Hi,

      I am trying to script installation of plugins on a jenkins instance, in the best case scenario, my script works as expected; but if there are any failures, then from the CLI we get no information, we don't even the install-plugin command failed. This makes it very hard to automate reliably.

      /tmp # java -jar jenkins-cli.jar -s http://localhost:8080/jenkins install-plugin violations
      Installing violations from update center
      tmp # echo $?
      0

      if I go to the update center through the GUI, then:
      1) I can see it failed
      2) I get a hint that my proxy settings are wrong
      3) I get some stack trace

      java.net.ConnectException: Connection timed out
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1491)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1485)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1139)
      at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:566)
      at hudson.model.UpdateCenter$DownloadJob._run(UpdateCenter.java:849)
      at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:957)
      at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:832)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
      Caused by: java.net.ConnectException: Connection timed out
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
      at java.net.Socket.connect(Socket.java:529)
      at java.net.Socket.connect(Socket.java:478)
      at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
      at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
      at sun.net.www.http.HttpClient.New(HttpClient.java:306)
      at sun.net.www.http.HttpClient.New(HttpClient.java:323)
      at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
      at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)
      at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2304)
      at java.net.URLConnection.getHeaderFieldInt(URLConnection.java:579)
      at java.net.URLConnection.getContentLength(URLConnection.java:474)
      at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:565)
      ... 9 more

      chat log:

      [02:56:14] <damien___> hi
      [02:56:49] <damien___> I have a problem with the cli, I've looked through the open bugs and I'm not sure the issue is already mentioned
      [02:57:04] <damien___> I do 'java -jar ... install-plugin foobar'
      [02:57:29] <damien___> then it says "Installing foobar from update center"
      [02:57:42] <damien___> but that actually fails because of proxy issues
      [02:57:48] <damien___> cli doesn't complain
      [02:57:56] <damien___> and cli returns 0 as return code
      [02:58:04] <jenkinsci_builds> Starting build 897 for job jenkins_main_trunk (previous build: SUCCESS)
      [03:00:37] *** sshaw has joined #jenkins
      [03:03:15] *** geronimo_ has quit IRC
      [03:03:48] <kohsuke> damien___: good point. I think it's because CLI doesn't actually wait for the completion of the installation
      [03:03:52] <kohsuke> It just submits the job and then returns
      [03:04:05] <damien___> okay
      [03:04:20] <damien___> so these cannot be automated safely as of now
      [03:05:00] <damien___> thanks, I will submit a bug report tomorrow morning
      [03:05:10] <kohsuke> thank you
      [03:05:18] <damien___> I think I have a scenario to repro
      [03:05:39] <damien___> (in my case fails when no proxy set, so it should fail all the time if a bad proxy is set)
      [03:06:06] <damien___> thanks
      [03:06:13] *** damien___ has quit IRC

      to reproduce:
      1) set your proxy settings to something you expect not to work.
      2) cli command install-plugin violations (or any existing plugin)

            Unassigned Unassigned
            dnozay Damien Nozay
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: