Hi,

I have a jenkins project whose "Execute shell" command consists of this:


set -e  # Exit immediately if a simple command exits with a non-zero status
set -x verbose


export PKG="annotation"
export SUFFIX="zip"

ssh -o StrictHostKeyChecking=no -i $SSH_KEY [email protected] 
"rm -f ~/repository/$PKG/*.$SUFFIX"

If I run this script manually on the windows box, it works fine. 

That ssh command looks syntactically valid to me (SSH_KEY is defined in the 
node config) but it fails in jenkins. Since I have verbosity turned on this 
is the command I see (along with its output) in the jenkins build output:

+ ssh -o StrictHostKeyChecking=no -i c:/jenkins/docbuilder 
[email protected] rm -f ~/repository/annotation/*.zip
usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-e escape_char] [-F configfile]
           [-I pkcs11] [-i identity_file]
           [-L [bind_address:]port:host:hostport]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-R [bind_address:]port:host:hostport] [-S ctl_path]
           [-W host:port] [-w local_tun[:remote_tun]]
           [user@]hostname [command]


So it looks like the quotes in my command were somehow stripped. I think those 
quotes are needed in order for ssh to understand its arguments (otherwise the * 
is expanded before it gets to ssh, and so on). 


How can I fix that? I tried escaping the quotes with a backslash and then the 
command (when echoed) looked like this in the jenkins output:


+ ssh -o StrictHostKeyChecking=no -i c:/jenkins/docbuilder 
[email protected] "rm -f ~/repository/annotation/*.zip"

usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-e escape_char] [-F configfile]
           [-I pkcs11] [-i identity_file]
           [-L [bind_address:]port:host:hostport]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-R [bind_address:]port:host:hostport] [-S ctl_path]
           [-W host:port] [-w local_tun[:remote_tun]]
           [user@]hostname [command]


So the quotes are now present but there is still something wrong with the 
command as seen by ssh.

If I copy and paste that command directly into an sh window on the windows node 
(a cygwin terminal window where I have exported SSH_KEY), it works.


Another thing I should mention is that I'm logged into the windows node as 
Administrator, but the jenkins slave is running as nt authority\system, a user 
who does not have the right to log on interactively. 


Any ideas? Thanks.








-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to