I am using ssh as protocol to connect to jenkins via cli . The same command is working when run manually , but fails via my cookbook .
server # java -jar /opt/tomcat/webapps/ROOT/WEB-INF/jenkins-cli.jar -s http://localhost:8181/ -ssh -user update -i /home/update/.ssh/id_rsa who-am-i
Feb 16, 2018 11:18:02 AM hudson.cli.SSHCLI$1 verifyServerKey
WARNING: Unknown host key for server:32855
Authenticated as: update
Authorities:
authenticated
Failure via chef cookbook recipe : I am running it as a bash command resource in my recipe .
[2018-02-16T11:27:39+01:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: bash[install jenkins plugins] (sap-bs-jenkins::bs_jenkins line 104) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '255'
---- Begin output of "bash" "/tmp/chef-script20180216-23269-9xs4ow" ----
STDOUT:
STDERR: Feb 16, 2018 11:27:39 AM hudson.cli.SSHCLI sshConnection
WARNING: No header 'X-SSH-Endpoint' returned by Jenkins
---- End output of "bash" "/tmp/chef-script20180216-23269-9xs4ow" ----
Jenkins ssh port is set to random , and X-SSH-Endpoint is indeed set
server # curl -I http://localhost:8181
HTTP/1.1 200 OK
........
X-SSH-Endpoint: server:41228