Personal tools
You are here: Home Software Development Continuous Integration TeamCity Install a Teamcity v9.x CentOS Build Agent

Install a Teamcity v9.x CentOS Build Agent

Use 'Agent Push' to install a build agent using ssh with public key authentication.

 

TeamCity Authentication

Ensure the Teamcity server user has a ssh key pair. (Note: if password based ssh authentication is used then this step can be skipped)

# su - teamcity
$ ssh-keygen -b 4096
$ cat ~/.ssh/id_rsa.pub

The public key text from 'id_rsa.pub' will need to be put into the 'authorized_keys' file of the Teamcity Ageny user (below).

Build Agent

Install prerequisites for the agent:

# yum install java-1.8.0-openjdk unzip wget java-1.8.0-openjdk-devel

Create a Teamcity build agent account on the agent machine. Add the Teamcity servers ssh public key to the 'authorized_keys' file of the Teamcity Agent account.

# adduser -r -m -c "TeamCity Build Agent" -d /srv/tcagent tcagent
# passwd tcagent
# su - tcagent
$ umask 022
$ mkdir .ssh
$ vi .ssh/authorized_keys

 

Teamcity

From the Teamcity web UI run the agent push wizard (see the log below) to install the agent software.

Init

Setup the teamcity agent to run when the machine is restarted.

Create a systemd service file '/lib/systemd/system/teamcity-agent.service'.

[Unit]
Description=TeamCity Build Agent
After=network.target

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/teamcity-agent
PIDFile=/var/lock/subsys/teamcity-agent.pid
ExecStart=/srv/tcagent/BuildAgent/bin/agent.sh start
ExecStop=/srv/tcagent/BuildAgent/bin/agent.sh stop
User=tcagent

[Install]
WantedBy=multi-user.target

Create a configuration file (this can be used to set JVM parameters)

# touch /etc/sysconfig/teamcity-agent
# systemctl enable teamcity-agent

Links

 

Appendices

Agent Push Log

