Hello,
In this official documentation, it is mentioned that, if I provide args '-v $HOME/.m2:/root/.m2'
then earlier dependencies will be cached and will not be downloaded each time the code is built. Also, I’ve used reuseNode true
to make use of same workspace.
Still the old dependencies are being downloaded every time I build my code.
Please let me know what wrong I’m doing here.
Below is my sample Jenkinsfile.
pipeline {
agent any
stages {
stage('Build war') {
when {
anyOf {
branch 'preprod'
}
}
agent {
docker {
image 'maven:3.9.8-eclipse-temurin-8'
// caching data on the agent between Pipeline runs.
args '-v $HOME/.m2:/root/.m2'
// Run the container on the node specified at the
// top-level of the Pipeline, in the same workspace,
// rather than on a new node entirely:
reuseNode true
}
}
steps {
sh 'java -version'
sh 'mvn clean package'
}
}
stage('Build Docker Image') {
// Use the "parent" agent for the Docker specific steps
when {
anyOf {
branch 'preprod'
}
}
steps {
sh 'ls -l'
sh 'docker ps'
}
}
}
}
Thank you.