Docker image of maven returns this error - could not create local repository

0 votes

I’m a new bee to Jenkins and Docker, and I’m facing a problem trying to get a docker image of maven to build my project.

My Jenkins script is as follows:

pipeline {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2'
}
}
stages {
stage('Build') {
steps {
sh 'mvn -B -DskipTests clean install'
}
}
}
}

This results in the following error:

"Could not create local repository at /var/empty/.m2/repository".
Aug 10, 2018 in Docker by Tyrion anex
• 8,550 points
1,016 views

1 answer to this question.

0 votes

Instead of mounting the root/.m2 folder to the container, you can just run as a root user:

agent {
    docker {
        image 'maven:3-alpine'
        args '-u root'
    } }
answered Aug 10, 2018 by Sophie may
• 10,100 points
Thanks a mil. This really helped me.

Related Questions In Docker

0 votes
1 answer

Init could not choose ip address error while doing docker swarm init

First look for the public IP of ...READ MORE

answered Aug 23, 2018 in Docker by Nilesh
• 6,980 points
842 views
+2 votes
1 answer
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 57,640 points
774 views
0 votes
1 answer