Blog

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

So, after all, it seems JetBrains is very serious with Kotlin. And I have to admit it comes with some handy features and good IDE support. But this is not about the Kotlin language, this is about where it can be used.

As we have seen in Migrating from Gradle to Gradle there is support to write your  writing Gradle build scripts in a using the new Kotlin DSL is supported. So far we have

  • our sources in Kotlin
  • our build configuration in Kotlin
  • but not our Continuous Integration configuration
    (depending on how far you want to push it your build chain or pipeline as well)

...

  • it real source code
  • it compiles
  • you can share common pipeline definitions via libraries
  • since Kotlin is a typed language, there is a nice support for in your IDE with auto-completion
  • you can compile the code prior to pushing it - compared to the try and error cycle that yaml YAML config files come with, I'll argue its it is the better method

There is a very nice Blog from JetBrains on this topic that I can highly recommend to read:

...

Since I consider you know to be convinced lets let us test-drive it! We first need a TeamCity Server, a TeamCity Agent, and an example project.

To have it quickly setup set up to test-drive, I created a docker-compose.yaml file (yes a yaml file, isn't it ironic): https://github.com/brontofundus/kotlin-all-the-things

...

Code Block
languagebash
$ docker-compose pull
$ docker-compose up -d

Then point a browser to: to http://localhost:8111/

This will bring you to the TeamCity installer. But don't panic, it will only take a few minutes!




Proceed

Image Modified

  • Select PostgreSQL
  • download the driver
  • and use the same settings as used in the docker-compose file:
    • "postgres" as host
    • "teamcity" as username, password and database name

Proceed

Image Modified

Wait

Image Modified

Scroll down and agree to the license
(well read it of course - but don't tell me you are not used to
sell
selling your soul)

Image Modified

Create an admin account

(for simplicity use "admin" and "password" here)


Image Modified

There
your
you are

Image Modified

As you may notice on top there are 0 agents. Which is not entirely true.

But to have the one we have enabled it needs to be authorized first


Go to "Agents" and "Unauthorized" and enable the agent

Image Modified

If you now go to the start page (click on the logo on the top left) you will be able to add a project

Image Modified

Builds run already

Image Modified


If you have a close look at the project you will notice it contains a ".teamcity" directory that contains the build configuration: https://github.com/brontofundus/gradle-groovy-kotlin-dsl/tree/kts/.teamcity

...

Since you probably use IntelliJ to develop in Kotlin anyway and you now have a running TeamCity server from the same company, even more, comfort is possible!

Just install the TeamCity plugin in IntelliJ and point it via the new menu entry to your local server.

This will show the build status of your projects, but in addition, also allows you to run your local changes remotely as personal build! This is not a new feature but people tend to forget about it:



Install the plugin in IntelliJ

Image Modified

Restart and point it to the local TeamCity server
(we used "password" as password above)

Image Modified

And you can now remote run builds with local changes!

Image Modified

Even with not yet
commited
committed changes

Image Modified

Personal builds have this nice additional icon to mark personal builds. These are only visible to the user that created them

Image Modified

If you create an additional user and re-login you will not see other peoples personal builds

Image Modified


So we have:

  • our software in Kotlin
  • our Gradle build script in Kotlin
  • our CI configuration in Kotlin - able to share and re-use our build chains 
    (read the JetBrains blog above for more details on this)
  • and free of charge with this setup: remote runs

...