How to Configure and Integrate Maven in Jenkins?
Last Updated :
16 May, 2024
Maven integration with Jenkins makes Java project development and deployment easier. Step-by-step instructions for integrating Maven with Jenkins are provided in this guide. You will discover how to set up Jenkins for Maven, manage project dependencies, automate builds, and enhance software delivery pipelines.
What Is Maven?
Maven is a powerful project management tool that is based on POM (project object model). It is used for project build, dependency, and documentation. It simplifies the build process like ANT. But it is too much more advanced than ANT. In short terms we can tell maven is a tool that can be used for building and managing any Java-based project. maven makes the day-to-day work of Java developers easier and generally helps with the comprehension of any Java-based project.
Different Types Of Ways to Configure Maven in Jenkins
- Using Jenkins Plugin
- Using Jenkins CLI
Configuring Maven Using Jenkins Plugin
Follow the steps mentioned below to configure Maven using Jenkins UI.
Step 1: Click on the "Manage Jenkins" option in the navigation menu, sidebar, or user dropdown, click on it. This will take you to the Jenkins configuration management page where you can access various settings and options for managing your Jenkins server.
Step 2: After clicking on "Manage Jenkins" in the Jenkins dashboard, you'll find a section or category called "Tools" within the management options.
Step 3: Here we are choosing the version maven3.9.6 you can configure according to your requiurment.
- Maven installations: This is the title at the top of the section, indicating you're adding a new Maven installation.
- Add Maven: This button initiates the process of adding a new Maven installation.
- Name: This field allows you to specify a name for this particular Maven installation. It helps distinguish between different Maven versions you might manage within Jenkins. The example shows maven3.9.6 as the name.
- Install automatically? This checkbox determines how Jenkins retrieves Maven. If checked (as in the image), Jenkins will automatically download and install the chosen Maven version during configuration.
- Install from Apache: This radio button selection (pre-selected in the image) instructs Jenkins to download the Maven installer from the official Apache Maven repository.
- Version: This dropdown menu allows you to choose the specific Maven version you want to install. The current selection is 3.9.6.
- Add Installer: If you select to install from a custom location rather than the default Apache repository, this button would allow you to upload a custom Maven installer.
- Save: Clicking this button saves the configuration and installs Maven if the "Install automatically" checkbox is selected.
- Apply: Clicking this button applies the configuration changes without saving them permanently.
Configuring Maven Using Jenkins CLI
Follow the steps mentioned below to configure maven in jenkins using jenkins CLI
Step 1: Using the below command, first verify whether the maven is installed or not.
mvn -v
- mvn: This is the executable for the Maven command-line tool.
- -v: This is a flag that tells mvn to display the version information.
In my instance, the error "command not found" indicates that Maven is not installed, as you can see in the image. Rewrite the sentence
Step 2: To install Maven within your Jenkins environment, use this command:
sudo apt install maven
- sudo: stands for "superuser do" and is used to execute commands with administrative privileges. Since installing software often requires modifying system files, sudo is necessary to grant those permissions.
- apt: is the package manager used by Debian-based systems. It manages the installation, removal, and updating of software packages. Think of it like a central app store for your system.
- install: is a command within the apt package manager that instructs it to install a specific software package.
- maven: is the name of the software package you want to install. In this case, it's "maven," which refers to the Apache Maven software, a popular build automation tool used for managing project lifecycles in software development.

Step 2: Once you've run the sudo apt install maven command, let's verify if the installation was successful.
mvn -v

The image confirms successful Maven 3.8.7 installation using sudo apt install maven.
Similar Reads
How to Configure a Maven Project in Jenkins ?
Jenkins is a powerful automation server broadly utilized in software development for continuous integration (CI) and continuous delivery (CD) processes, it empowers developers to automate different parts of the product advancement lifecycle, including building, testing, and deploying applications, o
8 min read
How To Set Up Continuous Integration With Git and Jenkins?
Continuous Integration (CI) is a practice where developers integrate their code into a shared repository frequently, ideally several times a day. Each integration can then be verified by an automated build and automated tests. This practice helps to detect errors quickly and improve software quality
4 min read
How to install and configure Jenkins Server on Godaddy Srever?
GoDaddy Server is a cloud-based hosting platform that consists of virtual and dedicated servers. The premium service includes weekly backups, 99% uptime, 24x7 Customer Support, a free encrypted SSL certificate, unlimited bandwidth, and SSD storage. For regular users, the latest generation is VPS Gen
3 min read
How To Configure Build Periodically In Jenkins?
Jenkin has now become a very popular open-source automation server used for building, testing, and deploying software. It has several key features, one of which is that it can schedule periodically in Jenkins. In this article, we are going to explore in depth how we can configure builds periodically
5 min read
How to Make a CI-CD Pipeline in Jenkins?
Pre-requisites: JenkinsDevOps professionals mostly work with pipelines because pipelines can automate the processes like building, testing, and deploying the application. Doing manually by UI takes lots of time and effort which will affect productivity. With the help of Continuous Integration / Cont
5 min read
How To Configure Poll SCM Jenkins ?
Jenkins is an open-source automation server, that allows us to automate the software development process through continuous integration, continuous testing, and continuous deployment/delivery with seamless integration of different plugins like git, maven, sonar qube, frog, tomcat, etc...One such cru
3 min read
Jenkins Master And Slave Configuration Using AWS EC2 Instance
Optimizing the jenkins performance enhances the scalability by configuring the master-slave architecture using AWS EC2 Instances. Distributed workloads efficiently secures seamless CI/CD process for your projects. In this Article you will guide how to configure jenkins master-slave nodes using AWS E
5 min read
Creating And Configuring Freestyle Projects In Jenkins
Jenkins freestyle project is the general purpose job that will clone the projects from the Source Code Management (SCM) like Github, Gitlab, and Bit Bucket. After according to the configurations done to the project it will execute the steps in a series of manner like archiving the artifacts and send
5 min read
How To Integrate SonarQube With Jenkins?
SonarQube is a code analysis tool that is used to find a number of bugs, duplications, security vulnerabilities, and many more. On the other hand, Jenkins is an open-source automation tool used to automate the build, test, and deploy stages of a software development lifecycle. Here in this, I have d
5 min read
How To Integrate Jenkins With Slack ?
In the present high-speed software development scene, consistent communication and collaboration efforts among teams are foremost. Jenkins, a software automation server, remains as a foundation for automating different undertakings across the product improvement lifecycle. Then again, Slack, a broad
8 min read