- Learning Continuous Integration with TeamCity
- Manoj Mahalingam S
- 920字
- 2021-09-03 09:41:41
Installation on Linux
The TeamCity installation package (Teamcity-<version number>.tar.gz
) can be downloaded from the download page of http://www.jetbrains.com/teamcity/download/.
TeamCity needs JRE or JDK Version 1.6+ to be installed. It is ideal to have the JDK instead of the agent.
Note
The installation package is bundled with the Tomcat 7 servlet container. This is the recommended way to install TeamCity on Linux, unless you want to absolutely use your own installation of Tomcat or a different J2EE servlet container.
We will be using Ubuntu 12.04 for the following steps. It should be straightforward to adapt it to the distribution of your choice.
Running the server and the default agent
The steps involved in installing a server and agent on a Linux system are as follows:
- The downloaded installation package can be unpacked from the command line using the
tar
command:tar -xvzf TeamCity-8.0.4.tar.gz -C /opt
The archive is extracted to
/opt
(resulting in/opt/TeamCity
) using the preceding command.Tip
The scripts in
/opt/TeamCity/bin
may need to be marked as an executable using thechmod +x /opt/TeamCity/bin/*.sh
command. - The
runAll.sh
script found under/opt/TeamCity/bin
can be used to start and stop the server and the default agent:- To start both the server and the default agent, run the following command:
/opt/TeamCity/bin/runAll.sh start
- To stop both the server and the default agent, run the following command:
/opt/TeamCity/bin/runAll.sh stop
- To start both the server and the default agent, run the following command:
- The
teamcity-server.sh
script can be used to start the server alone:- To start the server, run the following command:
/opt/TeamCity/bin/teamcity-server.sh start
- To stop the server, run the following command:
/opt/TeamCity/bin/teamcity-server.sh stop
- To start the server, run the following command:
- Once the server has been started, the web interface can be accessed at the default port,
8111
. - The port can be changed by editing the highlighted section in the following piece of code from the
/opt/TeamCity/conf/server.xml
file:<Connector port="8111" protocol="org.apache.coyote.http11.Http11NioProtocol" connectionTimeout="60000" redirectPort="8543" useBodyEncodingForURI="true" socket.txBufSize="64000" socket.rxBufSize="64000" tcpNoDelay="1" />
- The TeamCity web interface should present the TeamCity First Start page.
- The
<TeamCity data>
directory is located at$HOME/.BuildServer
by default. Setting theTEAMCITY_DATA_PATH
environment variable can change it. The data directory location has to be chosen carefully as it stores all the data, including the build history and the artifacts. More information on the data directory can be found at http://confluence.jetbrains.com/display/TCD8/TeamCity+Data+Directory. - The first time installation asks you to agree to the license from the web interface, and you can also opt to send usage statistics to the developers. The initial administrator account also needs to be set up at this point.
Running the TeamCity server as a daemon
The previous steps are good for running the TeamCity server (and agent) manually using the provided scripts. It is often necessary and convenient to have the server start up automatically once the machine has restarted.
Tip
The steps given here are advanced and optional. This section can be skipped.
The following additional steps can be followed to set up a daemon for the TeamCity server:
- Create the file
/etc/init.d/teamcity-server
with the following contents:#!/bin/bash USER=teamcity BASE=/opt/TeamCity SCRIPT=$BASE/bin/teamcity-server.sh case "$1" in start) su -l $USER -c "$SCRIPT start" ;; stop) su -l $USER -c "$SCRIPT stop" ;; *) echo "Usage: teamcity-server start|stop" exit 3 esac
The previous script is a simple
init
script for the server. This script allows you (and the system) to start and stop the server. The server is run under theteamcity
user in this case. - Make sure that this file is made executable. This can be done with the following command:
chmod +x /etc/init.d/teamcity-server
- The new
init
script needs to be enabled, which is done with the following command:update-rc.d teamcity-server defaults
- TeamCity server will now be started automatically once the system is restarted, and it will run as a daemon.
- If needed, the server can be started and stopped by running
/etc/init.d/teamcity-server start
and/etc/init.d/teamcity-server stop
respectively.
Installing additional agents
Note
JRE or JDK 1.6+ is a prerequisite. (JDK is preferred for the agent, since the agent may have to perform some build tasks that need the JDK.)
The steps involved in running additional agents on the same machine or additional machines are as follows:
- Additional agents can be easily installed from the Agents page (
http://<serverUrl>:<serverPort>/agents.html
). - The Install Build Agents link on the top-right corner of this page can be used to download the agent installer (ZIP file distribution) directly from the server. The following screenshot shows the pop up that is presented once this link is clicked:
- The
buildAgent.zip
package can be extracted to/opt/TeamCityAgent
using the following command:sudo unzip buildAgent.zip -d /opt/TeamCityAgent
- Before starting the agents, the agent configuration properties have to be edited. The sample properties file
<TeamCity Agent Base directory>/conf/buildAgent.dist.properties
needs to be renamed tobuildAgent.properties
. In the file, theserverUrl
property needs to be changed appropriately to point to the server. - The default port for the agent is
9090
. The agent must be able to communicate with the server on the server's port, and the server must be able to communicate with the agent on this default port. - Similar to the server and default agent package, the scripts to run the agent can now be found at
/opt/TeamCityAgent/bin
. The agent can be started by running/opt/TeamCityAgent/bin/agent.sh start
or/opt/TeamCityAgent/bin/agent.sh run
. The former starts the agent in the background, whereas the latter will start it in the current console. - An
init
script can be added and enabled for the agent, similar to the one for the server, in order to run it as a daemon. - Agents need to be approved from the Agents page. Agents on the same machine as the server are approved automatically, whereas any other agent must be manually approved for it to be added to the list of available agents.
- HTML5+CSS3基礎開發教程(第2版)
- FreeSWITCH 1.6 Cookbook
- R語言編程指南
- Building Mobile Applications Using Kendo UI Mobile and ASP.NET Web API
- 詳解MATLAB圖形繪制技術
- Scala Data Analysis Cookbook
- Node學習指南(第2版)
- Mastering Python Design Patterns
- Learning Nessus for Penetration Testing
- 深入解析Java編譯器:源碼剖析與實例詳解
- PHP 8從入門到精通(視頻教學版)
- UML基礎與Rose建模實用教程(第三版)
- Ionic3與CodePush初探:支持跨平臺與熱更新的App開發技術
- Building a Media Center with Raspberry Pi
- Spring Boot學習指南:構建云原生Java和Kotlin應用程序