I am trying to salvage test data from an aborted Jenkins build. The documentation (https://wiki.jenkins-ci.org/display/JENKINS/Aborting+a+build) appears to throw an interrupt and so I attempted to catch it with a custom handler:
signal.signal(signal.SIGINT, signal_handler)
Running my program through CMD and sending crtl-c stimulates the signal_handler function. However, when running this through Jenkins, the interrupt signal is not captured. Are there any plugins that alter Jenkins abort signal, or is there a way to handle it gracefully?
Well, I know this a bit late, but jenkins sends a TERM signal when aborting. Basically you just gotta register that signal
signal.signal(signal.SIGTERM, signal_handler)
Info obtained from: https://gist.github.com/datagrok/dfe9604cb907523f4a2f
where it says:
Jenkins
When a Jenkins job is cancelled, it sends
TERMto the process group of the process it spawns, and immediately disconnects, reporting "Finished: ABORTED," regardless of the state of the job.This causes the spawned process and all its subprocesses (unless they are spawned in new process groups) to receive
TERM.This is the same effect as running the job in your terminal and pressing CTRL+C, except in the latter situation
INTis sent, notTERM.Since Jenkins disconnects immediately from the child process and reports no further output:
it can misleadingly appear that signal handlers are not being invoked. (Which has mislead many to think that Jenkins has
KILLed the process.)it can misleadingly appear that spawned processes have completed or exited, while they continue to run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With