Given I have multiple agents which build Gradle 5.X based applications, I'd like to start caching Gradle dependencies across all agents.
I tried to share .gradle folder, but when I try to run the same build on 2 agents, one of them fails on:
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'
How can I share dependencies across Teamcity agents?
Is there a generic solution which will support Gradle 5 onwards?
I found this in Gradle 6.x documentation, but I didn't find anything in 5.x documentation.
I cannot say what the root cause of the exception you get is, since the message is quite sparse. All I can say is that for Gradle 5 there is no built-in solution to share the local cache via network as you would like to do. The ability to copy and reuse the cache you mentioned has been introduced with Gradle 6.1 and has some limitations:
$GRADLE_HOME/caches/modules-<version>) onlySo, what's a portable solution that works for Gradle 5 and 6? According to the ticket that originally introduced the cache reusability (Make dependency caches relocateable #1338):