TeamCity is a Continuous Integration (CI) tool from JetBrains that works out of the box.

Declaration: Everything in this series is for the Jdk1.8 environment.



First of all, clarify a concept, what is CI, CI to achieve what purpose? In simple terms, CI is a software development practice in which different developers may submit code on a software project team every day, and it is unclear whether the code in the shared code base remains operational at all times. By continuously building and deploying the shared code base during the development process, you can test the runnable time of your code and find and fix problems early.

It can be seen that CI is an indispensable part of team projects.

There are many CI tools in the industry, such as Jenkins, CircleCI, GitLab CI, etc. This article will not discuss the advantages and disadvantages of each CI tool, but focus on the introduction of TC.

TC is a powerful and user-friendly CI tool with the following main functions:

1) Run parallel builds simultaneously across different platforms and environments

2) Optimize the code integration cycle and ensure that you never get broken code in the repository

3) View real-time test results reports by reordering the smart test

4) Java and.NET support: for Java and. NET run code coverage and repeat finder

5) Custom build duration, success rate, code quality and custom metrics statistics


Windows installation:

Make sure the Maven and Git software is installed and environment variables are configured correctly. That’s important.

1) download the exe setup: http://www.jetbrains.com/teamcity/download/

2) Select the functional components to be installed:



Build Agent: Build Agent, the carrier of actual code integration Build, is installed on the same Server as TC service Server by default. TCS support multiple build agents. The TC Server can connect to multiple build agents on different servers to work together. Please check it because you are currently in a walkthrough environment.

Server: TC service, which carries the core TC services and web UI. Select this parameter.

In addition, select Windows Service to install the Windows Service.

3) Select a port

The default port number is 80. You are advised to change it to 8111.



4) Configure Build Agent properties:



As can be seen from the figure above: The web address of the TC service is http://localhost:8111, the listening port of the buildAgent on the TC service is 9090, and the directory of the buildAgent is C:\Softapp\JetBrains\TeamCity2\buildAgent, that is, in the TC installation directory:



5) Use the system account to run the TC service and Build Agent service





6) Start the service



It can also be managed manually through the Windows Services administration panel.




Installation under Centos7:

It is important to ensure that git and Maven are installed and that the system environment variables are configured.

1) download the tar. Gz installer: http://www.jetbrains.com/teamcity/download/, and will install package sent to centos system, such as copy to/data/software/directory:



Install version 2018.1.2 below:

2) Decompress version 2018.1.2:

The tar XZVF/data/software/TeamCity – 2018.1.2. Tar. Gz

Generate the TeamCity directory and open it as follows:



See above:

Bin: stores TC executable files, such as runall. sh, startup.sh, shutdown.sh, and teamcity-server.sh.

BuildAgent: default buildAgent directory, where buildAgent files and execution information are stored;

Conf: TC configuration file directory, such as server. XML. You can change the TC service port.

Licenses: Store certificate files of TC;

Logs: stores execution log files.

3) Start the service

The runall. sh script can start TC Server and Build Agent at the same time. If Build Agent needs to be started separately, you can run teamcity-server.sh to start TC server.

  • At the same time start the TC server and Build Agent: nohup/data/software/TeamCity/bin/runAll. Sh start, corresponding to stop the service command: /data/software/TeamCity/bin/runAll.sh stop
  • Only start the TC server: nohup/data/software/TeamCity/bin/TeamCity – server. Sh start, corresponding to stop the service command: /data/software/TeamCity/bin/teamcity-server.sh stop

You are advised to use the runall. sh script.


TC service configuration:

In the web browser, open http://localhost:8111. If the centos server is a remote one, enable firewall 8111 and access http://[centos server IP address]:8111.

1) Configure TC Data storage Directory:



The TeamCity Data directory is the directory that the TeamCity server uses to store configuration information, build results, and file information for current operations. This directory is the primary store for all configuration Settings and holds data that is critical to the TeamCity installation.

By default, Proceed.

2) Configure the database



TeamCity can store build history, users, build results, and some runtime data in an SQL database for later troubleshooting.

These include the HSQLDB built-in database and other databases that can be persisted to disk, such as mysql.

HSQLDB is the default built-in database. It is not recommended to use HSQLDB.

When TeamCity is run for the first time, an internal database based on the HSQLDB database engine is recommended by default. The internal database is for evaluation purposes only; It works right out of the box and requires no extra setup. However, we strongly recommend using an external database as the back-end TeamCity database in a production environment. External databases are generally more reliable and provide better performance: internal databases can crash and lose all their data (for example, in the case of "insufficient disk space"). In addition, internal databases can become very slow on large data sets (for example, more than 200Mb of database storage files). Also note that if you use an internal database, our support does not cover any performance or database data loss issues. In short, do not use the internal HSQLDB database to produce TeamCity instances.Copy the code

We choose MySQL database:



You need to copy a jar of the mysql JABC connection to the lib/jabc directory of the data directory, or download it online.



Then create an empty database and run the following command:

create database <database-name> collate utf8_bin;
create user <user-name> identified by '<password>';
grant all privileges on <database-name>.* to <user-name>;
grant process on *.* to <user-name>;Copy the code

Then fill in the database connection information in the figure above and click Proceed.

Note: An empty database must be created and assigned, otherwise the following error may occur:

Found a TeamCity schema when expected an empty databaseCopy the code

3) The last step: Create the owner account information of the TC



Enter the user name and password, and click Create cCount to complete the TC configuration.


Ok, that’s all for this article, and the next article will cover the basic use of TCS.