Sunday, September 8, 2019

Maven project in Jenkins


Maven Project type
The  Maven Project  type available to choose from when you click the New Item  button.
In order to have the Maven Project  type, you will need to install the Maven Project Plugin.
https://wiki.jenkins-ci.org/display/JENKINS/Maven+Project+Plugin If you are building a complicated maven project, definitely pick the maven project type here, this is a project template that Jenkins has reserved specifically for Maven-based projects.
Jenkins understands the pom dot XML file format and would take advantage of it which can greatly reduce the manual configuration.
In case you run into the following error when build your first Jenkins job
FATAL: Couldn't find any executable in /Users/xxxxx/Documents/apache-maven-3.3.9
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE
it means jenkins  user doesn't have permissions to access your maven directory. (Jenkins by default will run all builds under a special user name called jenkins )
Solution:
To fix it, we need to ensure that jenkins user has read and executable permission on /**/**apache-maven-**  folder.

For Mac/Linux User:
If Maven is installed on  /Users/user1/Documents/apache-maven-3.3.9  
Step1 : under your regular user ID, run the following command:
chmod 0755 /Users/user1/Documents
to ensure that jenkins user can access /Users/user1/Documents 
Step 2:  run the following command:
chmod -R 0755 /Users/user1/Documents/apache-maven-3.3.9  
to ensure jenkins can access to all the files under /Users/Hossein/Documents/apache-maven-3.3.9  
Step 3: verify jenkins user can run the maven mvn command:
switch under jenkins  user by running sudo -iu jenkins  
then run /Users/user1/Documents/apache-maven-3.3.9/bin/mvn -v to verify you can execute mvn  under jenkins  user

For Windows User:
If you are using Windows, the trouble shooting steps should be very similar to Mac/Linux, you can change the permission by right clicking the folder name.
https://technet.microsoft.com/en-us/library/cc754344(v=ws.11).aspx


No comments:

Post a Comment