Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jenkins_plugin code broken due to new -remoting cli change. #602

Closed
stefhen opened this issue Apr 26, 2017 · 19 comments
Closed

jenkins_plugin code broken due to new -remoting cli change. #602

stefhen opened this issue Apr 26, 2017 · 19 comments

Comments

@stefhen
Copy link

stefhen commented Apr 26, 2017

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
@bflad
Copy link

bflad commented Apr 26, 2017

Also seeing this issue. Its probably worth mentioning that its not possible to install an older version of Jenkins because the apt repository only has the latest version.

@daften
Copy link
Contributor

daften commented Apr 27, 2017

Related to #599

@kbaltrinic
Copy link

+1 Major issue for us.

@jayhendren
Copy link

Does anybody know of a workaround for this issue?

I've tried downgrading the jenkins cookbook to < 5.0.0, which doesn't seem to have any effect, and I've tried the following as suggested in the OP:

jenkins_plugin 'plugin_name' do
  options '-remoting'
end

which just gives me:

================================================================================
Error executing action `install` on resource 'jenkins_plugin[ansicolor]'
================================================================================

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '2'
---- 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/ansicolor-0.5.0.plugin -name ansicolor -remoting ----
STDOUT: 
STDERR: ERROR: "-remoting" is not a valid option
java -jar jenkins-cli.jar install-plugin SOURCE ... [-deploy] [-name VAL] [-restart]
Installs a plugin either from a file, an URL, or from update center. 
 SOURCE    : If this points to a local file (‘-remoting’ mode only), that file
      will be installed. If this is an URL, Jenkins downloads the URL
      and installs that as a plugin. If it is the string ‘=’, the file
      will be read from standard input of the command, and ‘-name’ must
      be specified. Otherwise the name is assumed to be the short name
      of the plugin in the existing update center (like ‘findbugs’), and
      the plugin will be installed from the update center.
 -deploy   : Deploy plugins right away without postponing them until the reboot.
 -name VAL : If specified, the plugin will be installed as this short name
      (whereas normally the name is inferred from the source name
      automatically).
 -restart  : Restart Jenkins upon successful installation.
---- 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/ansicolor-0.5.0.plugin -name ansicolor -remoting ----
Ran "/usr/lib/jvm/java/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 install-plugin /tmp/kitchen/cache/ansicolor-0.5.0.plugin -name ansicolor -remoting returned 2

Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/jenkins/libraries/_executor.rb:85: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/cub_jenkins/recipes/default.rb

 61:   jenkins_plugin(p) { options '-remoting' }
 62: end

Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/cub_jenkins/recipes/default.rb:61:in `block in from_file'

jenkins_plugin("ansicolor") do
  action [:install]
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  declared_type :jenkins_plugin
  cookbook_name "cub_jenkins"
  recipe_name "default"
  options "-remoting"
end

Platform:
---------
x86_64-linux

Platform is RHEL 7.3.

@charlottestjohn
Copy link

Blocked on upgrading past Jenkins 2.53 based off of this issue.

@daften
Copy link
Contributor

daften commented May 1, 2017

@Poohblah Look at #603 for a fix

@iennae
Copy link
Contributor

iennae commented May 2, 2017

Thanks for the PR folks. Please check to see if cookbook version 5.0.1 resolves this issue for you.

@oberones
Copy link

oberones commented May 3, 2017

5.0.1 actually causes this issue for me. I've had to pin my cookbooks to 5.0.0 for now.

@daften
Copy link
Contributor

daften commented May 3, 2017

@oberones What version of jenkins are you on?

@oberones
Copy link

oberones commented May 3, 2017

@daften I'm using 2.32.1, which does not have the remoting option available in the cli.

@daften
Copy link
Contributor

daften commented May 3, 2017

@oberones have you tried putting executor['protocol'] to nil by overriding it in a wrapper cookbook, environment, ...? That should disable the -remoting option

@jayhendren
Copy link

5.0.1 seems to fix the issues with jenkins_plugin for me.

@oberones
Copy link

oberones commented May 3, 2017

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

@isuftin
Copy link

isuftin commented May 11, 2017

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

@isuftin
Copy link

isuftin commented May 11, 2017

If I manually add file:// to the path when logged into the VM:

"/usr/lib/jvm/java/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 -"http" install-plugin file:///tmp/kitchen/cache/display-url-api-2.0.plugin -name display-url-api
Installing a plugin from file:/tmp/kitchen/cache/display-url-api-2.0.plugin

... this works fine. so it seems like Jenkins does not see a direct filepath without file:// as a valid URI

I've created two issues around this:

#613

#614

@iennae
Copy link
Contributor

iennae commented Jun 1, 2017

@stefhen can you update the title of this issue to reflect the problem that you are seeing rather than ascribing to remoting option being added? I think there are some conflicting reports being added to this and it's hard to track down what is broken/fixed for folks. I think the file:// issue that was pulled in today will fix your issue but I don't want to assume. Based on the change, then I can start asking folks who still have problems to separate out their issues rather than trying to solve everything about plugin installation in this issue (because plugin installation is a big problem that isn't going to be solved in one big change). Thanks!

@stefhen
Copy link
Author

stefhen commented Jun 1, 2017

Hi @iennae This was actually fixed in 5.0.1 and can be closed. https://github.com/chef-cookbooks/jenkins/blob/v5.0.1/CHANGELOG.md#501-2017-05-01

@iennae
Copy link
Contributor

iennae commented Jun 1, 2017

Thanks for updating @stefhen. For folks still having issues, please verify that a different issue hasn't already been created. If not, create a new issue so that we can make sure to track the specific changes required. Plugin installation is complex and we are working to do a rehaul on this completely.

@iennae iennae closed this as completed Jun 1, 2017
@tknerr
Copy link

tknerr commented Jul 25, 2017

Even with -remoting being the explicit default now, it doesn't work with Jenkins 2.60.1 and newer, because the remoting CLI is disabled by default, and needs to be re-enabled.

See my comment here:
#603 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests