I have a multi-branch setup on Jenkins for my Gradle project. I would like to be efficient in terms of performance and cost as well (money!). Meaning, if would like to build my project many times, for different branches, commits, in parallel. For that I'm thinking about having everything inside of containers, but I'm not sure if my containers would share the libraries resolved by gradle. Moreover, I don't want to resolve dependencies for every time I bring them up, it would be time consuming and network usage as well.
Or I'm thinking about deploying a simple vm with Ansible and run my builds from there, making this whole process simpler.
So I wonder which approach would is better? Anyone faced a similar issue? Does someone has any benchmark to share?