Configure maven project in jenkins example

As we all know, maven is a build / project management tool, based on the concept of a project object model (POM) which contains every information about your project. Maven allows a project to build using its project object model to manage builds, dependencies, releases and documentation which are all managed from the pom.xml file.

Maven defines a standard way to build the projects, test, and deploy project artifacts. It provides a framework that enables easy reuse of common build logic for all projects following Maven's standards. We discussed maven in detail earlier here and hope you have configured maven.

First lets Create a simple maven project in Jenkins

Step 1:- Click New Items on the left menu
->Enter Project Name in “Item name” field
-> Select Maven Project
->Click OK

Configure maven project in jenkins

Step 2:- Provide the job description

Step 3:- In Source Code Management, Jenkins supports CVS and Subversion out of the box, with built-in support for Git, and also integrates with many other version control systems via plugins. We will look into these details in next articles.

Now lets make it simple and select 'None' to execute from local machine.

Step 4:- Build Triggers, We have multiple options like 'Build periodically', 'Poll SCM', 'Build whenever a SNAPSHOT dependency is built, etc. Example, if you select 'Poll SCM' option, Jenkins will poll the repository for changes based on the cron expression specified. We will see more details in the coming tutorials.

Please select any of the option based on your needs.

Step 5:- In Build, We need to tell Jenkins where to find pom.xml file. Please specify the path of your pom.xml file in Build Root POM and Specify 'Goals and options', in this example 'clean test'.

Define Goal for maven project in jenkins

Below is the pom.xml file :

<project xmlns="" xmlns:xsi=""
   <name>My Maven Project</name>
   <description>This is a simple Maven Project</description>
         <!-- Compiler plug-in -->
         <!-- Added Surefire Plugin configuration to execute tests -->


Step 6:- In Build Settings, If you want to send an email notifications, you can check 'Email Notification' and add Recipients address.

Step 7:- In Post Build Actions, You can chose steps such as Archive Artifacts, Publish Results etc.

After executing the Build, you can view the result as below:

Goal executed maven project in jenkins


Hi I refer your link many a times. Thank you . I have a scenario where I have multiple testNG suites. I have Jenkins configured and I am able to run the suites though the POM .I am trying to check with you if there is a way we can trigger the Jenkin job seperately for each testNG suite. This is basically each suite takes about an hour so I want to schedule separate jobs so that we don't have to wait too long for all the suites to run completely.

We work for different modules. My question from where will i get this ROOT POM : POM.XML do we have to configure it.

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.