Jenkins repository location

jenkins, maven

Solution

actually it depends on configuration of each individual maven project. By default, Jenkins will use the local repository `JENKINS_HOME_DIR/.m2/repository` if you install the maven by ticking the Install automatically checkbox, otherwise it will use the local /home/username/.m2/repository.

however you can change this default location by setting up the settings.xml file in ~/.m2/settings.xml

OR

for global use you can change it from jenkins_home_dir/conf

for example if you install maven by tick Install automatically checkbox

`Step1.` Choose the maven Installation for a particular project in jenkins home directory

$ cd Jenkins_home_dir/tools/hudson.tasks.Maven_MavenInstallation/

`Step 2.` change the localRepository in settings.xml

The hierarchy for settings.xml is user `.m2` directory and if it could not find that, it will try to find the one in `{maven home}/conf/settings.xml`.

Problem

Which repository location does Jenkins use when building a Maven project? I have chosen `Default (~/.m2/repository)` option while configuring Jenkins but it seems the behavior is a bit different. Though there is this myown.jar present in my local repository i.e. in `/home/username/.m2`, it shows the error that myown.jar is not found. So I have to build a job for this `myown` project, build it and then the error gets solved. Not only this, when I put the Jenkins script in startup i.e. `/usr/bin/java -jar <warpath>.war`, it downloaded all the dependencies of my projects again while building it, though I had built the configured project 5 times before putting the script in startup !! Isn't it weird behavior? Which repository location does Jenkins use? Or is there something what I might be missing?

Original source