Issue
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??
UPDATE: I made a script using os library in python and configured the commands over there and run that script this worked for me
Solution
Any process resulting from a command executed by Jenkins will be a child node of the Jenkins process. Jenkins, by design, kills all processes pawned by a build once the build completes.
This feature is called ProcessTreeKiller. For Freestyle Jobs the Jenkins documentation has traditionally recommended setting the following environment variable in a Execute Shell step of your job.
export BUILD_ID=dontKillMe
A similar environment variable setting is required for Pipeline projects.
export JENKINS_NODE_COOKIE=dontKillMe
If you want to disable this feature globally you can use the following Java system property
java -Dhudson.util.ProcessTree.disable=true -jar jenkins.war
More recently, Jenkins Project has recommended using a daemon wrapper as well.
daemonize -E BUILD_ID=dontKillMe http-server
You could also implement a message queue or other asynchronous service
Answered By - Chris Maggiulli
Answer Checked By - Marie Seifert (JavaFixing Admin)