Search This Blog

Thursday, 8 June 2023

Install Jenkins on Linux

 Jenkins Installation Requirement for the below specific installation:


JDK : jdk1.8.0_161
Memory: 2G
DiskSpace: 50G
Operating System Version: Oracle Linux Server release 6.6
Java Container: apache-tomcat-8.5.30
Jenkins: Jenkins 2.107.2


Jenkins is a software that allows continuous integration.
Jenkins will be installed on a server where the central build will take place

Step 1) Download jdk from oracle site:
 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html



Step 2) Exact the downloaded jdk file to the directory where you want to install java. I have extracted under /home/oracle
                cd /home/oracle
                gunzip jdk-8u161-linux-x64.tar.gz
                tar -xvf jdk-8u161-linux-x64.tar

Step 3) Setup JAVA_HOME 
            After the extraction you should see the extracted version /home/oracle/jdk1.8.0_161
            Go to the user home directory 
            cd ~
            update the .bash_profile

vi .bash_profile
--------------------------------
if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi



# Get the aliases and functions

# User specific environment and startup programs

JAVA_HOME=/home/oracle/jdk1.8.0_161

PATH=$PATH:$JAVA_HOME/bin

export PATH

-------------------------------

Restart the Unix terminal or execute . .bash_profile for setting up JAVA_HOME variable.

Verify the java version by executing the following command.
[oracle@OracleLinux6 ~]$ java -version

java version "1.7.0_21"

Java(TM) SE Runtime Environment (build 1.7.0_21-b11)

Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

Step 4) Download and install Apache tomcat application server.

Download the tomcat version from the following site:

https://tomcat.apache.org/download-80.cgi

I have selected the highlighted version for my installation.



Step 4) Extract downloaded tomcat distribution where you want to install.  

cd /home/oracle
gunzip apache-tomcat-8.5.30.tar.gz
tar -xvf apache-tomcat-8.5.30.tar 

I have the extracted version at /home/oracle/apache-tomcat-8.5.30

Start the tomcat service by executing the following command
cd /home/oracle/apache-tomcat-8.5.30/bin

[oracle@OracleLinux6 bin]$ ./startup.sh

Using CATALINA_BASE:   /home/oracle/apache-tomcat-8.5.30
Using CATALINA_HOME:   /home/oracle/apache-tomcat-8.5.30
Using CATALINA_TMPDIR: /home/oracle/apache-tomcat-8.5.30/temp
Using JRE_HOME:        /home/oracle/jdk1.8.0_151
Using CLASSPATH:       /home/oracle/apache-tomcat-8.5.30/bin/bootstrap.jar:/home/oracle/apache-tomcat-8.5.30/bin/tomcat-juli.jar
Tomcat started.

Access the Tomcat console from web browser.

http://hostname:8080




Step 5) Download and deploy Jenkins war file on tomcat

Download jenkins.war from the following URL:
https://jenkins.io/download/

           

Step 6) Copy the jenkins.war file to the webapp directory and restart tomcat instance for deployment.         

cp /home/oracle/Downloads/jenkins.war /home/oracle/apache-tomcat-8.5.30/webapps/

[oracle@OracleLinux6 webapps]$ ls -rlt
total 72924
drwxr-x---.  3 oracle oracle     4096 Apr 11 21:09 ROOT
drwxr-x---.  5 oracle oracle     4096 Apr 11 21:09 manager
drwxr-x---.  5 oracle oracle     4096 Apr 11 21:09 host-manager
drwxr-x---.  6 oracle oracle     4096 Apr 11 21:09 examples
drwxr-x---. 14 oracle oracle     4096 Apr 11 21:09 docs
-rw-rw-r--.  1 oracle oracle 74568464 Apr 11 21:17 jenkins.war

SHUTDOWN  
/home/oracle/apache-tomcat-8.5.30/bin
[oracle@OracleLinux6 bin]$ ./shutdown.sh
Using CATALINA_BASE:   /home/oracle/apache-tomcat-8.5.30
Using CATALINA_HOME:   /home/oracle/apache-tomcat-8.5.30
Using CATALINA_TMPDIR: /home/oracle/apache-tomcat-8.5.30/temp
Using JRE_HOME:        /home/oracle/jdk1.7.0_21
Using CLASSPATH:       /home/oracle/apache-tomcat-8.5.30/bin/bootstrap.jar:/home/oracle/apache-tomcat-8.5.30/bin/tomcat-juli.jar

STARTUP
[oracle@OracleLinux6 bin]$ ./startup.sh
Using CATALINA_BASE:   /home/oracle/apache-tomcat-8.5.30
Using CATALINA_HOME:   /home/oracle/apache-tomcat-8.5.30
Using CATALINA_TMPDIR: /home/oracle/apache-tomcat-8.5.30/temp
Using JRE_HOME:        /home/oracle/jdk1.7.0_21
Using CLASSPATH:       /home/oracle/apache-tomcat-8.5.30/bin/bootstrap.jar:/home/oracle/apache-tomcat-8.5.30/bin/tomcat-juli.jar
Tomcat started.

Step 7) Access the Jenkins URL on your web browser.
http://hostname:8080/jenkins





Step 8) Unlock Jenkins by entering the Administrator password from the location on your Linux machine and click on install suggested plugins for now.




Step 9) Create Admin user








No comments: