Currently in Bamboo you cant stop a build once it has left the queue and is in progress. The problem is made more intractable because Bamboo doesnt really know what build processes to stop.
I am proposing that we put a feature in Bamboo build configuration that would be a "program to run on Build cancel". This would be invoked if the user presses the Cancel build button whena build is in progress.
This program would be given 3 arguments. The process id the build process in question, the build plan and the buld number say. Perhaps other Bamboo properties could eb stuffed into the process environment as well.
This would allow the "stop process" to do what ever it needs to do to stop the build from running. This might be a kill -9 style script under Unix or a clean shutdown program.
The key point here is that Bamboo does not take on the reposibility of being able to stop a build proccess (and all the support questions that would raise) but rather allows customers to have a mechanism to clean up running builds.
Maybe a database needs to be cleanly shutdown, or a TCP connection to a POS terminal emulator. There are all sorts of clean up tasks that a build might need. We just need to give them enough information to write such a script.
I would advocate that Bamboo have a simple "shim" program that it used to start any process. So this would produce a shim per build like
The shim would simple report its process id back to Bamboo via stdout/stderr and then Bamboo knows what COULD be killed, eg all the programs of and including shim xyz
The parameters to the shim would be the project/plan/build number so that when someone looks ate the running processes (via say ps) they can easily identify the builds. The rest of the parameters would be the build command to run.
So for example the shim program invocation might look like
shim "JIRA Unit Tests - HEAD" "JDK1.6" "BASIC-JDK16-3645" maven clean test
And the first line of stdout might be
then followed by the builder output.
As for finding out the current Java process id, there are two solid approaches. The first is to use JMX on Java5 or above. This works reliably on Sun JVM's on Windows and Unix.
The other is to use JNA. I have spiked this on both Windows and Linux with great success.
Once we have the process id of the shim, we then have a place that peole can terminate a running. Also the user of the shim will mean the builds will turn up more easily in process viewers like