Jenkins Declarative Pipeline: How can I mount a temporary volume associated with the workspace in a docker container?
Did you try something like this (adapted from Jenkins Docs)
pipeline {agent { docker { image 'maven:3-alpine' args '-v $HOME/.gradle:/home/jenkins/.gradle' }}stages { stage('Build') { steps { sh 'mvn -B' } }}
}
The volume is not temporal, but I think could work for your use case.