Using KotlinDSL on a large complicated project?
Completed
I've been researching the migration of our existing TeamCity server setup over to a KotlinSDL solution.
The key reasons for this are to resolve the following issues:
- Providing context for UI modifications (log messages to say why something changed etc)
- Programmatic duplication of Projects (foreach track in mySupportedTracks {create new subproject})
- A better ability to integrate changes between two teamcity servers (xml merging and runner_ids make this impossible)
I've ran into a few problems along the way due to limited documentation, however I've ran into a blocking case that has made me drop this research, this issue has received no Jetbrains support.
https://youtrack.jetbrains.com/issue/TW-56368
Basically,
- I cannot programmatically create a block of projects, due to the way 'RelativeId' works,
- and furthermore, I cannot extract a BuildType into it's own kt file to be called by multiple projects, due to it needing an ID, and that ID needing to be based upon it's relative parents (which aren't known at the kt file level)
As a result of this, I'm unsure whether I'm expecting KotlinDSL to provide functionality that it wasn't designed for, or I'm simply doing something fundamentally wrong.
I would love some support in this area.
Thanks
Please sign in to leave a comment.
The issue was solved via a private support channel, but I'll try to highlight the key points for anyone facing a similar problem.
ID is indeed required but it can be assigned at any time.
The following example creates 10 build configurations and then attaches them to some project:
Note, that you can write a function to any object in Kotlin, see also: https://kotlinlang.org/docs/tutorials/kotlin-for-py/extension-functionsproperties.html
You can also run the DSL locally without committing the changes into TeamCity, this may help you to debug your project, see: https://www.jetbrains.com/help/teamcity/2019.2/kotlin-dsl.html#KotlinDSL-GeneratingXMLConfigurationFilesLocally
Best regards,
Mikhail Efremov