How to handle shared configs across multiple versions settings

I have two projects that share part of their tech stack. Both are in their own repositories and each has versioned settings enabled in their repositories. How do you now most cleverly manage, for example, a template including build scripts that should be used in both projects? I would ideally like to manage this also under version control in Kotlin DSL without duplicating the code in both repositories.

1
5 comments
Hi,

The approach we’re considering is extracting the common logic into a custom Kotlin DSL library—This would allow both projects to reference the same shared code while keeping their own DSL configuration clean and maintainable.

For more detailed information, please refer to https://www.jetbrains.com/help/teamcity/kotlin-dsl.html#Add+Custom+Kotlin+Libraries.

Best Regards,
Tom
1

Hello Tom,

Thank you for the information. I have two additional questions:

  1. Is there a tutorial available for creating the .jar library mentioned in the documentation? Apart from Kotlin DSL, I have no experience with Java and/or Kotlin.
  2. Based on the linked documentation, am I correct in assuming that I can only use this .jar library in projects that use versioned settings? Or could I, for example, somehow use templates from this library in projects that don't use versioned settings?

Thank you for the support sebingel

0
Hi sebingel,

Since you're not very familiar with Java/Kotlin DSL, using recipes would be a helpful approach in your case.

For more detailed guidance, please refer to the documentation here:
https://www.jetbrains.com/help/teamcity/working-with-meta-runner.html#Extract+a+Recipe+From+a+Build+Configuration

Best Regards,
Tom
0

Hey Tom, thanks for your answer. Recipes have two problems in my scenario:

  1. I would either have to maintain the recipe on the server without version control, or manually copy it to the server again after each modification. OR duplicate it to both projects.
  2. Apart from using inline scripts, I don't know of any way to use helper scripts in build steps in recipes. However, inline is not an alternative for us.

I have no problem learning Kotlin/Java and creating simple JAR libraries. I just need a starting point, and a TeamCity-centered tutorial would have been a good starting point. If something like this is not available I will need to look in a more generalized resource.

Thank you for the support,
sebingel

0
Hi sebingel,

Thanks for your detailed information.

Glad to hear that you're interested in learning Kotlin/Java!
If you're looking to use Kotlin with TeamCity, a great starting point is the official documentation on TeamCity Kotlin DSL:
https://www.jetbrains.com/help/teamcity/kotlin-dsl.html

To help you get hands-on quickly, you can also check out this TeamCity Kotlin DSL tutorial series on YouTube:
https://www.youtube.com/watch?v=Mxa-eHMe2w8&list=PLQ176FUIyIUaW-RqAJLbSZe59l6r7t8wp

Additionally, if you plan to create a custom JAR library using IntelliJ IDEA, this video guide might be helpful:
https://www.youtube.com/watch?v=L1ZMVvz1yHU

Best Regards,
Tom
1

Please sign in to leave a comment.