jenkins: jenkins_plugin code broken due to new -remoting cli change.

Cookbook version

5.0.0

Chef-client version

Chef: 12.19.36

Platform Details

root@ip-192-168-0-228:/home/rightscale/.chef# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.1 LTS
Release:        16.04
Codename:       xenial

Running in AWS.

Scenario:

Plugin installation fails, appears to be due to the cli update that isn’t based on remoting, announced today here: https://jenkins.io/blog/2017/04/26/security-advisory/

---- Begin output of "/usr/lib/jvm/java-8-openjdk-amd64/bin/java" -jar "/home/rightscale/.chef/local-mode-cache/cache/jenkins-cli.jar" -s http://localhost:8080 install-plugin /home/rightscale/.chef/local-mode-cache/cache/swarm-3.4.plugin -name swarm  ----
STDOUT: /home/rightscale/.chef/local-mode-cache/cache/swarm-3.4.plugin is neither a valid file, URL, nor a plugin artifact name in the update center
STDERR: ERROR: Error occurred, see previous output.

Steps to Reproduce:

Run jenkins_plugin code and get the error above.

Example:

jenkins_plugin 'swarm' do
  version node['rsc_jenkins']['swarm']['version']
  install_deps true
  notifies :restart, 'service[jenkins]', :immediately
end

Expected Result:

Plugin should be installed.

Actual Result:

Plugin install fails with error above instead of being installed.

It appears the -remoting option needs to be passed to the cli options in jenkins_plugin for this to now work:

 java -jar /home/rightscale/.chef/local-mode-cache/cache/jenkins-cli.jar -remoting -s http://localhost:8080  install-plugin /home/rightscale/.chef/local-mode-cache/cache/swarm-3.4.plugin -name swarm
Installing a plugin from local file: /home/rightscale/.chef/local-mode-cache/cache/swarm-3.4.plugin

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 19 (7 by maintainers)

Most upvoted comments

+1 Major issue for us.

5.0.1 seems to fix the issues with jenkins_plugin for me.

Version 5.0.1 does not fix this for me. I am unable to use the SSH protocol because Jenkins by default starts with SSH disabled so the SSH protocol causes errors when attempting to do anything.

I am trying to use the http protocol as the remoting protocol is deprecated and causes warnings.

Using the http protocol causes the same errors.

I’ve attempted to set the protocol to nil. This gives me:

           ================================================================================
           Error executing action `install` on resource 'jenkins_plugin[display-url-api]'
           ================================================================================

           Mixlib::ShellOut::ShellCommandFailed
           ------------------------------------
           Expected process to exit with [0], but received '5'
           ---- Begin output of "/usr/lib/jvm/java/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 install-plugin /tmp/kitchen/cache/display-url-api-2.0.plugin -name display-url-api  ----
           STDOUT: /tmp/kitchen/cache/display-url-api-2.0.plugin is neither a valid file, URL, nor a plugin artifact name in the update center
           STDERR: ERROR: Error occurred, see previous output.
           May 11, 2017 3:57:16 PM hudson.cli.CLI$5 run
           WARNING: null
           java.io.IOException: Stream is closed
                at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError(HttpURLConnection.java:3512)
                at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:3486)
                at java.io.DataOutputStream.writeInt(DataOutputStream.java:197)
                at hudson.cli.PlainCLIProtocol$EitherSide.send(PlainCLIProtocol.java:175)
                at hudson.cli.PlainCLIProtocol$ClientSide.sendEndStdin(PlainCLIProtocol.java:347)
                at hudson.cli.CLI$5.run(CLI.java:671)
           ---- End output of "/usr/lib/jvm/java/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 install-plugin /tmp/kitchen/cache/display-url-api-2.0.plugin -name display-url-api  ----
           Ran "/usr/lib/jvm/java/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 install-plugin /tmp/kitchen/cache/display-url-api-2.0.plugin -name display-url-api  returned 5

           Cookbook Trace:
           ---------------
           /tmp/kitchen/cache/cookbooks/jenkins/libraries/_executor.rb:87:in `execute!'
           /tmp/kitchen/cache/cookbooks/jenkins/libraries/plugin.rb:317:in `install_plugin_from_url'
           /tmp/kitchen/cache/cookbooks/jenkins/libraries/plugin.rb:289:in `install_plugin_from_update_center'
           /tmp/kitchen/cache/cookbooks/jenkins/libraries/plugin.rb:124:in `block (2 levels) in <class:JenkinsPlugin>'
           /tmp/kitchen/cache/cookbooks/jenkins/libraries/plugin.rb:154:in `block in <class:JenkinsPlugin>'

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/owi_jenkins/recipes/plugins.rb

            17:   jenkins_plugin plugin do
            18:     version version if version
            19:     notifies :restart, 'service[jenkins]', :delayed
            20:   end
            21: end

@daften I haven’t tried that but I bet it will work.