鉴于我有多个构建基于 Gradle 5.X 的应用程序的代理,我想开始在所有代理之间缓存 Gradle 依赖项。
我尝试分享.gradle
文件夹,但是当我尝试在 2 个代理上运行相同的构建时,其中一个代理失败:
Caused by: org.gradle.api.UncheckedIOException:
Failed to create parent directory '/home/buildagent/.gradle/caches/5.0'
when creating directory '/home/buildagent/.gradle/caches/5.0/generated-gradle-jars'
如何跨 Teamcity 代理共享依赖项?
是否有支持 Gradle 5 及更高版本的通用解决方案?
我在 Gradle 6.x documentation 中找到了这个,但我在
5.x
中没有找到任何内容文档。
最佳答案
我不能说你得到异常的根本原因是什么,因为消息非常稀疏。我只能说,对于 Gradle 5,没有内置的解决方案可以通过网络共享本地缓存。能力copy and reuse the cache您提到的 Gradle 6.1 已经引入,并且有一些限制:
$GRADLE_HOME/caches/modules-<version>
) 那么,什么是适用于 Gradle 5 和 6 的可移植解决方案?根据最初介绍缓存可重用性的票证( Make dependency caches relocateable #1338 ):
Write a Gradle task that creates a file repository from your dependencies and package that file repository. Then have logic in your build that says "if that file repository is present, use it".
(From this comment)
关于gradle - 在 Teamcity CI 代理中重用 Gradle 缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61322247/