Sorry I should have been more useful in my comment. By worst I meant that I have found that a killed job can corrupt the current job's workspace. I have found a way to reproduce this corruption 100% of the time.
I use Jenkins 1.578 and Java SE JRE 1.7.0_45-b18) Java HotSpot 64-bit Server VM (build 24.35-b08).
I launch jenkins from linux RHEL 6.4 (Santiago) with java -jar jenkins.war
The job needs to be configured with the following script (it is a variation on the python script above):
#!/usr/bin/python
import signal
import time
import os
def handler(*ignored):
time.sleep(120)
fh = open("a_file.txt","a")
fh.write("Handler of Build number: "+os.environ['BUILD_NUMBER'])
fh.close()
signal.signal(signal.SIGTERM, handler)
fh = open("a_file.txt","w")
fh.write("Main of Build number: "+os.environ['BUILD_NUMBER'])
fh.close()
time.sleep(120)
Then configure the job to archive the artifact named a_file.txt
Run two jobs back to back, kill the first one shortly after it started. Leave the second one to complete until it ends normally.
The log as configured in the above comment, shows:
killAll: process=java.lang.UNIXProcess@3d7c07c9 and envs={HUDSON_COOKIE=06668ba4-b481-4a17-86b3-5f4fbd4061b2}
Sep 09, 2014 3:30:49 PM FINE hudson.util.ProcessTree
Recursively killing pid=1840
Sep 09, 2014 3:30:49 PM FINE hudson.util.ProcessTree
Killing pid=1840
Sep 09, 2014 3:30:49 PM FINE hudson.util.ProcessTree
Recursively killing pid=1840
Sep 09, 2014 3:30:49 PM FINE hudson.util.ProcessTree
Killing pid=1840
The unix process table, after the kill, shows that both jobs are still running:
mdanjou 1251 953 0 10:07 pts/30 00:01:46 java -jar jenkins.war
mdanjou 1840 1251 0 15:30 pts/30 00:00:00 /usr/bin/python /tmp/hudson6469713064377741807.sh
mdanjou 1851 1251 0 15:30 pts/30 00:00:00 /usr/bin/python /tmp/hudson1969984296722384280.sh
Both jobs are still running.
When the second job completes, examine its artifact. It contains this:
Main of Build number: 18Handler of Build number: 17
So the killed build (#17) corrupts the workspace of the running build (#18).