Setting Up TeamCity for VMware vSphere and vCenter
TeamCity vSphere integration allows using TeamCity agent cloud features with VMware vSphere and vCenter installation. It requires configuring TeamCity with your VMware vSphere/vCenter account and then handles automatic creation/starting/stopping/deleting of the virtual machines with TeamCity agents on-demand, based on the queued builds.
The functionality is implemented as a plugin bundled with TeamCity.
Requirements
Features
The TeamCity vSphere integration allows you to:
Select the type of behavior:
Start/stop an existing virtual machine.
Clone a virtual machine or a template, and either delete the clone once it becomes idle (when the build is finished or an idle timeout elapses, depending on the profile settings) or preserve it after stopping.
Select a virtual machine snapshot to start.
Specify the directory for clones and the resource pool where your machine will be allocated.
Configure the maximum number of started instances.
Usage
The following steps are required to set up TeamCity-VMware vSphere agent cloud integration:
Create a virtual machine where your builds will run. Refer to the VMware vSphere website for details on creating virtual machines.
Make sure VMware Tools or Open VM Tools are installed. See VMware documentation.
Install a TeamCity agent, configure and test the machine as described in this section.
If you want TeamCity to start/stop this machine on demand or to clone it, proceed to configuring the VMware cloud profile on the TeamCity server. When the profile is modified, TeamCity detects the changes immediately, and forces shutdown of the agents started prior to these changes once the agents finish the current build.
If you want to create a template of this machine and clone it, refer to the VMware vSphere website for details on creating templates and proceed to configuring the VMware cloud profile on the TeamCity server. Make sure to specify the valid vCenter SDK URL.
Notes on Configuring Agent Cloud Profile
You can limit a number of instances across all images and/or set the limit per image.
It is possible to specify unique hostnames for cloud agents: when adding an image, choose a customization spec from the corresponding field. The option is available for Windows and Linux virtual machines.
When using the same image in different cloud profiles, to avoid possible conflicts, it is possible to use a custom agent image name when configuring a cloud profile in TeamCity. This can be also useful with naming patterns for agents. When a custom agent image name is specified, the names of cloud agent instances cloned from the image will be based on this name.
Clone Virtual Machine to Reuse Agent
To clone a virtual machine or template and preserve the clone so TeamCity can reuse it, select the respective option in the Behavior configuration field of the Add Image/Edit Image dialog:
![vCenter Add Image Behavior vCenter Add Image Behavior](https://resources.jetbrains.com/help/img/teamcity/2023.09/vCenter-add-image-behavior.png)
Note that if you use <Current State>
in the Snapshot name field, TeamCity will always create a new clone and delete the previous one. To preserve the cloned virtual machine:
For virtual machines:
Select the virtual machine that you want to use in the Agent image field.
Create a snapshot of your virtual machine and use its name in the Snapshot name field.
For templates:
Convert a template to a virtual machine, create a snapshot of this virtual machine, and then convert the virtual machine back to a template.
In TeamCity, select the template in the Agent image field and use the snapshot you have just created in the Snapshot name field .