I am looking for a way to have each build run in complete isolation. I also need for each build to start with a "clean" environment. Conceptually, I want it to work like elastic bamboo with one difference... When the remote agent goes to an idle state, I want the remote VM to be destroyed not just shutdown. When a new build is queued, it should create a brand new VM for the build. This allows for build plans to install system level and/or make changes to the system configuration without the risk of impacting other builds.
We don't use EC2 but we do have a private cloud using VMWare's vCloud director. There do not appear to be any plugins currently available that work with vCloud director. I am considering writing a plugin for Bamboo that could provide this type of functionality but I think that it is going to be a fairly high level of effort (if possible at all).
I am wondering if i might be able to accomplish this using Docker. I have already tested out the docker support and 5.7 and it looks very promising. Adding the "--rm=true" parameter to the command line used to run the image causes the container to be removed when the process exits. When it is restarted, it is a brand new environment.
Unfortunately, I have not been able to come up with a way to have the remote agent exit after a build completes so that the docker container can stop running. If I could figure that part out then I could could wrap it in another script to restart it.
However, even if I solve that problem, this approach causes a new remote agent to be registered on the bamboo server every time the docker container starts. Is there a way to get around that issue?