[15:30:36]: AgentPush v30168 - Install Agent on remote host
[15:30:36]: Looking for Target Host...
[15:30:36]: Validating TeamCity Server Root URL 'https://teamcity.lucidsolutions.co.nz' ...
[15:30:36]: WARNING: Cannot open connection to 'https://teamcity.lucidsolutions.co.nz'.
[15:30:36]: WARNING: Make sure your Server URL is specified correctly on Administration/Server Configuration page. Server should be accessible by the URL from the target machine.
[15:30:36]: Starting agent push to 'khaki.lucidsolutions.co.nz'(IP: 10.20.20.4) using preset 'Khaki' (Username 'build'. Target platform: 'Unix')
[15:30:36]: Checking Platform...
[15:30:38]: bash: sw_vers: command not found
[15:30:42]: Linux khaki.lucidsolutions.co.nz 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[15:30:44]: Detected Platform: Linux (Linux khaki.lucidsolutions.co.nz 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux)
[15:30:44]: Determining installation path...
[15:30:47]: SHELL=/bin/bash
[15:30:47]: SSH_CLIENT=10.20.20.2 40209 22
[15:30:47]: USER=build
[15:30:47]: MAIL=/var/mail/build
[15:30:47]: PATH=/usr/local/bin:/usr/bin
[15:30:47]: PWD=/home/build
[15:30:47]: SHLVL=1
[15:30:47]: HOME=/home/build
[15:30:47]: LOGNAME=build
[15:30:47]: SSH_CONNECTION=10.20.20.2 40209 10.20.20.4 22
[15:30:47]: _=/usr/bin/env
[15:30:49]: The Agent will be installed to /home/build/BuildAgent on 'khaki.lucidsolutions.co.nz'
[15:30:49]: Uploading installation script bootstrapper.sh into remote directory /home/build/BuildAgent ...
[15:30:55]: Starting upload of bootstrapper.sh to khaki.lucidsolutions.co.nz
[15:30:55]: 4212 bytes got
[15:30:55]: 4212 bytes transferred
[15:30:59]: Running script 'bootstrapper.sh' on 'khaki.lucidsolutions.co.nz'
[15:31:01]: [khaki.lucidsolutions.co.nz] Agent installation is executing on 'khaki.lucidsolutions.co.nz'...
[15:31:01]: [khaki.lucidsolutions.co.nz] Restoring user's environment...
[15:31:01]: [khaki.lucidsolutions.co.nz] Looking for existing installations...
[15:31:01]: [khaki.lucidsolutions.co.nz] Downloading Agent's Installation from https://teamcity.lucidsolutions.co.nz to /home/build...
[15:31:01]: [khaki.lucidsolutions.co.nz] Looking for 'wget'...
[15:31:01]: [khaki.lucidsolutions.co.nz] 'wget' found:
[15:31:01]: [khaki.lucidsolutions.co.nz] GNU Wget 1.14 built on linux-gnu.
[15:31:01]: [khaki.lucidsolutions.co.nz] +digest +https +ipv6 +iri +large-file +nls +ntlm +opie +ssl/openssl
[15:31:01]: [khaki.lucidsolutions.co.nz] Wgetrc:
[15:31:01]: [khaki.lucidsolutions.co.nz] /etc/wgetrc (system)
[15:31:01]: [khaki.lucidsolutions.co.nz] Locale: /usr/share/locale
[15:31:01]: [khaki.lucidsolutions.co.nz] Compile: gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/etc/wgetrc"
[15:31:01]: [khaki.lucidsolutions.co.nz] -DLOCALEDIR="/usr/share/locale" -I. -I../lib -I../lib -O2 -g -pipe
[15:31:01]: [khaki.lucidsolutions.co.nz] -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
[15:31:01]: [khaki.lucidsolutions.co.nz] --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
[15:31:01]: [khaki.lucidsolutions.co.nz] Link: gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
[15:31:01]: [khaki.lucidsolutions.co.nz] -fstack-protector-strong --param=ssp-buffer-size=4
[15:31:01]: [khaki.lucidsolutions.co.nz] -grecord-gcc-switches -m64 -mtune=generic -lssl -lcrypto
[15:31:01]: [khaki.lucidsolutions.co.nz] /usr/lib64/libssl.so /usr/lib64/libcrypto.so /usr/lib64/libz.so
[15:31:01]: [khaki.lucidsolutions.co.nz] -ldl -lz -lz -lidn -luuid -lpcre ftp-opie.o openssl.o http-ntlm.o
[15:31:01]: [khaki.lucidsolutions.co.nz] ../lib/libgnu.a
[15:31:01]: [khaki.lucidsolutions.co.nz] Copyright (C) 2011 Free Software Foundation, Inc.
[15:31:01]: [khaki.lucidsolutions.co.nz] License GPLv3+: GNU GPL version 3 or later
[15:31:01]: [khaki.lucidsolutions.co.nz] <http://www.gnu.org/licenses/gpl.html>.
[15:31:01]: [khaki.lucidsolutions.co.nz] This is free software: you are free to change and redistribute it.
[15:31:01]: [khaki.lucidsolutions.co.nz] There is NO WARRANTY, to the extent permitted by law.
[15:31:01]: [khaki.lucidsolutions.co.nz] Originally written by Hrvoje Niksic <hniksic@xemacs.org>.
[15:31:01]: [khaki.lucidsolutions.co.nz] Please send bug reports and questions to <bug-wget@gnu.org>.
[15:31:01]: [khaki.lucidsolutions.co.nz] --2014-10-28 15:31:01-- https://teamcity.lucidsolutions.co.nz/update/buildAgent.zip
[15:31:01]: [khaki.lucidsolutions.co.nz] Resolving teamcity.lucidsolutions.co.nz (teamcity.lucidsolutions.co.nz)... 2001:4428:225:7::2, fd0c:898b:471c:7::2, 10.20.7.2
[15:31:01]: [khaki.lucidsolutions.co.nz] Connecting to teamcity.lucidsolutions.co.nz (teamcity.lucidsolutions.co.nz)|2001:4428:225:7::2|:443... connected.
[15:31:02]: [khaki.lucidsolutions.co.nz] HTTP request sent, awaiting response... 200 OK
[15:31:02]: [khaki.lucidsolutions.co.nz] Length: 13219128 (13M) [application/zip]
[15:31:02]: [khaki.lucidsolutions.co.nz] Saving to: 'buildAgent.zip'
[15:31:02]: [khaki.lucidsolutions.co.nz] 0K ........ ........ ........ ........ ........ ........ 23% 7.23M 1s
[15:31:03]: [khaki.lucidsolutions.co.nz] 3072K ........ ........ ........ ........ ........ ........ 47% 12.8M 1s
[15:31:03]: [khaki.lucidsolutions.co.nz] 6144K ........ ........ ........ ........ ........ ........ 71% 12.5M 0s
[15:31:03]: [khaki.lucidsolutions.co.nz] 9216K ........ ........ ........ ........ ........ ........ 95% 12.4M 0s
[15:31:03]: [khaki.lucidsolutions.co.nz] 12288K ........ . 100% 12.6M=1.2s
[15:31:03]: [khaki.lucidsolutions.co.nz] 2014-10-28 15:31:03 (10.7 MB/s) - 'buildAgent.zip' saved [13219128/13219128]
[15:31:03]: [khaki.lucidsolutions.co.nz] Extracting agent into '/home/build/BuildAgent'...
[15:31:04]: [khaki.lucidsolutions.co.nz] Launching Agent installation...
[15:31:04]: [khaki.lucidsolutions.co.nz] Installing TeamCity Agent for https://teamcity.lucidsolutions.co.nz
[15:31:04]: [khaki.lucidsolutions.co.nz] Looking for Java Runtime Environment...
[15:31:04]: [khaki.lucidsolutions.co.nz] Java executable is found in '/usr/bin/..'.
[15:31:04]: [khaki.lucidsolutions.co.nz] Configuring the Agent's properties...
[15:31:04]: [khaki.lucidsolutions.co.nz] /home/build/BuildAgent/bin
[15:31:04]: [khaki.lucidsolutions.co.nz] Starting the Agent under 'build' account...
[15:31:04]: [khaki.lucidsolutions.co.nz] Starting TeamCity build agent...
[15:31:04]: [khaki.lucidsolutions.co.nz] Java executable is found in '/usr/bin/..'.
[15:31:04]: [khaki.lucidsolutions.co.nz] Starting TeamCity Build Agent Launcher...
[15:31:04]: [khaki.lucidsolutions.co.nz] Agent home directory is /home/build/BuildAgent
[15:31:05]: [khaki.lucidsolutions.co.nz] Current Java runtime version is 1.7
[15:31:05]: [khaki.lucidsolutions.co.nz] Lock file: /home/build/BuildAgent/logs/buildAgent.properties.lock
[15:31:05]: [khaki.lucidsolutions.co.nz] Using no lock
[15:31:05]: [khaki.lucidsolutions.co.nz] Done [22558], see log at /home/build/BuildAgent/logs/teamcity-agent.log
[15:31:05]: [khaki.lucidsolutions.co.nz] WARNING: The TeamCity Agent installed as standalone application and will not start automatically on machine reboot.
[15:31:05]: [khaki.lucidsolutions.co.nz] Cleaning temporary installation's resources...
[15:31:05]: [khaki.lucidsolutions.co.nz] Successfully installed build agent on 'khaki.lucidsolutions.co.nz' to '/home/build/BuildAgent'
[15:31:06]: Remote agent installation successful.

 

 

Document Actions