-
-
Notifications
You must be signed in to change notification settings - Fork 637
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
Add Jenkins 2.54 new cli options: -http, -ssh, -remoting to jenkins_script resource #599
Comments
Wanted to open similar issue. Same situation with jenkins cookbook 5.0.0 and CentOS (7.3) based environment (Masters and Slaves). Here's some additional info about changes in Jenkins 2.54: Here's my little research about problems that need to be addressed.
I hope that Jenkins Community will fix/work out this "requesting the deprecated -remoting mode"
I changed _helper.rb and _executor.rb libraries in my jenkins wrapper cookbook to support "protocol" (remoting/ssh/http) and "cli_user" (needed when ssh or http is used) - both as an option. Together with executor.rb attribute it works like before. BTW The Jenkins Community is planning to drop jenkins-cli.jar as a whole. There will be REST-like CLI in its place. CLI is crucial in the orchestration perspective so probably there will be more changes required in the jenkins cookbook in the nearest future. |
@p0d0l I've the same problem with |
@kannan4k Switch the jenkins-cli call to a REST API call |
@lioraspark We were using key based auth to manage the jobs. I hope REST api will not be applicable in that case right? |
@p0d0l Have you submitted that commit as a Pull request? ('Cause it looks good here.) |
For what its worth, this is affecting 2.46.2 users as well now. |
Partial fix for #599 add -remoting option
Hey folks, can you verify v 5.0.1 of the cookbook resolves your issue? |
v5.0.1 fixes it for me. |
I switched to use v5.0.1 jenkins cookbook on my production together with removed 'workaround' from my wrapper cookbook - it works. As to CLI commands that needed "remoting" (so ssh/http cannot be used):
I'm on Jenkins 2.58 and I no longer see such error for the "install-plugin" CLI command - it works. The CLI "groovy" command still has this error though. |
@p0d0l Agreed— the CLI "groovy" command is still failing here. It looks like other commands are working fine.
Bizarrely, I'm only seeing this under |
Calling |
Executing the command without |
@p0d0l And I don't know what's going down, but using I'm good here. |
Using v5.0.1 - Jenkins 2.46.2 I still have issue:
|
Hitting a totally different error: This error is related to issue: #590 My workaround was to add the next line to the jenkins wrapper cookbook (attributes file): |
the new cookbook version (5.0.1) worked for me |
I did some comparison of CLIs by manual triggering. Here are the results:
Executions of those CLIs against the Jenkins Master on localhost - in this example request about the Jenkins Master version (Master is 2.58 but it's not relevant right now and output is very short if successful):
"head -2", beacuse there's a whole "help" output after those two lines. So "-remoting" option is not understood and is read as CLI command + there's an additional SSH keys authentication failure. Same against CLI in 2.46.1 but without "-remoting"
@Dispader In your example the error suggests as "-remoting" was read as a CLI command and not a jar option. Are you sure that jenkins-cli.jar was from 2.46.2 (aka LTS) or 2.54+ (aka latest-greatest)? Because before those versions, jenkins-cli.jar did not have protocols in its options (just assumed the "remoting" as a default). In such case "-remoting" is read as a CLI command. Jenkins Community does not provide different contents of rpm packages for RHEL and CeonOS. Are you sure you had the same version of jenkins-cli.jar for war and non-war installation back then, during your tests? @StephenKing @Ali-karimkhani Maybe manually triggered jenkins-cli.jar would be more descriptive about the error. You could try:
@Ali-karimkhani do you have the same case as @StephenKing - when "remoting" is removed, it's working? Is it possible that your environment tirggered CLI comands with older jenkins-cli.jar? @lioramilbaum the v5.0.1 had some fixes in repositories area (pkg.jenkins.io: rpms, debs) to distinguish "stable" (aka LTS) vs "current" (aka latest-greatest). From the "stable" repositories, all newest non-LTS packages were moved to a separate URL. Probably a similar thing needs to be align with the "war" type installation like:
So jenkins cookbook should probably distinguish jenkins-cli.jar version or possible options to pass and add "-remoting" (or not) to support both old-way and new-way and to enable smooth transition between. Without "-remoting" passed to CLI you could not use newest versions of Jenkins Master and with "-remoting" passed to CLI you cannot use older versions. In other words - jenkins cookbook <=5.0.0 works with <2.46.2 and <2.54 and jenkins cookbook 5.0.1 works with >=2.46.2 and >=2.54. |
Well, to keep things simple and the story short - if you have Jenkins Master versions lower then 2.46.2 (LTS) and 2.54 (non-LTS) comment the:
in your executor.rb attributes. It will not pass such option as it's only passed if it's present... so no other changes for "distinguishing" versions is needed tbh. |
@p0d0l with -remoting
without
|
@p0d0l -remoting option doesnt seem to work fine for me as well.
Using -http option however seems to work for version.
However using -http option to install plugin isn't working as the URL passed is a local URL instead of HTTP URL.
If we manually run the command on the kitchen VM by passing a HTTP URL while using -http executor, it works fine:
Do you know how we can enforce passing a HTTP URL while using -http executor? |
Using -ssh option and local URL also doesnt seem to work:
However using -ssh and HTTP URL works fine:
For me, it looks like using -http or -ssh rather than -remoting is looking promising, provided the cookbook uses HTTP URL rather than local URL. |
In continuation of my earlier comment that -http and -ssh work better when provided with HTTP URL, the code here is downloading the URL to disk and passing the local URL to cli jar. (Due to cli jar unable to handle 302 re-directs) Probably the new cli jar is able to handle the 302 re-directs and the code can pass the HTTP URL directly, instead of downloading it? |
http works for me but, still have issue with groovy
Groovy test:
Same when running with kitchen test:
|
Hello, regarding to
imho : code at regex in jenkins/libraries/_executor.rb requires change:
to
Please. review and merge if appropriate #607 |
So:
So knowing that, all current possible options look like this (examples):
For me, the most interesting question here is, why does your "-remoting" don't work.
@ramc-n @Ali-karimkhani please be aware that "-http" CLI falls to anonymous user without the For me personally the best solution (taking in consideration current Jenkins CI changes) would be to use "-ssh" + "-user" instead of "-remoting" for all CLI commands except "groovy" (which still is not working without the "remoting"). This will be needed in the end as "remoting" is deprecated and planned to be removed. |
Agreed with switching to -ssh instead of -remoting! |
Because Jenkins does not start with SSHd enabled, how does anyone perform an initial run of the Jenkins cookbook with the executor protocol set to SSH? Because SSHd is not enabled, I am unable to add any plugins unless I manually go in, start the SSHd server and re-run the cookbook. Anyone? |
Maybe it is possible to enable SSHd by altering some config file on
filesystem or by REST api somehow
*Denys Shvedchenko*
Software Engineer
Cell: +380 (50) 911-0375
Skype: dshvedchenko
Sphere.Software
Website <https://sphereinc.com/> | Twitter <https://twitter.com/SphereSW>
| LinkedIn
<https://www.linkedin.com/company/sphere-consulting-inc?trk=biz-companies-cym>
| Facebook
<https://www.facebook.com/pages/Sphere-Consulting/117317111623107> |
…On Mon, May 15, 2017 at 11:29 PM, Ivan Suftin ***@***.***> wrote:
Because Jenkins does not start with SSHd enabled, how does anyone perform
an initial run of the Jenkins cookbook with the executor protocol set to
SSH? Because SSHd is not enabled, I am unable to add any plugins unless I
manually go in, start the SSHd server and re-run the cookbook.
Anyone?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#599 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABORwN9-6yXG-tc7FtRt15dcndMNqsauks5r6LW5gaJpZM4M9ly1>
.
|
Here's my solution for flipping SSHd on by defualt in my owi_jenkins cookbook. Got the idea from https://wiki.jenkins-ci.org/display/JENKINS/Groovy+Hook+Script and the Jenkins Docker container Dockerfile and how they're doing automated setup. This still does not fix plugin installation, btw. owi_jenkins::master :
sshd_configure.groovy.erb :
default.rb attributes:
|
I am getting the following error:
It appears that its pointing at a valid ssh key. Any suggestions on how to troubleshoot this are welcome. |
@ayk33 Please open a new issue. Adding this request for help to this thread may delay support. Thanks! |
Signed-off-by: Dieter Blomme <dieterblomme@gmail.com> # Conflicts: # attributes/executor.rb # libraries/_helper.rb
Signed-off-by: Dieter Blomme <dieterblomme@gmail.com> # Conflicts: # attributes/executor.rb # libraries/_helper.rb
Signed-off-by: Dieter Blomme <dieterblomme@gmail.com> # Conflicts: # attributes/executor.rb # libraries/_helper.rb
Hopefully this is a useful contribution back to this huge issue that I've ready through many times. One of the things that you might run into if you have enabled SSH or HTTPS is that attempting to run a Groovy script using Since I prefer to keep our Jenkins in line with recommendations, and managing huge blocks of Groovy inline in Chef can get unwieldy, especially if it is static code/text and doesn't require any variables. What we've moved towards doing is managing a file to the Chef cache directory using
This basically allows the file to get created during the converge portion of the |
Here is how we switched from remoting to ssh auth: A. Set executor protocol
B. Set template config for sshd server (we manually enable ssh on a jenkins master and capture this generated xml from jenkins_home)
<org.jenkinsci.main.modules.sshd.SSHD> C. Set config file for sshd server + restart
template "#{node['jenkins']['home']}/org.jenkinsci.main.modules.sshd.SSHD.xml" do execute 'wait-until-sshd-is-up' do Hope it helps. |
Thanks @danielstoian - we hit this in the middle of a planned-downtime upgrade; having a workaround readily available saved us. For reference, we had to change:
...to:
...and also:
...to:
In hopes that it helps someone else - our Jenkins install is behind a load balancer that only allows HTTP traffic, and the Jenkins CLI will automatically resolve the |
I use this little guy before all of my Jenkins resources - I have the protocol set to 'ssh' by default, unless this block is executed:
|
Cookbook version
4.2.1
Chef-client version
Chef Development Kit Version: 1.2.22
chef-client version: 12.18.31
delivery version: master (0b746cafed65a9ea1a79de3cc546e7922de9187c)
berks version: 5.6.1
kitchen version: 1.15.0
Platform Details
workstation - OS-X 10.12.4
target - Ubuntu 16.04 on EC2
Scenario:
I would like to execute my groovy scripts on Jenkins 2.54 as before. So, want to add the '-remoting' flag to the jenkins_script resource.
Steps to Reproduce:
Running jenkins_script resource
Expected Result:
Actual Result:
Works like a charm for Jenkins 2.53 and bellow
Works for Jenkins 2.54 when executing manually with the '-remoting' flag.
For Jenkins 2.54 with jenkins_script resource:
ec2-54-76-216-204.eu-west-1.compute.amazonaws.com �[0m ---- Begin output of "java" -jar "/var/chef/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20170414-1437-11rb2yt ----
ec2-54-76-216-204.eu-west-1.compute.amazonaws.com �[0m STDOUT:
ec2-54-76-216-204.eu-west-1.compute.amazonaws.com �[0m STDERR: ERROR: This command is requesting the deprecated -remoting mode. See https://jenkins.io/redirect/cli-command-requires-channel
ec2-54-76-216-204.eu-west-1.compute.amazonaws.com �[0m ---- End output of "java" -jar "/var/chef/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20170414-1437-11rb2yt ----
ec2-54-76-216-204.eu-west-1.compute.amazonaws.com �[0m Ran "java" -jar "/var/chef/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20170414-1437-11rb2yt returned 5�[0m
The text was updated successfully, but these errors were encountered: