Showing posts with label Jenkins Maven Job. Show all posts
Showing posts with label Jenkins Maven Job. Show all posts

Monday, September 7, 2026

How to Create a Maven Job in Jenkins

As we know Jenkins is a tool  , and its used for build and release any project.There are many such tools are available i.e. Hudson.  For creating job/project on Jenkins below steps/screen shots need to follow.

Step 1 - Login & Dashboard

Login to Jenkins with valid credential and you are in Dashboard.



Step 2 - Create Job

Click New Item (left side menu) to create a new Job/Project . Provide the Job Name as per your project requirement. Here this example my job name is "HelloWorld_Job".




Here in the above image many options are available for creating many kind of job. Also you can copy any existing job instead of creating a new. You can select Copy Existing Items and provide the existing job name inside the text box.



Step 3 - Job Configuration


There are few certain configuration is required for this job execution. For building any job we need few configuration and commands as below.





You need to configure the source code location from which you are going to build.In the below image I have used "Git" as source code management tool. You can use any source code management tool like SVN, CVS ,etc. And the important part of this configuration is the location of your project . So, make your the location you have provided is correct and relevant.



Then  there are few more setup is required make this job elegant and accurate. But these options/settings are fully optional. Read all the settings carefully and configure as per you needs.Some useful configurations as below.




As the part of configuration the major part is maven command for execute the build. The screen shot below shows the configuration about maven command for goal. This project is a maven project and we need maven command for build this job/project. 




Common maven commands which is used for a clean build is "mvn clean install". Also there are many other additional commands which will help you to achieve your goal.Read more here about Maven.


Step 4 - Start Build 


The final step is to start the build. Once all the above steps are completed and you are ensure about the configuration , then you can do the build . The build execution will provide you the artifacts i.e. jar ,war,ear, etc.




 If the job execution is success, the you can go for deployment. Now you are done with this job.


Enjoy the Build and Release process.

Monday, October 5, 2015

Jenkins Maven Error: Unknown Lifecycle Phase "mvn"


[ERROR] Unknown lifecycle phase "mvn" You must specify a valid lifecycle phase or a goal in the format.

This Jenkins issue is very common, while configuring the maven job in Jenkins. One of my peer faced this issue during her development. Then we investigate and fixed this issue.


Jenkins Configuration :-




Error Log :-

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.316 s
[INFO] Finished at: 2015-10-05T15:10:46+11:00
[INFO] Final Memory: 20M/491M
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException
[JENKINS] Archiving /opt/jenkins_dev/workspace/MYAPP_BIZ/pom.xml to au.com.mycompany.group.lar.testing.biz/Myapp/0.0.1-SNAPSHOT/Myapp-0.0.1-SNAPSHOT.pom
channel stopped
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE


Solution :-

Its a simple mistake, that while configuring the jenkins jobs maven goal, we are simple trying with mvn clean install  , which is a against maven life cycle policy.

So , we fixed this by removing the mvn  . Correct command is clean install. Then it worked.