I just want to change the .m2 path of a jenkins project in maven. Everytime when I build the project the .m2 folder is in c:\ and empty! There's no settings.xml or something...
The .m2 path of eclipse is in user.home (that's okay).
But how can I change the path of the .m2 folder in jenkins?
Thank you guys ;-)
In the project configuration page of Jenkin, under the tab Build, select Invoke Maven and click on Advanced. There is a check box Use private Maven repository. If this is selected, Jenkins will tell Maven to use $WORKSPACE/.repository as the local Maven repository.
Click on the help topic in Jenkin itself. It will give a clear idea.
If you need to invoke maven out side this plugin, you can pass
-Dmaven.repo.local=/some/path/.maven/repo
Related
I am new to CI. I am trying to run my local Selenium Project through Jenkins but it is getting failed with error. Here are the complete details:
OS - MAC OS
local POM xml Path:
Users/prakuma/git/NaveenPOMProject/Naveen_HybridPOM/pom.xml
I am not sure why is /Users/Shared/Jenkins/Home/workspace/Naveen_POMHybrid getting added before my pom.xml path.
I am attaching screen shot of Configuration and Global Setting of Jenkins.
Maven Global
Global setting :
Error:
Please follow the steps given below, which helped me to execute pom.xml successfully through jenkins on macOS.
Click on configuration (of project in jenkins)
Click on Build tab.
Keep Root POM as pom.xml
click on Advance.
search for "Use custom workspace"
check "Use custom workspace" , under Directory give your git dir location where pom.xml is there (eg: /Users/username/git/TestProject/TestProject).
Save.
Give all permission to directory(eg: /Users/username/git/TestProject)
Please click here to get the image
For working with maven jenkins plugin to use local project which is outside jenkins workspace. You can use Copy Data To Workspace Plugin which will move the code to workspace before maven execution.
Give your project folder to in path to folder variable.
Now in Root pom, simply leave it empty or just give pom.xml.
To make Jenkins find the pom.xml in a custom workspace ...
set the jobs Root POM to pom.xml
set Use custom workspace with the path to your pom.xml (e.g. /Users/prakuma/git/NaveenPOMProject/Naveen_HybridPOM/ in this case)
I am using Anypoint Studio 6.2 with Mule 3.8.1 runtime and Maven 3.3.9 and when I build my project, the Maven dependencies are written to a project folder called ${env.M2_REPO} instead of my usual Maven repository c:/users/my.name/.m2.
How can I change it back to c:/users/my.name/.m2 and stop this folder from being created?
It is causing errors to show in the Mule Problems tab saying "missing libraries" but when I move them from the ${env.M2_REPO} folder to c:/users/my.name/.m2 the problems go away.
The issue was that in the settings.xml file in the Maven application folder, the default repository was set to env.M2_REPO instead of the .m2 location. Changed it to .m2 and all working correctly.
right click on project--> Java Build Path-->Add Variable --> configure
variables--> Classpath variables--> new
-----------OR---------------
preferences-->Java--> Build path--> classpath variables
name: M2_REPO
path: location of repo
Update1:
right click on project, you will see something like this.
first time click on
populate maven repository
..
If your problem still didn't fixed then click on
Update project dependencies
.. This is how it fixed my problem few months back.
I am upgrading from maven 2 to maven 3. I have changed the maven home from M2_HOME to M3_HOME, created .m3 folder put the settings.xml inside it. Removed the .m2 folder also.
I see in the maven 3 global settings.xml, the default location of settings.xml is .m2\settings.xml. I could force maven to read the settings.xml from inside .m3 folder by supplying
mvn clean install -Dmaven.repo.local=C:/Users/tabeme/.m3/repository --settings C:\Users\tabeme\.m3\settings.xml
But I dont want to do this every time I build. Is there a way I can permanently make maven to read settings.xml from .m3 folder?
Maven 3 is a drop in replacement for maven 2.
It uses M2_HOME and .m2 folders as normal.
You should only change settings if you for some reason want to run multiple maven instances.
I comment out my local repository section im my pom.xml, but when I ran mvn eclipse: eclipse, it still try to download plugin from local repository. I also check the pom.xml it depends on and make sure to comment out them either, but this problem still occurs.
I think I might neglect some setting?
You may have a settings.xml in the default maven repository location .m2. If you are running maven inside eclipse, check your maven configuration inside Eclipse preferences, there you should find the location of the settings.xml file.
I am new to maven and Jenkins, I am trying to build a maven 3 project.
I have maven in c drive and I moved the repository to d drive.
But when I configure a build in Jenkins, it is creating its own repository(I think so)
Now How to configure jenkis, so that it can use my repository in D drive.
Hope I made sense.
you need to adjust the settings.xml to point out which repository to use.
<localRepository>C:\\USER_LOCAL_DIR\.m2\m2repository</localRepository>
where USER_LOCAL_DIR is your user directory (e.g. Users\your_user_name).
Further more you should make sure which settings.xml the maven is using, if you dont have any specific user settings.xml the maven will start using the settings.xml which is at maven configuration directory, which will be M2_HOME/conf/settings.xml (M2_HOME being the Maven home directory). The hierarchy for settings.xml is first the user .m2 directory and if it could not find that, it will try to find the one in M2_HOME/conf/settings.xml.
Hope this helps.
You may need to check for settings.xml file under
..\maven-xx\conf\settings.xml file
C:\Users\Username.m2\settings.xml file
You may need to remember precedence in the order mentioned. In case if you need to point to a private maven repository consider to check both the files and in case if it's not pointing to intended location then update the settings file accordingly.