How can we trap the abort signal of the job on hudson so that i can do some post steps in case of abort (I am running a job on hudson which has shell script running in background)?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I have experienced with Jenkins, not hudson, (Jenkins is a fork of hudson) Jenkins sends a SIGTERM on Unix through Sun's JRE java.lang.UnixProcess.destroyProcess, on Windows, this is done through TerminateProcess API.
JENKINS - Aborting a build
HUDSON - Aborting a build
So you can use "trap" in your shell script by this way
#!/bin/bash
getAbort()
{
echo "Abort detected"
# other commands here if any...
}
trap 'getAbort; exit' SIGTERM