We're trying to cache Maven artifacts across Jenkins pipeline runs so we don't have to re-download them with each run. We are performing runs declaratively in the JenkinsFile and the pipelines are being managed by kubernetes, basically this question but with Kubernetes. I suppose I will have to persist the .m2 directory with PV/PVC but i'm not sure if this is currently possible declaratively, would that be the best approach or is there an alternative solution for keeping maven dependencies available for each run?
JenkinsFile:
pipeline {
agent {
kubernetes {
yamlFile 'ci-cd/BuildPod.yaml'
}
}
...
BuildPod:
apiVersion: v1
kind: Pod
metadata:
namespace: jenkins
labels:
jenkins/label: 'api-slave'
spec:
containers:
- name: jnlp
- name: mavenenv
image: maven:3.6.2
command:
- bash
...