2

We're deploying our application using SSH scripts. For the production stage we need to figure out which out of two clusters is currently active. This can only be achieved reliably by running a command on a remote host and interpreting its output. Unfortunately there's no SSH plugin that does that AFAIK.

They only seem to be able to interpret if the SSH script return value was different from zero.

Currently I only see two undesirable solutions:

  • use SSH in a script like Python, Groovy, etc. (means, we would have to provide SSH authentication to it somehow)
  • Let the SSH-command write to a file, that is then copied to Jenkins and interpreted there (unelegant and cumbersome)
kossmoboleat
  • 1,841
  • 1
  • 19
  • 36
  • what exactly you want to interpret from the ssh output. Its either a success or failure upon executing the ssh command – Raghav Vaidhyanathan Nov 21 '14 at 16:03
  • Yeah, I didn't state this clearly, but I want to read the SSH commandline output. I.e. "ssh kossmoboleat@remote.com ls", which would return a list of files. I would like to have that command output in a variable in jenkins for further processing to conditionally deploy to one or another server. – kossmoboleat Nov 21 '14 at 16:12
  • Please state the environment/operating system this needs to run on. What kind of ssh authentication is available (password, ssh key, with or without passphrase?) Are you able to install any new tools or jenkins plugins? – sti Nov 23 '14 at 20:53

1 Answers1

1

Ok based on what you mentioned in the comment, I think you can try something like given in here and then copy back that file to jenkins using ftp and then read the file contents.

Or you can have the whole process orchestrated in an Ant script by using SSHExec task and get the output in Ant

Community
  • 1
  • 1
Raghav Vaidhyanathan
  • 745
  • 1
  • 10
  • 25