October 13, 2020 Jonny Steiner

Improve your CI/CD Testing with our Overview of TeamCity

Share this knowledge!

TeamCity by JetBrains is a continuous integration server and build management tool that has become quite popular. Most importantly, in software development circles. The tool enables developers to easily integrate CI/CD tasks and manage the entire environment from a central dashboard. By installing the CI server as a windows service, you can easily start or stop it from the Windows Services tab. Similarly, the GUI interface makes it easy to view and manage build and deployment tasks, even for novice users. The tool comes as a proprietary commercial software offering.

History and Main Concepts

JetBrains is a popular software company that was started in 2000. Within a quick time, it has evolved to operate with 1200+ employees in 213 countries and territories and win 80+ industry awards. The company now offers 28 products and has a user base of 8M+. IntelliJ is a popular IDE offered by JetBrains.

TeamCity was developed by JetBrains in 2006. It is written in Java and supports .NET and Ruby platforms. The tool comes integrated with popular IDEs such as Eclipse, IntelliJ, and Visual Studio and supports popular version control systems such as Subversion, CVS, Mercurial, and Git. One important feature of TeamCity is that it allows you to simultaneously run multiple build tests on different platforms and environments.

It helps you to keep your code base clean as you can build, run, and check tests before you commit changes to the server. It reports failures while the build is running which means you don’t have to wait till the build is finished to identify errors. With project hierarchy, templates, and chain dependencies, the tool offers a smart configuration. As it offers 100+ plugins, developers can integrate external plugins to efficiently run different processes. The tool runs pretty faster and scales well. It allows you to run multiple builds and deploy them using the REST API from within the tool. With a detailed summary of each build, you get a clear understanding of how your tests are running and easily deploy specific builds to production.

Using the Kotlin DSL, you can run configuration scripts to set up CI/CD pipeline and reuse the code as well. Kotlin DSL scripts are server-agnostic and project-agnostic, making your configuration scripts highly portable. You can scale out build agents on your Kubernetes cluster or on the cloud-based VMware vSphere, Amazon EC2, and Microsoft Azure environments. With a clear visualization of the entire CI/CD environment, you get the right insights into tests and trends and proactively monitor code quality.

The tool comes in two versions; a free version and an Enterprise edition. The free tool comes with all features included in the Enterprise edition. It offers 100 build configurations and 3 build agents with unlimited users and unlimited build time. You can start free and scale up as your network expands using the flexible licensing options.

Installation

The installation of TeamCity is a pretty simple process. You can simply download the .exe file and run it. The tool can be installed as a windows service. In a Windows-based GUI environment, configuring it is also easy and simple. To run the TeamCity CI server, you need the following components.

Step 1: Install Java and configure Environment Variables

TeamCity supports Java JDK 1.7 and above. You can use the latest version of Java as well. To download Java JDK, visit the following link:

https://www.oracle.com/in/java/technologies/javase-downloads.html

Download the JDK .exe file from the above link. After the download is completed, double-click the .exe file and follow the wizard instructions to install Java.

After Java is installed on your machine, you need to configure Environment Variables by adding the Java path.

To do so, open System -> Advanced System Settings -> Advanced -> Environment Variables

Under ‘User variable for user’, enter the name as ‘JAVA_HOME’ and provide the JDK path. Under the ‘System variables’ tab, enter the Java bin folder path.

To check if Java is working properly, open the command prompt, and type the following command:

  • java –version

It will display the java version and details.

Step 2: Install Eclipse IDE

To create and run test scripts, you need to install an IDE. Eclipse is a popular Java IDE. You can download Eclipse from this link:

https://www.eclipse.org/downloads/

After the file is downloaded, double-click it to install Eclipse IDE.

Step 3: Install the Gradle Build Tool

To automate the build process, you need a build tool. Gradle is a popular build tool for Java projects. To use Gradle, visit the following link.

https://gradle.org/install/

The Gradle distribution is available as a Zip file. Unzip it and save it in a folder.

Similar to Step 1, configure environment variables. Add the Gradle path to system variables.

Step 4: Install TestNG

Here is the link to install TestNG in Eclipse:

https://dl.bintray.com/testng-team/testng-eclipse-release/

Open Eclipse IDE and click on Help-> Install New software. In the search bar, paste the above link and install TestNG.

Step 5: Create a Java Project in Eclipse

  • Open Eclipse IDE and click on New-> Java Project
  • Provide a name and create a Java project. (eg: ExperitestProject)
  • Right-click on the project and create a new package.
  • Right-click on the project and create a new class under that package.

