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?

  • What is the user which run jenkins? Do you put in script python server to run in background? Nov 27, 2019 at 21:35
  • The user which runs Jenkins is not the user which runs the script on console and yes I put the python server command to the background with &> /dev/null & Can this be the cause? Nov 27, 2019 at 21:37
  • Do the user which run jenkins have permissions to see/run the shell and/or python script? Nov 27, 2019 at 21:38
  • Tbh I don't know. How can I lookup this? Nov 27, 2019 at 21:39
  • ls -l <shell script> <python script> And if you do not see r-x in the last triad you should make it. Nov 27, 2019 at 21:40

1 Answer 1


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 string JENKINS, 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 only BUILD_ID.

More info in the official docs and in the same question on StackOverflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.