Problem
Generating Kotlin DSL versioned settings fails when the DSL pom.xml declares a dependency hosted in a private Maven repository. The Create Project From URL page reports:
Failed to apply changes from VCS to project settings (revision <revision>): Failed to get DSL dependencies: Failed to collect dependencies at com.example.teamcity:custom-dsl-library:jar:2.0.0. Please fix the errors in the script and make a new commit.
teamcity-versioned-settings.log records the same failure:
WARN - s.VersionedSettingsUpdaterImpl - Failed to generate updated settings for revision <revision>: jetbrains.buildServer.serverSide.impl.projects.ConfigGenerationException: Failed to get DSL dependencies: Failed to collect dependencies at com.example.teamcity:custom-dsl-library:jar:2.0.0 (enable debug to see stacktrace)
A common variant: importing a new project fails while existing projects keep synchronizing their settings without error. Successful resolution on existing projects does not show that the private repository is reachable.
Cause
The local Maven repository is kept per settings VCS root. Downloaded dependencies are cached in <TeamCity Data Directory>/system/caches/dslDependenciesMaven/<VCS root instance id>. A project that already resolved its dependencies regenerates its settings from that cache and never contacts the remote repository. Importing a project creates a new settings VCS root with an empty cache, so an import is the only operation that performs a real download. This is why a new import fails while established projects keep working.
Maven settings are read from the Root project alone. Credentials, mirrors and proxies for DSL dependency resolution come from mavenSettingsDsl.xml uploaded on the Maven Settingspage of the Root project, as described in Kotlin DSL - Ability to Use External Libraries. A Maven settings file attached to a subproject is ignored during DSL dependency resolution. Improve Kotlin DSL libraries resolution. Allow each project to specify its own settings file for DSL library resolution tracks a request to allow per-project settings files.
Maven Central is added to the repository list. Unless the DSL pom.xml already declares https://repo.maven.apache.org/maven2/ among its repositories, TeamCity appends it. On a server without direct access to Maven Central, resolution can be directed there rather than to the internal repository. Kotlin DSL does not pull Maven dependency from internal repo covers this behavior.
Resolution
- Confirm that
mavenSettingsDsl.xmlis uploaded on the Maven Settings page of the Rootproject and that its<servers>section holds credentials for the private repository. Moving an existing file from a subproject to the Root project resolves the error in most reported cases. - Add the internal repository as a
<mirror>in the same file when the server has no direct access to Maven Central. - Confirm that the exact artifact version named in the error exists in the repository and is readable with those credentials. An expired access token matches a setup that worked until recently and then stopped.
- Retry the project import.
A settings file that covers both the mirror and the credentials:
<settings>
<mirrors>
<mirror>
<id>internal-repository</id>
<url>https://repo.example.com/maven</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<servers>
<server>
<id>internal-repository</id>
<username>user</username>
<password>password</password>
</server>
</servers>
</settings>
Comments
0 comments
Please sign in to leave a comment.