If you are using kubernetes as executor for gitlab-runner, you can also use the maven cache. I chose to have a persistent cache on NFS with k8s PV (but other volume type are supported by gitlab-runner). The following configuration doesn't use the cache gitlab feature because of persistence offered by NFS.
1) create a PersistentVolume on your cluster, ex here with NFS (adapt to your persistence layer and your options) :
apiVersion: v1
kind: PersistentVolume
metadata:
name: gitlabrunner-nfs-volume
spec:
capacity:
storage: 10Gi
mountOptions:
- nolock
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Recycle
nfs:
path: /gitlabrunner
server: 1.2.3.4
2) Reference the PV to get a claim as a volume in the runner pod :
[[runners.kubernetes.volumes.pvc]]
name = "pvc-1"
mount_path = "/path/to/mount/point1"
Note (03/09/18) : A command line option for these paramaters doesn't exist yet. There is a open issue.
3) Specify the same path for the gitlab-runner cache :
[[runners]]
executor = "kubernetes"
# ...
cache_dir = "/path/to/mount/point1"
or
--cache-dir "/path/to/mount/point1"
in interactive mode
4) use the "/path/to/mount/point1" directory in the -Dmaven.repo.local
option
$HOME/.m2/repository
or can be configured viamvn -Dmaven.local.repo=Path
? – khmarbaise