I have a Jenkins job and the integration tests require certain resources. I have a shut down hook that ensures that all connections have been closed and worker threads stopped in case there is such a situation that some of them are missed during execution or (as i intended) build is interrupted.However, shut down hooks are not executed if job is interrupted with the UI or something. Is there a way to make it execute, or an event created when job is interrupted before completion? Thanks in advance
Asked
Active
Viewed 811 times
1
-
Have you taken a look at the [Post Build Task](https://wiki.jenkins-ci.org/display/JENKINS/Post+build+task)? (See: http://stackoverflow.com/a/25543380/4121744) – bto Jun 26 '15 at 02:13
-
Thats a solution. However, it looks like Post Build Task is used to start another task. So, Id have to create a script to kill the original process, or start up another JVM to signal the original one to clean up or stop, or something along those lines. This is a reasonable solution, how ever it'd be a lot nicer to simply call System.exit from within the same JVM. Is there a way to do that? – aiguy Jun 26 '15 at 05:03
-
@aiguy You write "I have a shut down hook", how does it look like? Is it a shell `trap`? – Daniel Alder May 03 '17 at 15:29