Monday, 7 November 2016

CI-CD_002-Jenkins-on-Tomcat

Tomcat installation

  • Verify the Java installation
    # java -version
  • Set the Java home and Path
    # echo "export JAVA_HOME=/usr/java/jdk1.8.0_91/" >> ~/.bashrc
    # echo "export JAVA_HOME=/usr/java/jdk1.8.0_91/" >> /etc/bashrc
    # echo "export PATH=$PATH:$JAVA_HOME/bin/" >> /etc/bashrc
    # echo "export PATH=$PATH:$JAVA_HOME/bin/" >> ~/.bashrc
  • Download tomcat application from the following site in tar.gz format
    https://tomcat.apache.org/download-70.cgi
  • Make a custom application directory and untar the tomcat application
    mkdir /u01
    cp -prv ~/Downloads/apache-tomcat-7.0.69.tar.gz /u01/
    cd /u01
    tar -xzvf apache-tomcat-7.0.69.tar.gz
  • Create a soft link for the unzipped directory as tomcat
    ln -s apache-tomcat-7.0.69 tomcat
  • Copy the jenkins.war file into webapps directory
    cp -prv `locate jenkins.war` /u01/tomcat/webapps/
  • Now clone the "Jenkins" repo from Linux-Library git account "vmsnivas" and copy the tomcat script from the scripts dir to /sbin
    mkdir /git
    cd /git
    git clone https://github.com/vmsnivas/jenkins.git
    cp -prv /git/jenkins/scripts/tomcat /sbin/
  • Now start the tomcat application
    tomcat start
NOTE : Here you'll face some problems as the default ports of Jenkins and Tomcat are the same (8080). So we'll change the Jenkins port to some other in my case i am using 18080. Also will change the hostname, users and roles in tomcat
  • To change the default port of Jenkins edit "/etc/sysconfig/jenkins"
    JENKINS_PORT="18080"
  • Now let us configure the Tomcat
    - Change the hostname from "localhost" to "dev1.linux-library.ll"
        <Engine name="Catalina" defaultHost="dev1.linux-lirary.ll">
        <Host name="dev1.linux-library.ll"  appBase="webapps"
  • Configure a user to manage the UI. Edit "/u01/tomcat/conf/tomcat-users.xml" and add the following above "" tag.
    <role rolename="manager-gui"/>
    <role rolename="tomcat"/>
    <user username="arjun" password="aDminTom" roles="tomcat,manager-gui"/>
  • Now you can be able to use Jenkins through Tomcat. All you need to do is to load the below url
    http://dev1.linux-library.ll:8080/jenkins/

No comments :

Post a Comment