I'm having problems controlling my virtual machine using the VBoxManage tool when invoked from a TeamCity build step. In particular, I'm trying to attach a USB device to the VM before I run my unit tests. After the unit tests, I also want to clean up by detaching the USB device from the VM.
Here are the commands that are failing:
VBoxManage list vms <== to get a listing of the running VMs. This will return an empty string when run from TeamCity
VBoxManage list usbhost <== to get a list of USB devices and their corresponding UUIDs
VBoxManage controlvm <VM Name> usbattach <some UUID> <== to attach the USB device to the VM
VBoxManage controlvm <VM Name> usbdetach <some UUID> <== to detach the USB device from the VM
Note that when TeamCity runs my command line build steps, it is running as the "nt authority\system" account.
Initially, I would start the Virtual Machine using my normal login. To get the system user to see the VM, VBOX_USER_HOME environmental variable to point it to the correct location.
This cause the VBoxManage tools to fail to find my virtual machines that were created under a different user.
Next I tried starting the Virtual Machine from the system account and have verified that the above VBoxManage commands work fine when run from a local system account shell. Unfortunately, the TeamCity build steps still failed.
I use the "whoami /all" command to look at all the permissions. Unfortunately, they are the same when invoked from TeamCity or from the local system account shell.
So, what is different between a "nt authority\system" shell launched from TeamCity compared to one launched with "PSEXEC -i -s -d CMD"?
Has anyone been able to use VBoxManager in a TeamCity build step? If so, I'd love to learn the "trick".
Note in frustration, I tried numerous ways to have the TeamCity build step "become" a different user. Although these did become a different user, they couldn't successfully use the VBoxManage commands. These approaches were:
- Use "runas"
- Use ssh to log back into the same machine
Thanks in advance!