Mar 6, 2023

Jenkins setup

Jenkins is built so that it is extensible over any environment and platform for faster development, testing, and deployment. It is more adaptable thanks to its sizeable plug-in library, which allows for creating, deploying, and automating across various platforms. Jenkins, as well as its plugins, are written in Java 


-- Jenkins is a web based application and runs on Java.
-- runs on port 8080

Note: For testing AWS EC2 system used.

URL to find all installation steps:

https://www.jenkins.io/download/
Choose -  Download Jenkins 2.375.3 LTS 

https://pkg.jenkins.io/redhat-stable/

-- Install Java

# yum install fontconfig java-11-openjdk -y
# sudo amazon-linux-extras install java-openjdk11 -y


-- Verify Java version

# java -version
openjdk version "11.0.18" 2023-01-17 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.18.0.10-1.amzn2.0.1) (build 11.0.18+10-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.18.0.10-1.amzn2.0.1) (build 11.0.18+10-LTS, mixed mode, sharing)
#
# which java
/usr/bin/java

-- find the Java installation location

# cd /bin
# ls -l
Found below soft link. here is our java location
java -> /etc/alternatives/java
and the comlete patch of Java is:
/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.amzn2.0.1.x86_64/

]# pwd
/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.amzn2.0.1.x86_64


-- here you can find how many java versions have been installed in your machine

# cd bin
# pwd
/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.amzn2.0.1.x86_64/bin
# sudo update-alternatives --config java
There is 1 program that provides 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.amzn2.0.1.x86_64/bin/java)
Enter to keep the current selection[+], or type selection number:



-- Export Java home and path

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.amzn2.0.1.x86_64
export PATH=$JAVA_HOME/bin:$PATH

-- Test Java working or not

# java -version
openjdk version "11.0.18" 2023-01-17 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.18.0.10-1.amzn2.0.1) (build 11.0.18+10-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.18.0.10-1.amzn2.0.1) (build 11.0.18+10-LTS, mixed mode, sharing)
#


-- Install Jenkins ( https://pkg.jenkins.io/redhat-stable/)

# cd /home/ec2-user/
# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
# yum install jenkins -y
...
Installed:
  jenkins.noarch 0:2.375.3-1.1
Complete!

-- Start Jenkins

ec2-user]# service jenkins start
Starting jenkins (via systemctl):                          [  OK  ]


-- Configure auto start of jenkins when system reboot

# chkconfig jenkins on


-- Note : you ll find all jenkins information related from /etc/sysconfig/jenkins file.

cd /etc/sysconfig
cat jenkins
Default user: jenkins
-- Jenkins configuration file
# cd /var/lib/jenkins
# cat config.xml


-- (part-1)Lunch Jenkins page
-- in browser

http://<host-name/ip>:8080/

Jenkins page will be displayed but it ll ask admin password  from installation location 

# cat /var/lib/jenkins/secrets/initialAdminPassword
47319bd7272f4b04a60dd8e01e29ea69

Copy the password and paste in password section and press continue. It may take some time to complete the plugin installations







































(go-to -> part-2) Here meantime install git and complete maven setup

-- install git

# yum install git -y

-- Setup maven

About maven :

Maven is a build automation tool used primarily for Java projects. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. maven is a product of apache foundation. light weighted as compare to ant.

1) Binary tar.gz archive apache-maven-3.9.0-bin.tar.gz
2) Binary zip archive apache-maven-3.9.0-bin.zip

-- create installation directory for maven

# mkdir /opt/maven
# cd /opt/maven

-- copy link of "apache-maven-3.9.0-bin.tar.gz" and use wget to download

# wget https://dlcdn.apache.org/maven/maven-3/3.9.0/binaries/apache-maven-3.9.0-bin.tar.gz
# ls -l
-rw-r--r-- 1 root root 9024147 Jan 31 15:20 apache-maven-3.9.0-bin.tar.gz

-- extract the tar.gz

 maven]# tar -xvzf apache-maven-3.9.0-bin.tar.gz
# ls
apache-maven-3.9.0  apache-maven-3.9.0-bin.tar.gz
# mv apache-maven-3.9.0 maven
# ls
apache-maven-3.9.0-bin.tar.gz  maven
# ls maven/
bin  boot  conf  lib  LICENSE  NOTICE  README.txt

-- setup maven variable

 maven]# M2_HOME=/opt/maven/maven
 maven]# M2=/opt/maven/maven/bin

# export M2_HOME M2
# PATH=$PATH:$JAVA_HOME:$M2_HOME:$M2

-- Now check the maven version

# mvn --version
Apache Maven 3.9.0 (9b58d2bad23a66be161c4664ef21ce219c2c8584)
Maven home: /opt/maven/maven
Java version: 11.0.18, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.amzn2.0.1.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.10.167-147.601.amzn2.x86_64", arch: "amd64", family: "unix"
[root@ip-172-31-16-110 maven]#


-- (part-2): Now you can continue to configure jenins web page setup 

skip user creation go with default admin account as of now
start using jenkins
Now you ll have welcome/ first page of jenkins

-- Now chnage the admin user password:

Click on admin drop down --> configure --> go to password section --> use new password --> Save
user : admin
password :  xxxxxx

Note: from url you can stop/ start and restart jenkins

e.g.,
http://<ip-address>:8080/restart


-- Let us do some configuration change and then we can restart Jenkins




















From Jenkins Home page --> click on "Manage Jenkins" --> "Global tool configuration"


Go to JDK section:

here you type your JDK location ( this is JAVA_HOME)
Use : JAVA_HOME
path : /usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.amzn2.0.1.x86_64










Note: no change to git. it ll take default setup

Go to maven section ( use what we did in setup section)

Name : M2_HOME
Home : /opt/maven/maven






Now you can restart if you need.
http://18.142.45.170:8080/restart
















Automatically you get login screen once restarted. you ll find log in screen again.


























No comments:

Post a Comment

Translate >>