I want to run the command http-server command on jenkins. It is a command which runs continusly it will never gets disconnected until we do the CTRL C. What happens is the job is failed since the commmand never completes. Any solution. I want the server to run and jenkins job to be succeeded any solution??
CodePudding user response:
How about you execute the command as a background process?
http-server > /dev/null 2>&1 &
CodePudding user response:
You need to set the following in your job. By default Jenkins kills every process that is spawned by the job unless you set this environment variable in the job itself
export BUILD_ID=dontKillMe
CodePudding user response:
Don't use CtrlC, but use CtrlZ - or use &
to detach the console (second option is better for scripting).
On Jenkins you might also want to obtain the PID of that process, in order to kill it again; else you'll spawn a new process with every single build. Setting up Apache or Ngnix might provide a more reliable experience; else you'll have to mess around with PID, instead of just deploying (the script will ultimately not run on http-server
anyway).