I have an .sh file which spawns a simple http server with python3. What I need is to successfully run this file with Jenkins. The job goes "green" but the directory I try to serve with python http server is not available and the browser says "Request failed". ps -a
also does not show any python process.
When I run the python command directly on the console the server gets started and ps -a
shows the pid of python process. What am I missing?
Best Answer
It sounds like you are running into the Jenkins Process Tree Killer. Basically, when a build finishes, Jenkins kills any processes started by that build, even if those processes were moved to the background.
To stop processes from being killed, set the environment variable
BUILD_ID
to anything that doesn't contain the stringJENKINS
, for instance:If you are using Pipelines instead of Freestyle jobs, the official docs say to change the value of
JENKINS_NODE_COOKIE
instead, but I use Pipelines and haven't had any issues by altering onlyBUILD_ID
.More info in the official docs and in the same question on StackOverflow.