DevOps

Install and Configure Maven Build Tool on Jenkins

Maven serves as a crucial code build tool, transforming your code into an artifact. It’s widely utilized in continuous integration processes.

Prerequisites

Ensure you have:

  1. A Jenkins server.

Install Maven on Jenkins

To install Maven on your Jenkins server, follow these steps:

  1. Download Maven packages from https://maven.apache.org/download.cgi onto your Jenkins server. Here, I’ll use /opt/maven as the installation directory. Link: https://maven.apache.org/download.cgi # Create maven directory under /opt mkdir /opt/maven cd /opt/maven # Download maven version 3.6.0 wget http://mirrors.estointernet.in/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz tar -xvzf apache-maven-3.6.1-bin.tar.gz
  2. Set up M2_HOME and M2 paths in .bash_profile of the user and add these to the path variable. vi ~/.bash_profile M2_HOME=/opt/maven/apache-maven-3.6.1 M2=$M2_HOME/bin PATH=<Existing_PATH>:$M2_HOME:$M2

Checkpoint

Log off and log in to check the Maven version.

mvn --version

This completes the Maven software installation to support the Maven plugin on the Jenkins console. Let’s proceed to Jenkins to finish the remaining steps.

Setup Maven on Jenkins console

Follow these steps to configure Maven on the Jenkins console:

  1. Install the Maven plugin without requiring a restart:
  • Navigate to Manage Jenkins > Jenkins Plugins > Available > Maven Invoker.
  • Navigate to Manage Jenkins > Jenkins Plugins > Available > Maven Integration.
  1. Configure the Maven path:
  • Access Manage Jenkins > Global Tool Configuration > Maven.
Ali Imran
Over the past 20+ years, I have been working as a software engineer, architect, and programmer, creating, designing, and programming various applications. My main focus has always been to achieve business goals and transform business ideas into digital reality. I have successfully solved numerous business problems and increased productivity for small businesses as well as enterprise corporations through the solutions that I created. My strong technical background and ability to work effectively in team environments make me a valuable asset to any organization.
https://ITsAli.com

Leave a Reply