Install & configure Maven build tool 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
# Creating maven directory under /opt mkdir /opt/maven cd /opt/maven # downloading maven version 3.6.0 wget https://archive.apache.org/dist/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.zip unzip /opt/maven/apache-maven-3.6.0-bin.zip
- Setup M2_HOME and M2 paths in .bash_profile of user and add these to path variable
vi ~/.bash_profile M2_HOME=/opt/maven/apache-maven-3.6.0 M2=$M2_HOME/bin PAHT=<Existing_PATH>:$M2_HOME:$M2
- Logoff and login to check maven version Check maven version
mvn –version
- Install maven plugin without restartManage Jenkins > Jenkins Plugins > available > Maven Invoker
- Configure java pathManage Jenkins > Global Tool Configuration > Maven
- Apply & Save