
This is a standard pom.xml file, besides that, we have to pay attention to a few things. The TeamCity specific classes that we use in the Kotlin script are coming from the dependencies that we declare in the pom.xml as part of the Maven module.
#Teamcity kotlin download#
Right-click on the pom.xml file and select Add as Maven Project – the IDE will import the Maven module and download the required dependencies. Open the folder in IntelliJ IDEA, you will see the following layout:Įssentially, the. For instance, the following are the files checked in to version control for the spring-petclinic application. teamcity directory with two files: settings.kts and pom.xml. Opening the configuration in IntelliJ IDEA Now we can pull the changes from the settings repository and start editing. Once the Versioned Settings are enabled, TeamCity will generate the corresponding script and commit to the selected VCS root. The changes to the settings are then always reflected on the server. Hence, it is advised to enable the use settings from VCS option. When we use Kotlin DSL and make changes to the scripts in our favorite IDE, the “source of truth” is located in the VCS repository. In addition to this, it is possible to define which settings to take when the build starts.
#Teamcity kotlin code#
Hence, there will be 2 VCS roots in the project: one for source code of the application and the other for build settings. For our demo, however, we are going to use a specific VCS root dedicated to only the settings. The VCS root selected to store the settings can be the same as the source code of the application you want to build. In the project configuration, under Versioned Settings, select the Synchronization enabled option, select a VCS root for the settings, and choose Kotlin format. Regardless of whether you are starting from scratch or you have an existing project. To start using Kotlin build scripts in TeamCity the Versioned Settings have to be enabled. WARNING! Once you enable Versioned Settings for the project, TeamCity will generate the corresponding files and immediately commit/push them into the selected repository. To do that, we have to enable Versioned Settings in our project. The next step for this project is transitioning to configuration-as-code with Kotlin DSL. As a result, the new project will include one VCS root and a build configuration with a Maven build step and a VCS trigger. For our demo project, TeamCity will detect the presence of the Maven pom.xml and propose the required build steps. First, create a new project in TeamCity by pointing to a repository URL. It is best to add a Kotlin DSL configuration to an existing project in TeamCity. The goal of this post is to demonstrate an approach for building an existing application with Kotlin DSL. Spring Petclinic is a Java project that uses Maven for the build. In this tutorial, we are going to use the famous spring-petclinic project for demonstration.

#Teamcity kotlin how to#
We will start with the basics on how to get started with configuration-as-code in TeamCity.
#Teamcity kotlin series#
In this series of posts, we are going to explain how to use Kotlin to define build configurations for TeamCity. In TeamCity 2018.x Kotlin support was greatly improved for a more pleasant user experience. The possibility to use Kotlin for defining build configurations was added in TeamCity 10. In TeamCity, we can use Kotlin DSL to author build configurations. Some users may also prefer code to configuring the builds with point-and-click via UI. The benefits of this approach include versioning support via VCS repository, a simplified audit of the configuration changes, and improved portability of the configurations. Import project with the existing Kotlin scriptĬonfiguration as code is a well-established practice for CI Servers.Opening the configuration in IntelliJ IDEA.
