When using Hudson's execute SH script, if the SH script is a background process, such as TOMCAT services. If you use the default configuration of Hudson, you will find that the SH process has a start-up process, but will not be resident in the background, look at the Hudson output log, and discover that Hudson kill all the non-terminating derivative processes after the job build is completed.
A further description of the Hudson killing of the derivative process is described in Hudson on another wiki page. Hudson sets a series of environment variables that will be inherited by the job-derived process when the job is executed. Hudson will look at the environment variables of the process when the kill derivation process, and if it finds the environment variables set before it, kill them. A simple way to prevent the process from being killed is given on the wiki: Modify the value of the environment variable build_id set by the Hudson, so that Hudson thinks the process is not derived from the job's build process.
Method 1: Global Settings
Open: Hudson > System Management > System settings
Set build_id value to Allow_to_run_as_daemon
This allows us to execute the command to execute SH where we need to execute the SH script to start and stop Tomcat, for example:
Method 2: Set the build_id where you need to execute the SH script
Set the build_id directly inside the command and then execute the SH script, as follows:
-------------------------------------
Finish
HUDs
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Hudson Execute shell script (Hudson boot tomcat Invalid issue)