clean up maven repo in Jenkins slave

2,812 views
Skip to first unread message

JasonX

unread,
Apr 13, 2012, 2:43:50 PM4/13/12
to Jenkins Users
I saw maven repo is copied to /opt/.m2 directory on Jenkins slave from
maven server and it fills up Jenkins slave disk. I wanna clean it up.
How can I do it? can I remove all of the repos from Jenkins slave
after each build? is that necessary to keep all dependencies on
Jenkins slave but they are already existing in maven server.

domi

unread,
Apr 14, 2012, 3:02:39 AM4/14/12
to jenkins...@googlegroups.com
It's not jenkins who copies the dependencies to this location, its maven.
There are multiple reasons which could cause this:
- you have configured /opt to be the home directory of your user you running jenkins with.
- this location is configured in your settings.xml
If you delete all these, maven will just download them the next time again (and slow down the build). If you have multiple maven jobs running at the same time, you should also not delete the directory/repository while a build is running, this would just remove the needed libraries and the build will fail.
I recommend you use the 'Config File Provide Plugin' [1] - this will allow you to configure your settings.xml at a central place and select one within your job configuration from a drop down menu.
regards Domi

[1] https://wiki.jenkins-ci.org/display/JENKINS/Config+File+Provider+Plugin

JasonX

unread,
Apr 16, 2012, 1:30:16 PM4/16/12
to Jenkins Users
Hi Domi,

this is a great help. I have more questions.....
where can I check/change the home directory of my user jenkins running
with? Is that a good idea if i put maven repos in a share drive and
mount it on both maven and jenkins slave servers so that only one
location should be cleared up once too many dependencies are there and
maven does not need to copy files to jenkins slave when build job
running?
Thanks,

Jason

domi

unread,
Apr 17, 2012, 2:34:47 PM4/17/12
to jenkins...@googlegroups.com
Jason,
if you talk about jenkins home, there are two homes you have to think about:
- JENKINS_HOME, this is where the config of Jenkins will be, have a look here: https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins
- Home of the user Jenkins is running with: this depends on the system Jenkins os running on: Windows / *nix - don't know how to change it on Windows, on *nix its in the /etc/passwd. But before you do that, you should get familiar with what you are doing.
At the end its probably more a question of why you want to change the home directory… If you just want to change it to have the maven repo at a different location, then you should rather just change that location in your settings.xml (http://maven.apache.org/settings.html)

About deleting and sharing the local repo: you have to be aware, that the local maven repo is not multi thread aware - e.g. if two builds download the same artifact at the same time you might get into trouble. This is also the reason, why Jenkins allows to configure the local repo for each build/executor/workspace (have a look at the Jenkins' global 'Maven Project Configuration').
So my advice is: get enough space to allow all this repos to exist.
regards Domi

Reply all
Reply to author
Forward
0 new messages