This page covers:
Before you can start customizing projects and creating build configurations, you need to configure build agents. Please review the agent-server communication and Prerequisites section before proceeding with agent installation.
|
Before the installation, please review the Conflicting Software section. In case of any issues, make sure no conflicting software is used.
Please note that in order to run a TeamCity build agent, the user account used to run the Agent requires the following privileges:
serverUrl
property (usually the same URL as the server web UI). Specific URLs which can be used for requests to the server should not be limited. See also the recommended reverse proxy settings.By default unidirectional agent-to-server connection via polling protocol is used by TeamCity. If you need to use legacy bidirectional communication (not recommended), in addition for the agent to server connections, the server must be able to open HTTP connections to the agent. The agent port is determined using the
If the agent is behind NAT and cannot be accessed by any of addresses of the agent machine network interfaces, please specify the Please ensure that any firewalls installed on the agent, server machine, or in the network and network configuration comply with these requirements. |
The agent process (java) should:
<agent home>
(necessary for automatic agent upgrade and agent tools support), <agent work>
, <agent temp>
, and agent system directory (set by workDir, tempDir and systemDir parameters in buildAgent.properties file)Reboot the machine (required for agent reboot functionality)
To be able to monitor performance of a build agent run as a Windows service, the user starting the agent must be a member of the Performance Monitor Users group
For granting necessary permissions for unprivileged users, see Microsoft documentation. You can assign rights to manage services with Microsoft SubInACL utility, a command-line tool enabling administrators to directly edit security information. The tool uses the following syntax:
For example, to grant Start/Stop rights, you might need to execute the command:
|
shutdown
command (for the agent machine reboot functionality and the machine shutdown functionality when running in a cloud environment)The build process is launched by a TeamCity agent and thus shares the environment and is executed under the OS user used by the TeamCity agent. Please ensure that the TeamCity agent is configured accordingly.
See Known Issues for related Windows Service Limitations.
A TeamCity agent connects to the TeamCity server via the URL configured as the "serverUrl" agent property. This is called unidirectional agent-to-server connection. If specifically configured, TeamCity agent can use legacy bidirectional communication which also requires establishing a connection from the server to the agents.
Unless security in transfer between the agent and the server is important, it is recommended to deploy agents and the server into a secure environment and configure agents to use plain HTTP URL for the server as this reduces transfer overhead.
To view whether the agent-server communication is unidirectional or bidirectional for a particular agent, navigate to Agents | <Agent Name> | Agent Summary tab, the Details section, Communication Protocol.
Agents use unidirectional agent-to-server connection via the polling protocol: the agent establishes an HTTP(S) connection to the TeamCity Server, and polls the server periodically for server commands.
HTTPS agent-server connection
It is possible and recommended to set up a server to be available via the HTTPS protocol, so all the data travelling through the connections established from an agent to the server (including the download of build sources, build artifacts, build progress messages and build log) can be secured. See Using HTTPS to access TeamCity server for configuration details.
The bidirectional communication is a legacy connection between the agent and the server and it needs to be specifically enabled (see below). When enabled, it requires the agent to connect to the server via HTTP (or HTTPS) and the server to connect to the agent via HTTP.
The data that is transferred via the connections established by the server to agents is passed via an unsecured HTTP channel and thus is potentially exposed to any third party that may listen to the traffic between the server and the agents. Moreover, since the agent and server can send "commands" to each other, an attacker that can send HTTP requests and capture responses may in theory trick the agent into executing an arbitrary command and perform other actions with a security impact.
The communication protocol used by TeamCity agents is determined by the value of the
|
{hidden-data} The agent gets disconnected, but remains authorized. See [Build Agent Status|Build Agent#Build Agent Status] for details. {hidden-data} |
conf/buildAgent.properties
file.When the newly installed agent connects to the server for the first time, it appears on the Agents
page, Unauthorized agents
tab visible to administrators/users with the permissions to authorize it. Agents will not run builds until they are authorized in the TeamCity web UI. The agent running on the same computer as the server is authorized by default.
The number of authorized agents is limited by the number of agents licenses on the server. See more under Licensing Policy.
Run the agentInstaller.exe
Windows Installer and follow the installation instructions.
Please ensure that the user account used to run the agent service has appropriate permissions |
JRE_HOME
or JAVA_HOME
environment variables are set (pointing to the installed JRE or JDK directory respectively).<installation path>\conf
directory, locate the file called buildAgent.dist.properties
and rename it to buildAgent.properties
.buildAgent.properties
file to specify the TeamCity server URL and the name of the agent. Please refer to Build Agent Configuration section for details on agent configuration.Under Linux, you may need to give execution permissions to the bin/agent.sh
shell script.
On Windows you may also want to install the build agent windows service instead of the manual agent startup. |
TeamCity provides functionality that allows installing a build agent to a remote host. Currently supported combinations of the server host platform and targets for build agents are:
SSH note |
There are several requirements for the remote host:
Platform | Prerequisites | |
---|---|---|
Linux |
| |
Windows |
|
hostname.domain:2222
, during the actual agent installation.Sysinternals psexec.exe
, in which case you will see the corresponding warning and a link to the Administration | Tools page where you can download it.You can use Agent Push presets in Agent Cloud profile settings to automatically install a build agent to a started cloud instance.
TeamCity build agents can be started manually or configured to start automatically.
To start the agent manually, run the following script:
for Windows:
<installation path>\bin\agent.bat start
for Linux and macOS:
<installation path>\bin\agent.sh start
To configure the agent to be started automatically, see the corresponding sections:
Windows
Linux : configure daemon process with agent.sh start
command to start it and agent.sh stop
command to stop it.
macOS
To run agent automatically on the machine boot under Windows, you can either set up the agent to be run as a Windows service or use another way of the automatic process start.
Using the Windows service approach is the easiest way, but Windows applies some constraints to the processes run this way.
A TeamCity agent works reliably under Windows service provided all the requirements are met, but is often not the case for the build processes configured to be run on the agent.
That is why it is recommended to run a TeamCity agent as a Windows service only if all the build scripts support this.
Otherwise, it is advised to use alternative OS-specific ways to start a TeamCity agent automatically.
One of the ways is to configure an automatic user logon on Windows start and then configure the TeamCity agent start (via agent.bat start
) on the user logon (e.g. via Windows Task Scheduler).
In Windows, you may want to run TeamCity agent as a Windows service to allow it running without any user logged on.
If you use the Windows agent installer, you have an option to install the service in the installation wizard.
To run builds, the build agent must be started under a user with sufficient permissions for performing a build and managing the service. By default, a Windows service is started under the SYSTEM account which is not recommended for production use due to extended permisisons the account uses. To change it, use the standard Windows Services applet (Control Panel|Administrative Tools|Services) and change the user for the |
If you start an Amazon EC2 cloud agent as a Windows service, check related notes. |
The following instructions can be used to install the Windows service manually (e.g. after .zip agent installation). This procedure should also be performed to create Windows services for the second and following agents on the same machine.
To install the service:
wrapper.java.command
property in the <agent home>\launcher\conf\wrapper.conf
file contains a valid path to the Java executable in the JDK installation directory. You can use wrapper.java.command=../jre/bin/java
for the agent installed with the Windows distribution. Make sure to specify the path of the java.exe file without any quotes.<agent home>\launcher\conf\wrapper.conf
file with appropriate credentials<agent>\launcher\conf\wrapper.conf
file so that the wrapper.console.title
, wrapper.ntservice.name
, wrapper.ntservice.displayname
and wrapper.ntservice.description
properties have unique values within the computer.<agent home>\bin\service.install.bat
script under a user with sufficient privileges to register the new agent service. Make sure to start the agent for the first time only after it is configured as described.To start the service:
<agent home>/bin/service.start.bat
To stop the service:
<agent home>/bin/service.stop.bat
You can also use the standard Windows net.exe
utility to manage the service once it is installed.
For example (assuming the default service name):
net start TCBuildAgent |
The <agent home>\launcher\conf\wrapper.conf
file can also be used to alter the agent JVM parameters.
The user account used to run the build agent service must have enough rights to start/stop the agent service, as described above.
To run agent automatically on the machine boot under Linux, configure daemon process with the agent.sh start
command to start it and agent.sh stop
command to stop it. Refer to an example procedure below:
1. Navigate to the services start/stop services scripts directory:
cd /etc/init.d/ |
2. Open the build agent service script:
sudo vim buildAgent |
3. Paste the following into the file :
#!/bin/sh ### BEGIN INIT INFO # Provides: TeamCity Build Agent # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start build agent daemon at boot time # Description: Enable service provided by daemon. ### END INIT INFO #Provide the correct user name: USER="agentuser" case "$1" in start) su - $USER -c "cd BuildAgent/bin ; ./agent.sh start" ;; stop) su - $USER -c "cd BuildAgent/bin ; ./agent.sh stop" ;; *) echo "usage start/stop" exit 1 ;; esac exit 0 |
4. Set the permissions to execute the file:
sudo chmod 755 buildAgent |
5. Make links to start the agent service on the machine boot and on restarts using the appropriate tool:
For Debian/Ubuntu:
sudo update-rc.d buildAgent defaults |
For Red Hat/CentOS:
sudo chkconfig buildAgent on |
For macOS/Mac OS X, TeamCity provides the ability to load a build agent automatically when a build user logs in. For that, TeamCity uses standard macOS way to start daemon processes - LaunchDaemon plist
files.
To configure an automatic build agent startup, follow these steps:
buildAgent.zip
conf/buildAgent.properties
file (set agent name there, at least)Make sure that all files under the buildAgent
directory are owned by your_build_user
to ensure a proper agent upgrade process.
Load the build agent via command:
mkdir buildAgent/logs # Directory should be created under your_build_user user sh buildAgent/bin/mac.launchd.sh load |
You have to wait several minutes for the build agent to auto-upgrade from the TeamCity server. You can watch the process in the logs:
tail -f buildAgent/logs/teamcity-agent.log |
When the build agent is upgraded and successfully connects to TeamCity server, stop it:
sh buildAgent/bin/mac.launchd.sh unload |
After buildAgent upgrade from the TeamCity server, copy the buildAgent/bin/jetbrains.teamcity.BuildAgent.plist
file to $HOME/Library/LaunchAgents/
directory.
You can configure to start build agent on system boot, and place See this external posting for some more details on LaunchDaemons. |
The old |
Reboot
If you want to start several build agents, repeat the procedure of installing and starting build agent with the following changes:
Install the second build agent in a different directory
In conf/buildAgent.properties
, you should specify an unique name for the build agent
bin/agent.sh
scriptbin/jetbrains.teamcity.BuildAgent.plist
file, you should specify unique "Label
" parameter (which is jetbrains.teamcity.BuildAgent
by default)
jetbrains.teamcity.BuildAgent.plist
file to LaunchAgents
, you should give it a different nameTo stop the agent manually, run the <Agent home>\agent
script with a stop
parameter.
Use stop
to request stopping after the current build finished.
Use stop force
to request an immediate stop (if a build is running on the agent, it will be stopped abruptly (canceled))
Under Linux, you have one more option top use: stop kill
to kill the agent process.
If the agent runs with a console attached, you may also press Ctrl+C in the console to stop the agent (if a build is running, it will be canceled).
A TeamCity build agent is a Java application and it requires JDK version 6 or later to work. Oracle Java SE JDK 1.8.0_161 or later, 32-bit is recommended. Java download page
A build agent contains two processes:
The (Windows) .exe TeamCity distribution comes bundled with Java 1.8.0_161.
If you run a previous version of the TeamCity agent, you will need to repeat the agent installation to update the JVM.
Using x32 bit JDK (not JRE) is recommended. JDK is required for some build runners like IntelliJ IDEA Project, Java Inspections and Duplicates. If you do not have Java builds, you can install JRE instead of JDK.
Using of x64 bit Java is possible, but you might need to double the -Xmx memory value for the main agent process (see Configuring Build Agent Startup Properties and alike section for the server).
For the .zip agent installation you need to install the appropriate Java version. Make it available via PATH or available in one of the following places:
<Agent home>/jre
directoryTEAMCITY_JRE
, JAVA_HOME
or JRE_HOME
environment variables (check that you only have one of the variables defined). wrapper.java.command
property in the <agent home>\launcher\conf\wrapper.conf
file to a valid path to the Java executableIf a build agent uses a Java version older than the one required by agent (Java 6 currently), the agent will not be able to start and will be shown as disconnected.
If a build agent uses a Java version older than Java 8 (e.g. Java 6 or 7), you will see the corresponding warning on the agent's page and a health item in the web UI.
Support for Java prior to version 8 will be dropped in future TeamCity versions. Consider upgrading Java on the agent if you see the warning. |
To update Java on agents, do one of the following:
Upgrade the Java automatically: if the appropriate Java version of the same bitness as the current one is detected on the agent, the agent page provides an action to upgrade the Java automatically. Upon the action invocation, the agent process is restarted (once the agent becomes idle, i.e. finishes the current build if there is one) using the new java.
Upon the action invocation, the path to the detected Java is saved into the conf/teamcity-agent.jvm file, the agent process is restarted (once the agent becomes idle, i.e. finishes the current build if there is one) and uses the new java from the file. |
.exe
installation comes bundled with the required Java, you can just reinstall the agent using the .exe
installer obtained from the TeamCity server | Agents page.
In a rare case of updating the Java for the process that launches the TeamCity agent, use one of the options for the agent Java upgrade. |
You can install several TeamCity agents on the same machine if the machine is capable of running several builds at the same time. However, we recommend running a single agent per (virtual) machine to minimize builds cross-influence and making builds more predictable. When installing several agents, it is recommended to install them under different OS users so that user-level resources (like Maven/Gradle/NuGet local artifact caches) do not conflict.
TeamCity treats all agents equally regardless of whether they are installed on the same or on different machines.
When installing several TeamCity build agents on the same machine, please consider the following:
After having one agent installed, you can install additional agents by following the regular installation procedure (see an exception for the Windows service below), but make sure that:
workDir
and tempDir
directories in the buildAgent.properties
file.name
and ownPort
properties of buildAgent.properties
are unique.Make sure there are no build configurations with the absolute checkout directory specified (alternatively, make sure such build configurations have the "clean checkout" option enabled and they cannot be run in parallel).
Usually, for a new agent installation you can just copy the directory of the existing agent to a new place with the exception of its "temp", "work", "logs" and "system" directories. Then, modify conf/buildAgent.properties
with the new name
, ownPort
values. Please also clear (delete or remove the value) for the authorizationToken
property and make sure the workDir
and tempDir
are relative/do not clash with another agent.
If you use Windows installer to install additional agents and want to run the agent as a service, you will need to perform manual steps as installing second agent as a service on the same machine is not supported by the installer: the existing service is overwritten (see also a feature request).
In order to install the second agent, it is recommended to install the second agent manually (using .zip agent distribution). You can use Windows agent installer and do not opt for service installation, but you will lose uninstall option for the initially installed agent this way.
After the second agent is installed, register a new service for it as mentioned in the section above.
For step-by-step instructions on installing a second Windows agent as a service, see a related external blog post . |
See also:
Concepts: Build Agent |