Install & configure the Maven build tool on Jenkins
Maven is a code build tool used to convert your code to an artifact. this is a widely used plugin to build a continuous integration
Prerequisites
- Jenkins server
hostname jenkins
sudo su -
cd /opt
ls -ltr
Install Maven on Jenkins
- Download maven packages https://maven.apache.org/download.cgi onto Jenkins server. In this case, I am using /opt/maven as my installation directory
- Link : https://maven.apache.org/download.cgi
- sudo wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
sudo tar -xvzf apache-maven-3.8.6-bin.tar.gz
sudo mv apache-maven-3.8.6 maven
cd maven
- Setup M2_HOME and M2 paths in .bash_profile of the user and add these to the path variable
[root@jenkins ~]# vi ~/.bash_profile
M2_HOME=/opt/maven
M2=$M2_HOME/bin
echo $M2
exit
sudo su -
echo $M2
echo $M2_HOME
[root@jenkins ~]# vi ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.17.0.8–2.el9_0.x86_64
M2_HOME=/opt/maven
M2=$M2_HOME/bin
PATH=$PATH:$JAVA_HOME:$HOME/bin:$M2:$M2_HOME
export PATH
exit
sudo su -
Checkpoint
- logoff and login to check maven version
mvn - version
So far we have completed the installation of the maven software to support the maven plugin on the Jenkins console. Let’s jump onto Jenkins to complete the remaining steps.
Setup maven on Jenkins console
- Install maven plugin without restart
Manage Jenkins
>Jenkins Plugins
>available
>Maven Invoker
Manage Jenkins
>Jenkins Plugins
>available
>Maven Integration
2. Configure the maven path
Manage Jenkins
>Global Tool Configuration
>Maven
Done.
If you Want to Learn Python, You can watch my ultimate Python Course on My Youtube Channel.
You can join there as well to share your Queries and suggestions. Facebook Facebook Group: https://web.facebook.com/groups/890525732087988/?mibextid=HsNCOg
You can Also Follow Me on My Social Media Platforms:
Thank You for reading!