Kotlin DSL - how to configure VCS roots?
TeamCity 2018.1. Having two VCS root DSL issues that appear to possibly be related.
1. Creating of a new project from a Github repository with a VCS root specified in settings.kts appears to be impossible - the import process appears to already pre-create a VCS root with an ID the script needs to, apparently, guess? Sample error:
Could not import project settings from VCS because of the following errors: Settings loading error [project-name]/buildTypes/[project-name]_Master.xml: VCS root with id "[project-name]_Master" does not exist
2. For an existing project, changing Kotlin DSL settings of an existing source root doesn't take. Build steps and other configuration changes work as advertised, with the exception of the VCS root - changes in settings.kts to things like branchSpec do not reflect in the build.
Please sign in to leave a comment.
The way we worked around this is that we have a separate VCS root for the Kotlin DSL and nothing else, and the Kotlin DSL defines all the other VCS roots for the project itself.
Hi,
if you are creating a new project in the UI, the VCS Root will be created with an autogenerated ID. If you have the settings in the VCS, the idea is that you should be able to simply create the new projects directly from the DSL instead of generating them via the UI.
2. Modifying the DSL and committing the changes should apply them to the UI, but this depends on how your DSL settings are specified. This said, it should be picked up as a whole, either changes are applied or they aren't. If changes aren't being applied, make sure that you are modifying the correct VCS Root. You can access the Versioned settings tab on the project settings and force loading the settings from the VCS.
If it still doesn't work, please open an issue in our tracker, provide the DSL code you are using, an screenshot of the build configuration after the changes should have been applied. Keep in mind that, if you don't force the VCS settings, it will take as much time to load the changes as the checking for changes interval in your VCS Root for the settings specifies.
"If you have the settings in the VCS, the idea is that you should be able to simply create the new projects directly from the DSL instead of generating them via the UI."
Are there any examples or documentation one how we can create a Project in TeamCity without the UI, as of now? E.G. If we have the settings in the VCS, how to create a new project from the DSL? This would allow nothing to have to be done from the Teamcity UI hypothetically.
Our use case is that we want to set up 2 templates, one for android, one for iOS, that our team can use to generate TeamCity Projects with build configurations easily by copying the templates into their github repositories.
Hi,
you can simply add a "subproject" entry within any existing project, and that should create a new project. It's quickly hinted at at the start of our blog post on the dsl: https://blog.jetbrains.com/teamcity/2019/03/configuration-as-code-part-2-working-with-kotlin-scripts/. Subprojects are a project object, so you can fill them with the same content that fills regular projects.