Kotlin variables file used from TC DSL

I have been using Kotlin to script TC but find that I still see no real advantage as my configurations have repeated items (as TC has no way of sharing steps).  I was hoping Kotlin would help with this by having a Kotlin file which simply holds all my steps and then I can just reference from the configuration files, is that possible?

 

e.g.

powerShell {
name = "Create website"
platform = PowerShellStep.Platform.x64
edition = PowerShellStep.Edition.Desktop
formatStderrAsError = true
scriptMode = script {
content = // I want to access some shared variable here
}

Is the above possible?

0
2 comments

Hi Ruskin,

it should be mostly possible. The Kotlin code is compiled and validated when it's loaded into the server, so as long as it contains static values, it's possible to reuse the code. You can find an example on pretty much this here: https://blog.jetbrains.com/teamcity/2017/01/kotlin-configuration-scripts-creating-configuration-scripts-dynamically/ (simply replace the variables with the content of the script)

1
Avatar
Permanently deleted user

Thanks I achieved by putting my steps inside functions and returning them out and then using them via the TC DSL

0

Please sign in to leave a comment.