'How to use TeamCity DSL versionedSettings feature?
I am trying to configure a project in TeamCity DSL and I want to be able to specify versionedSettings for that project, else I have to manually edit the Version Settings in the UI after the project has been imported/created.
Here is a sample configuration I try to use:
version = "2021.2"
project {
vcsRoot(TheVCS)
features {
versionedSettings {
mode = VersionedSettings.Mode.ENABLED
allowEditingOfProjectSettings = false
settingsFormat = VersionedSettings.Format.KOTLIN
buildSettingsMode = VersionedSettings.BuildSettingsMode.PREFER_SETTINGS_FROM_VCS
}
}
}
object TheVCS : GitVcsRoot({
name = "TheVcs"
url = "https://git.repo/1234"
userNameStyle = UserNameStyle.NAME
branch = "refs/heads/main"
branchSpec = "+:refs/heads/(*)"
checkoutPolicy = AgentCheckoutPolicy.NO_MIRRORS
})
Generating the XML (mvn teamcity-configs:generate) for this configuration will result in:
[ERROR] Error while generating TeamCity configs:
[ERROR] Validation error: Project 'RootProjectId', project feature [1/1]: Versioned settings project feature cannot be used in relative project hierarchy
Do I need to specify the versionedSettings in some other way or is this correct and the behavior a bug? Googling the error message resulted in only two matches without any answers:
Solution 1:[1]
Currently, it is not possible to change the versioned settings configuration from the DSL itself. If we allow it then some non-trivial problems can occur. So you can't change the synchronization options of the project which is currently being synchronized with VCS. You also can't enable synchronization with some other VCS root in some sub-project that is generated by DSL from some other VCS repository. Basically, this is a chicken and egg problem, hence the limitation.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | tolache |