Tuesday, February 15, 2011

How to prevent Hudson to kill processes

Normally hudson will kill all the processes that have been created during the build tasks, this will ensure that after the build the system will be left in a consistent state.

However, sometimes, you may need to keep those tasks running, for example we use Hudson to automatically perform nightly installations on our test servers, in those cases you want that hudson will not kill the processes that have been started during the installation (i.e. jboss, tomcat).

A web search got me this page:

http://www.suryasuravarapu.com/2010/07/spawning-a-process-from-hudson.html

The page explain how to setup the project to prevent hudson from killing started process, basically it says:

set the environment variable BUILD_ID to something like 'dontKillMe' in the
process that should stay alive.

Hudson looks for that environment variable when cleaning up stray processes.

However, if you are new to hudson, it does not say how to achieve that, well, you can use the setenv plugin, to install it you have to simply go to the “manage hudson” page where you will find the “manage plugins” shortcut, in the plugins page (in the “available” column) you can find the SetEnv plugin, just mark it and then click on “install” at the end of the page.

At the end of the plugin installation you can restart hudson and the Environment Variables field will appear when configuring the project.

 

Happy CI.

No comments: