I confess I am total newbie to Jenkins. I have
Jenkins-tls
installed on my Mac for experimentation. I have a remote server that I testing with. My Jenkins script is ultra simple.
ssh to the remote machine
sudo pm2 ls
the last command just hangs
I run the same 2 commands from the command line and it all works perfectly. FYI, I need sudo for pm2 since I need to be root to run pm2, without sudo, I get access denied.
Any thoughts?
I believe you make the invalid assumption that jenkins somehow "types" commands after starting ssh to the remote session's command shell. This is not what happens. Instead, it will wait for the ssh command to finish, and only then execute the next command sudo pm2 ls
. This never happens, because the ssh session never terminates. You observe this as a "hang".
How to solve this?
If there's only a small number of commands, you can use ssh to run them with
ssh user@remote sudo mp2 ls
ssh user@remote command arg1 arg2
If this gets longer, why not place all commands in a remote script and just run it with
ssh user@remote /path/to/script