原答案: https://issues.jenkins.io/browse/JENKINS-60593
OK, I got something working.
I have a script file on the remote server with this:
nohup java -jar demo.jar > nohup.out & sleep 5
It's the sleep 5 that fixed it for me. Now in my pipeline script I have:
sshPut remote: remote, from: 'target/demo.jar', into: 'demo.jar' sshCommand remote: remote, command: './script.sh'
This works. I guess maybe the sshCommand finishes so fast it closes the connection before nohup can really start? Just a guess, I'm not a Linux guy.
I also tried sshCommand remote: remote, command: 'nohup java -jar demo.jar > nohup.out & && sleep 5', but that didn't work, and neither did nohup java -jar demo.jar > nohup.out & ; sleep 5. In both cases it results in a "Failed command error".
标签:remote,不起作用,demo,jar,sleep,nohup,jenkins,sshCommand From: https://www.cnblogs.com/whm-blog/p/16779062.html