Using JetBrains TeamCity

JetBrains TeamCity is a commercial continuous integration server. TeamCity has a Professional Server license. This means that we can create 20 build configurations and one build agent. If we need more configurations or build agents, we can purchase other licenses. In this section, we will see how to create a build plan with Gradle.

We can download installer software for Mac OS X, Windows, and Linux from the JetBrains TeamCity website. We run the installer software to install TeamCity on our computer. TeamCity is also available as an archive for all platforms. To install the archive, we only have to unpack the contents to a directory on our computer. TeamCity is also available as a WAR file, which can be deployed to a Java web container.

Creating a project

In TeamCity we must create a project with the build configuration we want to be executed. Let's see how we can add a project:

  1. After we install TeamCity, we will open a web browser and go to  http://localhost:8111/ . We can create a new project from the Administration page. We can also define the name of our project and provide a short description:

    Creating a project

    Creating a new project in TeamCity

  2. We will then click on the Create button to create the project and go to an overview page of our project:

    Creating a project

    Project overview page

  3. It is time to add a new build configuration. We will click on the Create build configuration button in the Build Configurations section to add a build configuration:

    Creating a project

    Creating a new build configuration

  4. We will click on the Create button to create the project and go to the version control settings page of our project. Here, we fill in the properties of our local Git repository:

    Creating a project

    Configuration for version control management

  5.  We will click on the Create button to create the project and go to an overview page of our project:

    Creating a project

    Overview of configuration for version control

  6. We will define the artifacts of our project on the General Settings page. We can define the path of the artifacts in our project in the Artifact paths field. Here, We defined the value build/libs/*.jar in the Artifact paths field.:

    Creating a project

    Configuration of the artifacts of the project

  7. On the project overview screen, we will click on the Add Build Step button. We are taken to a new screen, where we can select the Runner type of the build. Here, we will select the Gradle runner and click on the Save button:

    Creating a project

    Defining a new build step with Gradle

  8. We are on the configuration page for the build step now, as shown in the following screenshot:

    Creating a project

    Configuration for Gradle build step

  9. We can fill a descriptive name for this build step in the Step name field. In the Gradle Parameters section, we can set the tasks in the Gradle tasks field. For our project, we want to invoke the build task, so we will fill build. Note that we can enable Incremental building for multi-project builds. TeamCity will use the buildDependents task.
  10. To set the Gradle version, we will fill the Gradle home path field. Extra command-line parameters can be filled in the Additional Gradle command line parameters field.
  11. If our project has a Gradle Wrapper, we can check the Gradle Wrapper checkbox. TeamCity will then use the gradlew or gradlew.bat scripts, instead of the Gradle home path location, to run Gradle.

Running the project

We can save the build configuration, and we are now ready to run it as follows:

  1. At the top-right side, we can see the Run button with an ellipsis. When we click on the ellipsis, we will get a dialog window with options that we can set before we run the build, as shown in the following screenshot:

    Running the project

    Running the project with the Gradle build step

    We will leave all the options unchanged and click on the Run Build button.

  2. TeamCity instructs the build agent to run our build configuration. The code is checked from the repository, and the build Gradle task is invoked. On the Projects page, we will see a summary of the build:

    Running the project

    Results after running the project

  3. We can click on the project to get more details. The following overview page of the project shows the date of the project build, build agent used, and summary of test results:

    Running the project

    More details for a project that has run

  4. If we click on the Tests tab, we will see the tests that have run and the time it took to execute them:

    Running the project

    Overview of test results

  5. The Build Log tab page shows the output of the build process. We will see detailed information here:

    Running the project

    TeamCity logging for running the project

  6. Finally, on the Artifacts page, we will see the generated JAR files. We can click on the filename and see the contents of the files:

    Running the project

    Overview of artifacts for the project

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.36.38