Jenkins : Unable to Run Local Maven Project through Jenkins - maven

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)

Related

Jenkins path in a pipeline

How can I made my pipeline execute on
Jenkins in /var/jenkins_home/workspace/
instead of
Jenkins in /opt/jenkins/workspace/
To make root pom readable. Because I am getting UNABLE TO READ POM error.
I am building a maven project through a pipeline.
Modify the workspace and build directory path in config.xml
<workspaceDir>${JENKINS_HOME}/workspace/${ITEM_FULL_NAME}</workspaceDir>
<buildsDir>${ITEM_ROOTDIR}/builds</buildsDir>
Path of config.xml is ${JENKINS_HOME}/config.xml
You can save the configuration and restart the jenkins server for the changes to get reflect.

jenkins is not using local maven repository

I have few jars which I have installed in my local maven repo(in windows under user/.m2). While building the project from command-line it's perfectly downloading the jars and packaging it.
Now I have created a Jenkins job (mvn clean package) to do so, but while running the jobs it's not picking up those jars from local repo instead trying to download it from central repo.
I tried all possible solutions available in Internet but still no luck. Can you please how I can configure Jenkins so that it should download those jars from my local repo ?
I also tried :-
1. offline mode
2. gave local repo path in settings.xml
3. use of nexus/artifactory in not an option for me
Seems maven executed by Jenkins not used the settings.xml in your local
you can try to change the maven command/goal in Jenkins job configuration with one more option:
-f <your local settings.xml path>
you can copy the settings.xml to your source code folder for debug purpose, after prove it work, then consider how to prepare the settings.xml for jenkins job with below options:
Option 1 use Config file provider plugin
Click Config Files -> Add a New Config -> Maven settings.xml
Change name and set your xml into content field:
In your job configuration, click the Advance... button in Build Section, choose your added settings.xml as below:

Mule copies Maven dependencies into env.M2_REPO folder

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.

Jenkins: Finding root pom.xml in OSX

Ive been searhcing and I cannot find the path to the pom.xml for ROOT POM in Jenkins Project on my macbook
on my comp, the path is here: /eclipse/.../workspace/test/pom.xml
but when I insert that into the ROOT POM space, the error shows:
ERROR: NO SUCH FILE
/eclipse/.../workspace/test/pom.xml
What do I put to the path to get to my pom? THanks!
Jenkins is on the same machine, and Project is also locally under users on My machine,
Job is configured as "maven project" in jenkin, every thing is on My System

jenkins on windows | change .m2 path

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

Resources