...
For integrations with other cloud solutions, see see the following pages:
- VMWare vSphere (bundled since TeamCity 10.
...
- 0)
...
...
- ,
- Google Cloud Agents.
- Implementing Cloud support enables to you create your own integration.
On this page:
Table of Contents |
---|
...
It is assumed that the machine images are pre-configured to start TeamCity agent on boot (see details below). The exception is usage of agent push.
...
On instance terminating/stopping, its disconnected agent is removed from authorized agents list and is deleted from the system.
Since TeamCity 9.1.4, Amazon EC2 Spot Instances are supported.
Configuration
...
ec2:Describe*
ec2:StartInstances
ec2:StopInstances
ec2:TerminateInstances
ec2:RebootInstances
ec2:RunInstances
ec2:ModifyInstanceAttribute
To use spot instances, the following additional permissions are required:
ec2:RequestSpotInstances
ec2:CancelSpotInstanceRequests
To launch an instance with Iam Role (applicable to instances cloned from AMI-s only) the following additional permissions are required:
...
Optional permissions
See the section below for permissions to set IAM roles on an agent instance.
...
If you need the connection between the server and the agent machine to be secure, you will need to setup set up the agent machine to establish a secure tunnel (e.g. VPN) to the server on boot so that TeamCity agent receives data via the secure channel.
...
- Choose one of existing generic images.
- Start the image.
- Configure the running instance:
- Install and configure build agent:
- Configure server name and agent name in
conf/buildAgent.properties
— this is optional, if the image will be started by TeamCity, but it is useful to test the agent is configured correctly. - It usually makes sense to specify
tempDir
andworkDir
inconf/buildAgent.properties
to use non-system drive (d: under Windows)
- Configure server name and agent name in
- Install any additional software necessary for the builds on the machine.
- Run the agent and check it is working OK and is compatible with all necessary build configurations, etc.
- Configure system so that agent it is started on machine boot (and make sure TeamCity server is accessible on machine boot).
For Amazon EC2 on Windows, you may need to To ensure proper TeamCity agent communication with EC2 API under Windows, add a dependency from the TeamCity Build Agent service on the the AmazonSSMAgent or EC2Launch / EC2Config service (e.g. EC2Config mounts drives after the OS is started, and the agent or some of its folders may be present on these drives).Anchor EC2ConfigDep EC2ConfigDep Info the service which makes sure the machine is fully initialized in regard to AWS infrastructure use). This can be done, for example, via the Registry or using sc config , e.g.
sc config TCBuildAgent depend= EC2Config
Alternatively, you can use the "Automatic (delayed start)" service starting mode.
- Install and configure build agent:
- Test the setup by rebooting machine and checking that the agent connects normally to the server.
- Prepare the Image for bundling:
- Remove any temporary/history information in the system.
- Stop the agent (under Windows stop the service but leave it in Automatic startup type)
- Delete content
logs
andtemp
directories in agent home (optional) - Delete "
<Agent Home>/conf/amazon-*
" file (optional) - Change
config/buildAgent.properties
to remove properties:name
,serverUrl
,authorizationToken
(optional).serverUrl
can be removed for EC2 integration plugins. Other plugins might require that it is present and set to correct value.
Make a new image from the running instance (or just stop it for Amazon EBS images).
Agent auto-upgrade Note
TeamCity agent auto-upgrades whenever distribution of agent plugins on the server changes (e.g. after TeamCity upgrade). If you want to cut agent startup time, you might want to re-bundle the agent AMI after agent plugins have been auto-updated.
Configuring a cloud profile in TeamCity
Next configure Amazon EC2 Agent Cloud Profile in the Server Administration UI, on the Administration | Agent Cloud.
IAM profiles
Since TeamCity 9.1.1 it It is possible to use IAM profiles with build agents launched as Amazon EC2 instances, which requires the supplied AWS account to have the following permissions:
...
Amazon EC2 Spot Instances support
Since TeamCity 9.1.4 TeamCity supports Amazon EC2 Spot Instances and now you can place your bid on unused EC2 capacity and use it, as long as your suggested price exceeds the current "Spot price".
...
Amazon EBS-Optimized Instances
EBS-optimization is enabled by default since Since TeamCity 10.0 unhide for 10.0.3
The behavior of [EBS-optimization|http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html], enabled by default in TeamCity 3, the behavior of EBS-optimization, enabled by default in TeamCity 10.0, is changed similarly to what EC2 console offers. In the TeamCity Web UI, it can be set using the corresponding box of the Instance Type when configuring the image of the Amazon cloud profile:
# EBS-optimization is turned on by default for c4.*, d2.* , and m4.* (non-configurable)
# EBS-optimization is turned off by default for any other instance types.
# EBS-optimization can be turned on for instances that support it (such as c3.xlarge, etc.)
hidden-data
When configuring the image of the Amazon cloud profile, the optimization can be set using the corresponding box of the Instance Type. Note that
- EBS-optimization is turned on by default for
c4.*
,d2.*
, andm4.*
(non-configurable) - EBS-optimization is turned off by default for any other instance types and can be turned on for instances that support it (such as
c3.xlarge
, etc.)
Tagging for TeamCity-launched instances
...
The following requirements must be met for tagging instances launched by TeamCity:
- you have the
ec2:*Tags
permissions - the maximum number of tags (1050) for your Amazon EC2 resource is not reached.
...
Custom tags
Since TeamCity 10.0, custom tags can be applied to EC2 cloud agent instances: when configuring Cloud profile settings, in the Add Image/ Edit Image dialog use the Instance tags: field to specify tags in the format of <key1>=<value1>,<key2>=<value2>
. Amazon tag restrictions need to be considered.
Agent auto-upgrade Note
TeamCity agent auto-upgrades whenever distribution of agent plugins on the server changes (e.g. after TeamCity upgrade). If you want to cut agent startup time, you might want to re-bundle the agent AMI after agent plugins have been auto-updatedIf you'd like to use equal(=) sign in the tag value, no escaping is needed. For instance, the string extraParam=name=John
will be parsed into <key=extraParam>
and value <name=John>
(Since 10.0.3).
Tagging instance-dependent resources
Since TeamCity 2017.1, when launching Amazon EC2 instances, TeamCity tags all the resources (e.g. volumes and network adapters) associated with the created instances, which is important when evaluating the overall cost of an instance (taking into account the storage drive type and size, I/O operations (for standard drives), network (transfers out), etc.
Sharing single EBS instance between several TeamCity servers
As mentioned above, TeamCity tags every instance it launches with "teamcity:TeamcityData
" tag that represents server, cloud profile and source (AMI or EBS-instance). So, in case when several TeamCity servers tries to use the same EBS instance, the second one will see message "Instance is used by another TeamCity server. Unable to start/stop it". If you are sure that no other TeamCity servers are working with this instance, you can delete the "teamcity:TeamcityData
" tag and the instance will become available for all TeamCity servers again.
New instance types
Since Amazon doesn't provide a robust API method to retrieve all instance types, Amazon integration relies on periodical update of AWS SDK to make new instance types available.
However, there 's is a workaround if you are not willing to wait. To register new Instance Types, use the following internal property:
...
Proxy settings
If your TeamCity server instance is behind needs to use a proxy to connect to AWS API endpoint, configure the following server internal properties to connect to Amazon AWS addresses.
...