官术网_书友最值得收藏!

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:

  1. 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 the chmod +x /opt/TeamCity/bin/*.sh command.

  2. 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
      
  3. 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
      
  4. Once the server has been started, the web interface can be accessed at the default port, 8111.
  5. 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"
                    />
  6. The TeamCity web interface should present the TeamCity First Start page.
  7. The <TeamCity data> directory is located at $HOME/.BuildServer by default. Setting the TEAMCITY_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.
  8. 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:

  1. 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 the teamcity user in this case.

  2. Make sure that this file is made executable. This can be done with the following command:
    chmod +x /etc/init.d/teamcity-server
    
  3. The new init script needs to be enabled, which is done with the following command:
    update-rc.d teamcity-server defaults
    
  4. TeamCity server will now be started automatically once the system is restarted, and it will run as a daemon.
  5. 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:

  1. Additional agents can be easily installed from the Agents page (http://<serverUrl>:<serverPort>/agents.html).
  2. 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:
  3. The buildAgent.zip package can be extracted to /opt/TeamCityAgent using the following command:
    sudo unzip buildAgent.zip -d /opt/TeamCityAgent
    
  4. 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 to buildAgent.properties. In the file, the serverUrl property needs to be changed appropriately to point to the server.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
主站蜘蛛池模板: 和林格尔县| 繁峙县| 华坪县| 隆回县| 丹棱县| 麟游县| 敦煌市| 伊宁市| 洞口县| 双柏县| 都江堰市| 鄄城县| 晋宁县| 高邮市| 双桥区| 宁阳县| 诸暨市| 灌云县| 丰县| 吉木乃县| 兴文县| 玉环县| 左贡县| 甘德县| 耒阳市| 正宁县| 大丰市| 罗山县| 凤城市| 通渭县| 鄂托克前旗| 琼结县| 江油市| 长岭县| 夏邑县| 绥江县| 武城县| 凤凰县| 来凤县| 临沧市| 宁蒗|