Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Catch Abort signal on hudson in shell script?

Tags:

hudson

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)?

like image 477
pkm Avatar asked Oct 02 '22 08:10

pkm


1 Answers

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
like image 146
vzamanillo Avatar answered Oct 11 '22 13:10

vzamanillo