Now, open the class file and type the following code:

package ExperitestPackage;

import org.openqa.selenium.*;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.net.URL;

public class ExperitestSearch {

private static final String ACCESS_KEY = "Enter your token here";
    private RemoteWebDriver driver;
    private URL url;
    private DesiredCapabilities dc = new DesiredCapabilities();

    @BeforeMethod
    public void setUp() throws Exception {

        url = new URL("https://cloud.seetest.io/wd/hub");
        dc.setCapability(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
                dc.setCapability(CapabilityType.PLATFORM, Platform.ANY);
        dc.setCapability("accessKey", ACCESS_KEY);
        dc.setCapability("testName", "Quick Start Chrome Browser Demo");
        driver = new RemoteWebDriver(url, dc);
    }

    @Test
    public void browserTestGoogleSearch() {
        driver.get("https://www.google.com");
        new WebDriverWait(driver, .until(ExpectedConditions.presenceOfElementLocated(By.name("q")));
        WebElement searchBar = driver.findElement(By.name("q"));
        searchBar.click();
        searchBar.sendKeys("Experitest");
        searchBar.sendKeys(Keys.ENTER);
    }

    @AfterMethod
    public void tearDown() {
        System.out.println("Report URL: "+ driver.getCapabilities().getCapability("reportUrl"));
        driver.quit();
    }
}

Step 6: Create a Github Repository

Git is a popular version control system. You can use it to store and manage your code. Visit this link to create a new account in Github:

https://github.com/join

Enter your details and create a new account. Verify your email and login to the GitHub account.

  • Create a new repository (eg: Selenium Test Automation)

Now, you can directly commit code changes to the repository from Eclipse.

  • To do so, right-click on your project and click on Team -> Share Project
  • Configure the new repository. When the new repository is configured, you can directly connect to your repo from Eclipse.

Step 7: Install Tomcat

Apache Tomcat is a popular test environment server that allows you to deploy build artifacts to a web container for testing purposes.

To install Apache Tomcat, visit this link:

https://tomcat.apache.org/

Download the file and install it. After Tomcat is installed, open your browser and type the following command:

http://localhost:8080 

tomcat install

You can see that Tomcat is successfully installed.

Step 8: Install TeamCity

Now that you have the CI components ready, go ahead and install TeamCity from this link:

https://www.jetbrains.com/teamcity/download/#section=get

There are two available versions. You can either download the .exe file for Windows or choose the portable .tar file for Linux/macOS.

Get TeamCity

When the .exe file is downloaded, double-click it to begin the installation procedure.

Welcome to TeamCity

Click next. On the next screen, accept the license agreement and click next.

Team City Agreement

Choose the installation folder and click next.

TeamCity folder

Select the components you want to install and click next.

TeamCity select components

The installation process begins.

TeamCity installation

After the setup is completed, choose the server port. The default port for TeamCity is 80. However, you can choose an alternative port if you have any other server running on this port.

TeamCity port

Configure build agent properties.

TeamCity build agent

Select the service account for the server as well as the agent.

TeamCity User account

On the next screen, select the services you want to start and click next. (Build Agent and Server)

Team City Build Agent

So, you are done with the installation. Click finish.

TeamCity complete

To open the TeamCity server, open a browser and type the following command:

http://localhost

It will open the TeamCity server.

TeamCity first start

Now, you need to configure a few settings. Firstly, specify the directory where you want to store server configurations, build results, and project definitions. You can choose the default one or specify another directory and click proceed.

TeamCity is starting

On the next screen, choose the database to be connected to the server. You can choose the internal database or specify another one. Click on ‘proceed’.

TeamCity connection setup

TeamCity new database

The tool starts creating a new database. On the next screen, accept the license agreement.

TeamCity agreement

Now, create an admin account to manage the server.

TeamCity admin account

On the next screen, create your profile by entering your name, and email. When you specify the email address, the server will send notifications to that email address. Click on Save.

Now, the CI server is ready for use.

To open the server, open the browser and type http://localhost/login

The server opens up. If you choose to automatically start the server when Windows starts, the server will automatically start. Else, you have to go to Windows services and start the service.

To do so, click on Windows -> Run and type services.msc.

It will display all windows services. Search for TeamCity server and build agent and click on start.

You can see that the server and one build agent are running. When you can click on Agents, you can see the agent details.

TeamCity UserPC

Running your TeamCity Server

To run your first project on TeamCity, click on projects, and then click on ‘Create project’.

TeamCity create project

Enter the repository URL and provide the username and password of your Git account and click save.

TeamCity Create Project

When you click on ‘Proceed’, the tool will check if VCS is accessible. It will give a message that connection to VCS has been verified. Now, provide a project name and build a configuration name and click on proceed.

Team City URL

Now, you can see a message that a new project, build configuration and VCS are successfully created. The tool will scan for build steps and settings automatically. If there are no builds you can create them manually.

Team City Build

To create build steps manually, click on ‘configure build steps manually’. Choose a build tool in the next screen (eg: Gradle)

On the next screen, provide Gradle details such as task, and path.

TeamCity Gradle

Now, a build plan is added.

TeamCity Build

Now, click on Run to start the build process. It will start the build process.

TeamCity Execute

TeamCity provides the details of each step taking place during the build process.

Eg: Collecting changes, starting the build, updating tools, and publishing artifacts.

TeamCity #4

When you go to the dashboard and click on the build plan, you can see a list of all your builds. When you click on a build process, you can see the details of that build.

TeamCity Experitest Build

So, the build process is successfully completed. You can create up to 100 build plans and use 3 build agents to run these plans.

Running Continuous Deployment

TeamCity enables you to automatically deploy artifacts to a web container such as Apache Tomcat. To do so, open your project and create another build configuration.

TeamCity Build Configuration

Simply choose the build configuration type as ‘Deployment’.

TeamCity Build

Provide the artifacts path and target details. TeamCity provides an easy way to add artifacts details. You can use parameters or just click on the tree symbol beside the artifacts box. It will provide the list of artifacts generated during the build in a hierarchy format. You can simply click the items you want to deploy to the test environment.

After entering all the details, click Save. Now, you can simply click on the ‘Deployment’ and it will deploy the artifacts to the testing server.

Automate Deployments with Octopus Deploy

To automate this deployment process, you can integrate Octopus Deploy with your TeamCity server. Octopus Deploy is a popular deployment automation tool.

To install the Octopus plugin, open Administration settings and click on ‘Plugin List’.

plugin list

On the Plugins List page, click on the ‘Browse plugin repository’.

TeamCity plugin list

Select ‘Octopus Deploy Integration’. It will open the plugin page. Click on ‘Get’.

octopus deploy

Now, you can see the Octopus plugin in your TeamCity plugin list.

plugins list

Click on it and then click on install.

install

Now, you need to enable the plugin. Click on ‘Enable’.

enable

Now, the Octopus Deploy plugin is successfully installed and enabled.

To use the Octopus Deploy plugin, create a new build step, and select the Runner Type as ‘Octopus Deploy: Pack’.

Deployment

Enter all the details and click on save. When you are done with the configuration, click on the Deploy button and it will deploy the artifacts to the testing environment.

Configure TeamCity Tools

TeamCity is a comprehensive CI/CD tool that enables you to integrate all your CI tools with ease. When you open your account and click on ‘My Settings & Tools’, you can see the listed tools on the right side.

tools

You can integrate your IDE tools such as IntelliJ, Visual Studio, and Eclipse.

To integrate Eclipse, copy the update site link of Eclipse Plugin and open Eclipse.

Go to Help-> Install new software.

Copy the link and click on add.

update eclipse

It will show the JetBrains TeamCity plugin. Select it and click on next.

available software eclipse

Review the items on the next screen and click next. Accept the license agreement on the next screen and click finish. It will install the Teamcity plugin in eclipse. Restart Eclipse.

When you open Eclipse, you can see the TeamCity tab. Using the options in this tab, you can log in, log out, view changes, and perform the remote run.

remote run

Now that the TeamCity CI server setup is completely configured, you can start using it to build, deploy, and manage your CI/CD environments.

The new addition to the tool is an intuitive web UI design. However, you can always switch to Classic UI any time by clicking on the icon on the top right corner of the page.

overview

Summary of TeamCity by JetBrains

TeamCity is a powerful CI integration server that enables developers to effectively manage CI/CD environments. The good thing about this tool is the intuitive interface that makes it easy for anyone to navigate through all options. Installing and configuration of the tool is simple and easy.

The striking feature of the tool is its support. You can find extensive documentation for every step. Moreover, the tool enjoys a large and vibrant community that is ready to offer help to users. Overall, TeamCity is a comprehensive CI tool that allows you to enjoy premium features for free for your small and medium projects. As your business scales up, you can subscribe to the enterprise edition. Integrate it with SeeTest today.

Guy ArieliCTO

Share this knowledge!