Monday 11 March 2019

How to install maven in EC2 by Raj Gupta

Prerequisites

  1. Jenkins server

Install Maven on Jenkins

  1. 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
  1. [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 functions
    if [ -f ~/.bashrc ]; then
            . ~/.bashrc
    fi

    # User specific environment and startup programs
    M2_HOME=/opt/maven/apache-maven-3.8.6
    M2=$M2_HOME/bin
    JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-1.amzn2.0.3.x86_64
    PATH=$PATH:$HOME/bin:$JAVA_HOME:$M2_HOME:$M2

    export PATH


    After 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 ~]#

  2. [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

  1. Install maven plugin without restart
  • Manage Jenkins > Jenkins Plugins > available > Maven Invoker
  • Manage Jenkins > Jenkins Plugins > available > Maven Integration
  1. Configure maven path
  • Manage Jenkins > Global Tool Configuration > Maven



No comments:

Post a Comment