Jumping on an old thread but I have the same need using docker based agents. I was thinking of trying to write a cache plugin that achieves a similar caching capability that travis ci provides for arbitrary directories :
https://docs.travis-ci.com/user/caching/#Arbitrary-directories
In the pipeline code, there would be a cache build wrapper that would download the cache from the master when entering the block and when the block completed, save the specified paths back to the master (ideally in an rsync style way with minimal data movement). There would also be a maximum cache size so that when the cache grew too large, it would be deleted from the master and started fresh on the next run:
node {
cache ([maxSize="250M",
paths=[
[path="${HOME}/.gradle/cache",
excludes=["${HOME}/.gradle/caches/modules-2/modules-2.lock", "${HOME}/.gradle/caches/*/plugin-resolution"]],
[path="${HOME}/.gradle/wrapper"]
]
]) {
sh './gradlew build -s'
}
}
Anyone aware of anything like this?
Thanks,
Pete