Bash – How to restart Jetty on a Jenkins slave node

bashJenkinsjetty

I am trying to deploy a .war on a Jenkins slave node that is running Jetty using an execute shell build step. To do this I am running the following in my shell command.

/etc/init.d/jetty restart

It starts Jetty successfully, but as soon as the Jenkins job finishes it stops. As I was trouble shooting this, I put a long sleep in the shell build step, and Jetty ran the entire time during the sleep, so I know it has something to do with exiting the shell after the job completes.

Is there any way to keep Jetty running after the shell exits in Jenkins?

I have tried using this but it doesn't do the trick.

nohup /etc/init.d/jetty restart &

Best Answer

its actually piss-poor-simple:

echo "/etc/init.d/jetty restart"| at now