Please visit my website and subscribe to my youtube channel for more articles

https://devops4solutions.com/

Installation

On Windows

Installing the server and the default agent

The steps involved in installing TeamCity using the installation package are as follows:

Continuing on, the installation copies the files and sets up TeamCity. The next bit of configuration that needs to be set is the port for the server. The default is 80.

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

covered the steps to get a basic installation of the TeamCity server and agent up and running.

Setting UP CI Server

Creating a project in TeamCity

Image for post
Image for post
Image for post
Image for post

SUBPROJECTS

TeamCity projects can themselves contain other projects. Subprojects are useful for hierarchical display and classification of builds, and also help in easily configuring and sharing similar settings and entities across projects. One use case of subprojects is to have subprojects for each branch/release version of a code base.

The root project is a special project that is the parent of every project and is automatically created. Furthermore, it cannot be deleted or have any build configurations of its own. The main purpose of the root project is to create and maintain settings and entities (such as VCS roots) for use by all projects in the server.

Adding build configurations

Build configurations in TeamCity are a collection of tasks that make a build, along with the settings needed to describe where the build fetches the source code from, when it runs, and what artifacts it produces.

or our sample project, we will begin by adding a build configuration named build. This build configuration will perform build activities such as checking the code for errors and running unit tests and coverage.

Image for post
Image for post

Click on VCS Settings to move to the next step of creating a build configuration.

Click on the Create and attach new VCS root button to go to the VCS creation page. The first step is to choose the VCS type. The choices include SVN, CVS, Perforce, Git, and Mercurial, among others

The Push URL setting is used to specify the URL through which we can push tags from the steps run in the build configuration. It is of use if we have to use a separate fetch URL for checking out and a separate push URL to which we can push tags. Leaving this setting empty will make use of the fetch URL for such push purposes too.

The Default branch is the branch that is to be checked and also monitored for changes. By default, it will be refs/heads/master, that is, the master branch.

Image for post
Image for post

When we are building release builds out of a branch, we can use that specific branch in this setting, say refs/heads/master/1.1.0. The Branch specification setting allows us to define additional branches/refs that need to be monitored for changes. Use tags as branches allows tags to be treated as branches in the Branch specification settings.

Username style defines how a user on TeamCity can link their username to authors of commits in the VCS. The default is Userid, which is ideal.

The Submodules settings define whether submodules must be checked while cloning/updating the repository. The default, and recommended, setting is to use Checkout, which means submodules are checked out and updated when the parent repository is cloned and updated. The other option is to ignore submodules.

Submodules are subrepositories contained within a parent Git repository. Submodules enable one repository to live within another as a subfolder but still be treated as a separate repository of its own. Consider the example of Build and Release scripts. They are common to many projects, and it is ideal to have them collocated with each project that needs them. Without duplicating such scripts, the Build and Release scripts can be maintained as a separate repository and added as submodules to the project repository that needs it.

Image for post
Image for post
Image for post
Image for post

INTRODUCING THE BUILD STEPS

Build steps are the individual sequential tasks that are performed within a build configuration.

We will choose the Command Line runner as the Runner type for the build configuration. This loads the necessary settings, which can be configured as shown in the following screenshot:

For the build build configuration, we will be adding two build steps. First we will perform code error, style, and complexity checking using the flake8 tool. The command to be used is:

flake8 --exclude=migrations --ignore=E501,E225,E128,E126 .

Next, we will run the unit tests of the project, using the following command:

python manage.py test
Image for post
Image for post
Image for post
Image for post

Devops Automation Enginneer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store