Catch Abort signal on hudson in shell script?

主宰稳场 提交于 2019-12-07 04:51:31

问题


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


来源:https://stackoverflow.com/questions/20137838/catch-abort-signal-on-hudson-in-shell-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!