Prerequisites
- Jenkins server
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
# Creating maven directory under /opt mkdir /opt/maven cd /opt/maven # downloading maven version 3.8.6 wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz tar -xvzf apache-maven-3.8.6-bin.tar.gz
- [root@ip-172-31-84-214 ~]# find / -name java-11*/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-1.amzn2.0.3.x86_64# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then. ~/.bashrcfi# User specific environment and startup programsM2_HOME=/opt/maven/apache-maven-3.8.6M2=$M2_HOME/binJAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-1.amzn2.0.3.x86_64PATH=$PATH:$HOME/bin:$JAVA_HOME:$M2_HOME:$M2export PATHAfter saving
[root@ip-172-31-84-214 ~]# source .bash_profile[root@ip-172-31-84-214 ~]# echo $PATH/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin:/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-1.amzn2.0.3.x86_64:/opt/maven/apache-maven-3.8.6:/opt/maven/apache-maven-3.8.6/bin[root@ip-172-31-84-214 ~]# [root@ip-172-31-84-214 ~]# mvn -v Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /opt/maven/apache-maven-3.8.6 Java version: 11.0.13, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-1.amzn2.0.3.x86_64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.10.130-118.517.amzn2.x86_64", arch: "amd64", family: "unix" [root@ip-172-31-84-214 ~]#
Setup maven on Jenkins console
- Install maven plugin without restart
Manage Jenkins
>Jenkins Plugins
>available
>Maven Invoker
Manage Jenkins
>Jenkins Plugins
>available
>Maven Integration
- Configure maven path
Manage Jenkins
>Global Tool Configuration
>Maven
No comments:
Post a Comment