Configure Apache Maven in Jenkins

In order to build Maven projects in Jenkins, we have to configure the JDK in addition to the mandatory part, which is also mandatory for us to configure Apache Maven for Jenkins to use. So, in this tutorial, I will guide you all how to configure Apache Maven in Jenkins.

First, log in to your admin account, then go to Manage Jenkins, select Global Configuration Configuration, and go to the configuration section for Apache Maven. Here, we will have two parts to configure for Apache Maven:

The first part is the configuration section for Apache Maven about the settings.xml file.

Configure Apache Maven in Jenkins

You can select Use default maven settings for the Default settings provider section, Use default maven global settings for the Default global settings provider section to use the default Apache Maven configuration. Or you can click on the drop down of each section to select a different settings.xml file.

Configure Apache Maven in Jenkins

Enter the path to the settings.xml file in the File path.

Here, I will use the Apache Maven default settings.xml file so I will choose to use the Default …

The second part that we need to configure is the Maven installations.

Configure Apache Maven in Jenkins

Click the Add Maven button to configure this section.

Configure Apache Maven in Jenkins

By default, Jenkins allows us to install Apache Maven automatically using its latest version. You just need to add information about the name of this installation is okay. Click the Save or Apply button if you want to use this default configuration after entering the value for Name.

If you want to use Apache Maven that you have installed on your machine then uncheck Install automatically. Then, you need to enter MAVEN_HOME information as follows:

Configure Apache Maven in Jenkins

with Name is okay.

I will choose Install automatically for convenience. 🙂

Configure Apache Maven in Jenkins

At this point, you can click the Save or Apply button to complete the configuration.

 

4 thoughts on “Configure Apache Maven in Jenkins

  1. Huongdan, In your example above, if you wanted Jenkins to install Maven for you, and you wanted to update the settings.xml file, do you know where the .m2 folder is placed by Jenkins?

Add Comment